Improved bittorrent heuristic
This commit is contained in:
+4
-2
@@ -4928,8 +4928,10 @@ int ndpi_search_into_bittorrent_cache(struct ndpi_detection_module_struct *ndpi_
|
||||
/* Check cached communications */
|
||||
key1 = ndpi_bittorrent_hash_funct(saddr, sport), key2 = ndpi_bittorrent_hash_funct(daddr, dport);
|
||||
|
||||
found = ndpi_lru_find_cache(ndpi_struct->bittorrent_cache, key1, &cached_proto, 0 /* Don't remove it as it can be used for other connections */)
|
||||
|| ndpi_lru_find_cache(ndpi_struct->bittorrent_cache, key2, &cached_proto, 0 /* Don't remove it as it can be used for other connections */);
|
||||
found =
|
||||
ndpi_lru_find_cache(ndpi_struct->bittorrent_cache, saddr+daddr, &cached_proto, 0 /* Don't remove it as it can be used for other connections */)
|
||||
|| ndpi_lru_find_cache(ndpi_struct->bittorrent_cache, key1, &cached_proto, 0 /* Don't remove it as it can be used for other connections */)
|
||||
|| ndpi_lru_find_cache(ndpi_struct->bittorrent_cache, key2, &cached_proto, 0 /* Don't remove it as it can be used for other connections */);
|
||||
|
||||
#ifdef BITTORRENT_CACHE_DEBUG
|
||||
if(packet->udp)
|
||||
|
||||
@@ -141,6 +141,11 @@ static void ndpi_add_connection_as_bittorrent(struct ndpi_detection_module_struc
|
||||
ndpi_lru_add_to_cache(ndpi_struct->bittorrent_cache, key1, NDPI_PROTOCOL_BITTORRENT);
|
||||
ndpi_lru_add_to_cache(ndpi_struct->bittorrent_cache, key2, NDPI_PROTOCOL_BITTORRENT);
|
||||
|
||||
/* Now add hosts as twins */
|
||||
ndpi_lru_add_to_cache(ndpi_struct->bittorrent_cache,
|
||||
packet->iph->saddr + packet->iph->daddr,
|
||||
NDPI_PROTOCOL_BITTORRENT);
|
||||
|
||||
/* Also add +2 ports of the sender in order to catch additional sockets open by the same client */
|
||||
for(i=0; i<2; i++) {
|
||||
if(packet->udp)
|
||||
@@ -509,20 +514,6 @@ static void ndpi_search_bittorrent(struct ndpi_detection_module_struct *ndpi_str
|
||||
|
||||
if(flow->detected_protocol_stack[0] != NDPI_PROTOCOL_BITTORRENT) {
|
||||
/* check for tcp retransmission here */
|
||||
|
||||
#ifdef EXCLUDE_BITTORRENT_QUICKLY
|
||||
u_int16_t sport, dport;
|
||||
|
||||
if(packet->udp)
|
||||
sport = packet->udp->source, dport = packet->udp->dest;
|
||||
else
|
||||
sport = packet->tcp->source, dport = packet->tcp->dest;
|
||||
|
||||
if(ndpi_search_into_bittorrent_cache(ndpi_struct, flow, packet->iph->saddr, sport, packet->iph->daddr, dport)) {
|
||||
ndpi_search_bittorrent_hash(ndpi_struct, flow, -1);
|
||||
goto bittorrent_found;
|
||||
}
|
||||
#endif
|
||||
|
||||
if(packet->tcp != NULL) {
|
||||
ndpi_int_search_bittorrent_tcp(ndpi_struct, flow);
|
||||
|
||||
Reference in New Issue
Block a user