Skip to content

Commit 4d17dc6

Browse files
committed
Telegram STUN improvement
1 parent 21493d5 commit 4d17dc6

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

src/lib/ndpi_utils.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1653,8 +1653,14 @@ int ndpi_dpi2json(struct ndpi_detection_module_struct *ndpi_struct,
16531653
break;
16541654

16551655
case NDPI_PROTOCOL_TLS:
1656+
ndpi_tls2json(serializer, flow);
1657+
break;
1658+
16561659
case NDPI_PROTOCOL_DTLS:
16571660
ndpi_tls2json(serializer, flow);
1661+
#ifdef CUSTOM_NDPI_PROTOCOLS
1662+
#include "../../../nDPI-custom/ndpi_utils_dpi2json_dtls.c"
1663+
#endif
16581664
break;
16591665

16601666
#ifdef CUSTOM_NDPI_PROTOCOLS

src/lib/protocols/stun.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -675,12 +675,11 @@ static int keep_extra_dissection(struct ndpi_detection_module_struct *ndpi_struc
675675
/* We want extra dissection for:
676676
* sub-classification
677677
* metadata extraction (*-ADDRESS) or looking for RTP
678-
At the moment:
678+
* At the moment:
679679
* it seems ZOOM doens't have any meaningful attributes
680680
* we want (all) XOR-PEER-ADDRESS only for Telegram.
681681
* for the other protocols, we stop after we have all metadata (if enabled)
682-
* for some specific protocol, we might know that some attributes
683-
are never used
682+
* for some specific protocol, we might know that some attributes are never used
684683
* if monitoring is enabled, keep looking for (S)RTP anyway
685684
686685
**After** extra dissection is ended, we might move to monitoring. Note that:
@@ -698,7 +697,21 @@ static int keep_extra_dissection(struct ndpi_detection_module_struct *ndpi_struc
698697
if(flow->stun.num_non_stun_pkt == 2)
699698
printf("%d %d\n", flow->stun.non_stun_pkt_len[0], flow->stun.non_stun_pkt_len[1]);
700699
#endif
701-
}
700+
}
701+
}
702+
703+
if(packet->payload_packet_len > 699) {
704+
if(flow->detected_protocol_stack[0] == NDPI_PROTOCOL_TELEGRAM_VOIP) {
705+
if((packet->payload[0] == 0x16) && (packet->payload[1] == 0xfe)
706+
&& ((packet->payload[2] == 0xff) /* DTLS 1.0 */
707+
|| (packet->payload[2] == 0xfd) /* DTLS 1.2 */ ))
708+
; /* Skip DTLS */
709+
else {
710+
/* STUN or RTP */
711+
/* This packet is too big to be audio: add video */
712+
flow->flow_multimedia_types |= ndpi_multimedia_video_flow;
713+
}
714+
}
702715
}
703716

704717
if(flow->monitoring)

0 commit comments

Comments
 (0)