File tree Expand file tree Collapse file tree 1 file changed +30
-2
lines changed
Expand file tree Collapse file tree 1 file changed +30
-2
lines changed Original file line number Diff line number Diff line change 22PCAP Parser for XCloud network traffic
33"""
44import argparse
5+ import logging
56
67import dpkt
8+ from aiortc import rtp
9+ from aioice import stun
710from construct .lib import containers
811
12+ from ..protocol import packets
913
14+
15+ logging .basicConfig (level = logging .DEBUG )
1016containers .setGlobalPrintFullStrings (True )
17+ LOG = logging .getLogger (__name__ )
18+
19+ def print_stun (stun : stun .Message ) -> None :
20+ print (f'STUN: { stun } ' )
21+
22+ def print_rtp (rtp : rtp .RtpPacket ) -> None :
23+ try :
24+ payload_name = packets .PayloadType (rtp .payload_type )
25+ except :
26+ payload_name = '<UNKNOWN>'
1127
28+ print (f'RTP: { payload_name .name } { rtp } ' )
29+
30+ PACKET_TYPES = [
31+ (stun .parse_message , print_stun ),
32+ (rtp .RtpPacket .parse , print_rtp )
33+ ]
1234
1335def packet_filter (filepath ):
1436 with open (filepath , 'rb' ) as fh :
@@ -28,8 +50,14 @@ def packet_filter(filepath):
2850
2951def parse_file (pcap_filepath : str ) -> None :
3052 for packet , timestamp in packet_filter (pcap_filepath ):
31- print (packet , timestamp )
32-
53+ packet = bytes (packet .data )
54+ for cls , print_func in PACKET_TYPES :
55+ try :
56+ instance = cls (packet )
57+ print_func (instance )
58+ except :
59+ pass
60+
3361
3462def main ():
3563 parser = argparse .ArgumentParser (
You can’t perform that action at this time.
0 commit comments