Exported HTTP server in metadata
This commit is contained in:
@@ -1578,6 +1578,9 @@ static void printFlow(u_int32_t id, struct ndpi_flow_info *flow, u_int16_t threa
|
||||
fprintf(out, "[Content-Type: %s]", flow->http.content_type);
|
||||
}
|
||||
|
||||
if(flow->http.server[0] != '\0')
|
||||
fprintf(out, "[Server: %s]", flow->http.server);
|
||||
|
||||
if(flow->http.user_agent[0] != '\0')
|
||||
fprintf(out, "[User-Agent: %s]", flow->http.user_agent);
|
||||
|
||||
|
||||
@@ -1214,6 +1214,7 @@ void process_ndpi_collected_info(struct ndpi_workflow * workflow, struct ndpi_fl
|
||||
ndpi_snprintf(flow->http.url, sizeof(flow->http.url), "%s", flow->ndpi_flow->http.url);
|
||||
flow->http.response_status_code = flow->ndpi_flow->http.response_status_code;
|
||||
ndpi_snprintf(flow->http.content_type, sizeof(flow->http.content_type), "%s", flow->ndpi_flow->http.content_type ? flow->ndpi_flow->http.content_type : "");
|
||||
ndpi_snprintf(flow->http.server, sizeof(flow->http.server), "%s", flow->ndpi_flow->http.server ? flow->ndpi_flow->http.server : "");
|
||||
ndpi_snprintf(flow->http.request_content_type, sizeof(flow->http.request_content_type), "%s", flow->ndpi_flow->http.request_content_type ? flow->ndpi_flow->http.request_content_type : "");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -275,7 +275,7 @@ typedef struct ndpi_flow_info {
|
||||
} ssh_tls;
|
||||
|
||||
struct {
|
||||
char url[256], request_content_type[64], content_type[64], user_agent[256];
|
||||
char url[256], request_content_type[64], content_type[64], user_agent[256], server[128];
|
||||
u_int response_status_code;
|
||||
} http;
|
||||
|
||||
|
||||
@@ -1355,14 +1355,14 @@ struct ndpi_flow_struct {
|
||||
ndpi_http_method method;
|
||||
u_int8_t request_version; /* 0=1.0 and 1=1.1. Create an enum for this? */
|
||||
u_int16_t response_status_code; /* 200, 404, etc. */
|
||||
char *url, *content_type /* response */, *request_content_type /* e.g. for POST */, *user_agent;
|
||||
char *url, *content_type /* response */, *request_content_type /* e.g. for POST */, *user_agent, *server;
|
||||
char *detected_os; /* Via HTTP/QUIC User-Agent */
|
||||
char *nat_ip; /* Via HTTP X-Forwarded-For */
|
||||
} http;
|
||||
|
||||
/*
|
||||
Put outside of the union to avoid issues in case the protocol
|
||||
is remapped to somethign pther than Kerberos due to a faulty
|
||||
is remapped to something other than Kerberos due to a faulty
|
||||
dissector
|
||||
*/
|
||||
struct {
|
||||
|
||||
@@ -5057,6 +5057,9 @@ void ndpi_free_flow_data(struct ndpi_flow_struct* flow) {
|
||||
if(flow->http.detected_os)
|
||||
ndpi_free(flow->http.detected_os);
|
||||
|
||||
if(flow->http.server)
|
||||
ndpi_free(flow->http.server);
|
||||
|
||||
if(flow->kerberos_buf.pktbuf)
|
||||
ndpi_free(flow->kerberos_buf.pktbuf);
|
||||
|
||||
|
||||
@@ -882,6 +882,17 @@ static void check_content_type_and_change_protocol(struct ndpi_detection_module_
|
||||
flow->guessed_category = flow->category = ndpi_http_check_content(ndpi_struct, flow);
|
||||
}
|
||||
}
|
||||
|
||||
if((flow->http.server == NULL) && (packet->server_line.len > 0)) {
|
||||
int len = packet->server_line.len + 1;
|
||||
|
||||
flow->http.server = ndpi_malloc(len);
|
||||
if(flow->http.server) {
|
||||
strncpy(flow->http.server, (char*)packet->server_line.ptr,
|
||||
packet->server_line.len);
|
||||
flow->http.server[packet->server_line.len] = '\0';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(flow->http_detected && packet->content_line.ptr && *(char*)packet->content_line.ptr) {
|
||||
|
||||
+5
-1
@@ -63,8 +63,9 @@ static int verbose = 0;
|
||||
/* *********************************************** */
|
||||
|
||||
#define FLT_MAX 3.402823466e+38F
|
||||
|
||||
int serializerUnitTest() {
|
||||
ndpi_serializer serializer = {0}, deserializer = {0};
|
||||
ndpi_serializer serializer, deserializer;
|
||||
int i, loop_id;
|
||||
ndpi_serialization_format fmt = {0};
|
||||
u_int32_t buffer_len;
|
||||
@@ -72,6 +73,9 @@ int serializerUnitTest() {
|
||||
enum json_tokener_error jerr;
|
||||
json_object *j;
|
||||
|
||||
memset(&serializer, 0, sizeof(serializer));
|
||||
memset(&deserializer, 0, sizeof(deserializer));
|
||||
|
||||
for(loop_id=0; loop_id<3; loop_id++) {
|
||||
switch(loop_id) {
|
||||
case 0:
|
||||
|
||||
Reference in New Issue
Block a user