Exported HTTP server in metadata

This commit is contained in:
Luca Deri
2022-12-05 21:27:30 +01:00
parent c882120afd
commit e0afc16aa2
7 changed files with 26 additions and 4 deletions
+2 -2
View File
@@ -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 {
+3
View File
@@ -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);
+11
View File
@@ -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) {