aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuca Deri <deri@ntop.org>2019-10-01 12:25:39 +0200
committerLuca Deri <deri@ntop.org>2019-10-01 12:25:39 +0200
commite45237a93f771f3d4aeb6c2360469f09c0282b58 (patch)
tree59b012693a1a66cbb493b0830f8ba61169aaf9bc
parenta62cf102331653119b83e87d2efdef6d11cefcd1 (diff)
Removed http:// from HTTP url
Reported URL in ndpiReader
-rw-r--r--example/ndpiReader.c4
-rw-r--r--example/reader_util.c9
-rw-r--r--example/reader_util.h5
-rw-r--r--src/lib/protocols/http.c7
4 files changed, 20 insertions, 5 deletions
diff --git a/example/ndpiReader.c b/example/ndpiReader.c
index 1a54b59d4..c22a6d496 100644
--- a/example/ndpiReader.c
+++ b/example/ndpiReader.c
@@ -1138,6 +1138,10 @@ static void printFlow(u_int16_t id, struct ndpi_flow_info *flow, u_int16_t threa
}
}
+ if(flow->http.url[0] != '\0')
+ fprintf(out, "[URL: %s][StatusCode: %u]",
+ flow->http.url, flow->http.response_status_code);
+
if(flow->ssh_tls.ssl_version != 0) fprintf(out, "[%s]", ndpi_ssl_version2str(flow->ssh_tls.ssl_version));
if(flow->ssh_tls.client_info[0] != '\0') fprintf(out, "[Client: %s]", flow->ssh_tls.client_info);
if(flow->ssh_tls.client_hassh[0] != '\0') fprintf(out, "[HASSH-C: %s]", flow->ssh_tls.client_hassh);
diff --git a/example/reader_util.c b/example/reader_util.c
index db25099a2..1cfedf1a6 100644
--- a/example/reader_util.c
+++ b/example/reader_util.c
@@ -976,7 +976,14 @@ void process_ndpi_collected_info(struct ndpi_workflow * workflow, struct ndpi_fl
else if(flow->detected_protocol.app_protocol == NDPI_PROTOCOL_UBNTAC2) {
snprintf(flow->info, sizeof(flow->info), "%s", flow->ndpi_flow->protos.ubntac2.version);
}
- if(flow->detected_protocol.app_protocol != NDPI_PROTOCOL_DNS) {
+ /* HTTP */
+ else if(flow->detected_protocol.master_protocol == NDPI_PROTOCOL_HTTP) {
+ if(flow->ndpi_flow->http.url != NULL) {
+ 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;
+ }
+ }
+ else if(flow->detected_protocol.app_protocol != NDPI_PROTOCOL_DNS) {
/* SSH */
if(flow->detected_protocol.app_protocol == NDPI_PROTOCOL_SSH) {
snprintf(flow->ssh_tls.client_info, sizeof(flow->ssh_tls.client_info), "%s",
diff --git a/example/reader_util.h b/example/reader_util.h
index 2055d7156..309e51d08 100644
--- a/example/reader_util.h
+++ b/example/reader_util.h
@@ -167,6 +167,11 @@ typedef struct ndpi_flow_info {
u_int16_t server_cipher;
ndpi_cipher_weakness client_unsafe_cipher, server_unsafe_cipher;
} ssh_tls;
+
+ struct {
+ char url[256];
+ u_int response_status_code;
+ } http;
void *src_id, *dst_id;
diff --git a/src/lib/protocols/http.c b/src/lib/protocols/http.c
index a118477c5..cc27b8eb6 100644
--- a/src/lib/protocols/http.c
+++ b/src/lib/protocols/http.c
@@ -162,13 +162,12 @@ static void check_content_type_and_change_protocol(struct ndpi_detection_module_
if((flow->http.url == NULL)
&& (packet->http_url_name.len > 0)
&& (packet->host_line.len > 0)) {
- int len = packet->http_url_name.len + packet->host_line.len + 7 + 1; /* "http://" */
+ int len = packet->http_url_name.len + packet->host_line.len + 1;
flow->http.url = ndpi_malloc(len);
if(flow->http.url) {
- strcpy(flow->http.url, "http://");
- strncpy(&flow->http.url[7], (char*)packet->host_line.ptr, packet->host_line.len);
- strncpy(&flow->http.url[7+packet->host_line.len], (char*)packet->http_url_name.ptr,
+ strncpy(flow->http.url, (char*)packet->host_line.ptr, packet->host_line.len);
+ strncpy(&flow->http.url[packet->host_line.len], (char*)packet->http_url_name.ptr,
packet->http_url_name.len);
flow->http.url[len-1] = '\0';
}