forked from p0f/p0f
-
Notifications
You must be signed in to change notification settings - Fork 0
/
host.cpp
66 lines (48 loc) · 1.26 KB
/
host.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "host.h"
host::host(QString ip){
ip_host = ip;
}
QString host::get_ip(){
return ip_host;
}
QString host::get_os(){
QString os = "";
if(host_packets.value(SYN_INFO)!=NULL){
os = host_packets.value(SYN_INFO)->get_value("os");
}
return os;
}
//Return the app field value
QString host::get_app(){
QString app = "";
if(host_packets.value(HTTP_RESPONSE)!=NULL){
app = host_packets.value(HTTP_RESPONSE)->get_value("app");
}
return app;
}
//Return a specific packet
p0f_info* host::get_packet(info_type type){
return host_packets.value(type);
}
//Return all packets link to host
QHash<info_type,p0f_info*> host::get_packets(){
return host_packets;
}
void host::set_packet(p0f_info* info){
host_packets.insert(info->get_type(),info);
}
//Chech if an host is probably behind nat
bool host::host_with_nat(){
return this->get_packet(HOST_CHANGE)!=NULL;
}
//Return all the host's informations
QString host::print_packets(){
QString info;
if(this->get_packet(HOST_CHANGE)!=NULL){
info.append("PAY ATTENTION\nHOST MAY BE RUNNING BEHIND NAT\nINFORMATIONS CAN BE INCORRECT");
}
foreach(p0f_info* packet, host_packets){
info.append(packet->get_info());
}
return info;
}