aboutsummaryrefslogtreecommitdiff
path: root/example
diff options
context:
space:
mode:
authorToni <matzeton@googlemail.com>2022-04-25 13:00:50 +0200
committerGitHub <noreply@github.com>2022-04-25 13:00:50 +0200
commitbc2ad3407a1cf7f6d2913f113df31dfbf735c6f6 (patch)
treea06e65f5d38238a894dea0415b2b6584cd027e4f /example
parent075bce5f3de463975464472158dca980a45f48a3 (diff)
Added generic user agent setter. (#1530)
* ndpiReader: Print user agent if one was set and not just for certain protocols. Signed-off-by: lns <matzeton@googlemail.com>
Diffstat (limited to 'example')
-rw-r--r--example/reader_util.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/example/reader_util.c b/example/reader_util.c
index dec8e1216..d36c42a16 100644
--- a/example/reader_util.c
+++ b/example/reader_util.c
@@ -1116,11 +1116,7 @@ void process_ndpi_collected_info(struct ndpi_workflow * workflow, struct ndpi_fl
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.request_content_type, sizeof(flow->http.request_content_type), "%s", flow->ndpi_flow->http.request_content_type ? flow->ndpi_flow->http.request_content_type : "");
- ndpi_snprintf(flow->http.user_agent, sizeof(flow->http.user_agent), "%s", flow->ndpi_flow->http.user_agent ? flow->ndpi_flow->http.user_agent : "");
}
- } else if(is_ndpi_proto(flow, NDPI_PROTOCOL_SSDP) ||
- is_ndpi_proto(flow, NDPI_PROTOCOL_XIAOMI)) {
- ndpi_snprintf(flow->http.user_agent, sizeof(flow->http.user_agent), "%s", flow->ndpi_flow->http.user_agent ? flow->ndpi_flow->http.user_agent : "");
} else if(is_ndpi_proto(flow, NDPI_PROTOCOL_TELNET)) {
if(flow->ndpi_flow->protos.telnet.username[0] != '\0')
flow->telnet.username = ndpi_strdup(flow->ndpi_flow->protos.telnet.username);
@@ -1145,8 +1141,6 @@ void process_ndpi_collected_info(struct ndpi_workflow * workflow, struct ndpi_fl
) {
flow->ssh_tls.ssl_version = flow->ndpi_flow->protos.tls_quic.ssl_version;
- ndpi_snprintf(flow->http.user_agent, sizeof(flow->http.user_agent), "%s", flow->ndpi_flow->http.user_agent ? flow->ndpi_flow->http.user_agent : "");
-
if(flow->ndpi_flow->protos.tls_quic.server_names_len > 0 && flow->ndpi_flow->protos.tls_quic.server_names)
flow->ssh_tls.server_names = ndpi_strdup(flow->ndpi_flow->protos.tls_quic.server_names);
@@ -1224,6 +1218,10 @@ void process_ndpi_collected_info(struct ndpi_workflow * workflow, struct ndpi_fl
}
}
+ ndpi_snprintf(flow->http.user_agent,
+ sizeof(flow->http.user_agent),
+ "%s", (flow->ndpi_flow->http.user_agent ? flow->ndpi_flow->http.user_agent : ""));
+
if(flow->detection_completed && (!flow->check_extra_packets)) {
if(is_ndpi_proto(flow, NDPI_PROTOCOL_UNKNOWN)) {
if(workflow->__flow_giveup_callback != NULL)