Added improvement for handling bit-torrent search on UDP

Added quic protocol sample
This commit is contained in:
Luca Deri
2015-05-13 23:37:31 +02:00
parent 08c8fe7411
commit bcd8380704
3 changed files with 40 additions and 31 deletions
+1 -1
View File
@@ -946,7 +946,7 @@ static void ndpi_init_protocol_defaults(struct ndpi_detection_module_struct *ndp
no_master, no_master,
no_master, "BitTorrent", no_master, "BitTorrent",
ndpi_build_default_ports(ports_a, 0, 0, 0, 0, 0) /* TCP */, ndpi_build_default_ports(ports_a, 0, 0, 0, 0, 0) /* TCP */,
ndpi_build_default_ports(ports_b, 0, 0, 0, 0, 0) /* UDP */); ndpi_build_default_ports(ports_b, 6771, 0, 0, 0, 0) /* UDP */);
ndpi_set_proto_defaults(ndpi_mod, NDPI_PROTOCOL_ACCEPTABLE, NDPI_PROTOCOL_EPP, ndpi_set_proto_defaults(ndpi_mod, NDPI_PROTOCOL_ACCEPTABLE, NDPI_PROTOCOL_EPP,
no_master, no_master,
no_master, "EPP", no_master, "EPP",
+9
View File
@@ -384,6 +384,8 @@ void ndpi_search_bittorrent(struct ndpi_detection_module_struct *ndpi_struct, st
ndpi_int_search_bittorrent_tcp(ndpi_struct, flow); ndpi_int_search_bittorrent_tcp(ndpi_struct, flow);
} }
else if(packet->udp != NULL) { else if(packet->udp != NULL) {
char *bt_search = "BT-SEARCH * HTTP/1.1\r\n";
if((ntohs(packet->udp->source) < 1024) if((ntohs(packet->udp->source) < 1024)
|| (ntohs(packet->udp->dest) < 1024) /* High ports only */) || (ntohs(packet->udp->dest) < 1024) /* High ports only */)
return; return;
@@ -395,6 +397,12 @@ void ndpi_search_bittorrent(struct ndpi_detection_module_struct *ndpi_struct, st
*/ */
if(packet->payload_packet_len >= 23 /* min header size */) { if(packet->payload_packet_len >= 23 /* min header size */) {
if(strncmp((const char*)packet->payload, bt_search, strlen(bt_search)) == 0) {
ndpi_add_connection_as_bittorrent(ndpi_struct, flow,
NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_PLAIN_DETECTION,
NDPI_REAL_PROTOCOL);
return;
} else {
/* Check if this is protocol v0 */ /* Check if this is protocol v0 */
u_int8_t v0_extension = packet->payload[17]; u_int8_t v0_extension = packet->payload[17];
u_int8_t v0_flags = packet->payload[18]; u_int8_t v0_flags = packet->payload[18];
@@ -436,6 +444,7 @@ void ndpi_search_bittorrent(struct ndpi_detection_module_struct *ndpi_struct, st
} }
} }
} }
}
flow->bittorrent_stage++; flow->bittorrent_stage++;
Binary file not shown.