mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-23 00:29:59 +02:00
fixes for bsd-style ipv6 output
This commit is contained in:
@ -45,9 +45,10 @@ Copyright (C) 2015 Luis Benitez
|
|||||||
Parses the output of a traceroute execution into an AST (Abstract Syntax Tree).
|
Parses the output of a traceroute execution into an AST (Abstract Syntax Tree).
|
||||||
"""
|
"""
|
||||||
|
|
||||||
RE_HEADER = re.compile(r'(\S+)\s+\((?:(\d+\.\d+\.\d+\.\d+)|([0-9a-fA-F:]+))\)')
|
RE_HEADER = re.compile(r'(\S+)\s+\((?:(\d+\.\d+\.\d+\.\d+|[0-9a-fA-F:]+))\)')
|
||||||
|
|
||||||
RE_PROBE_NAME_IP = re.compile(r'(\S+)\s+\((?:(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})|([0-9a-fA-F:]+))\)+')
|
RE_PROBE_NAME_IP = re.compile(r'(\S+)\s+\((?:(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|[0-9a-fA-F:]+))\)+')
|
||||||
|
RE_PROBE_BSD_IPV6 = re.compile(r'\b(?:[A-Fa-f0-9]{1,4}:){7}[A-Fa-f0-9]{1,4}\b')
|
||||||
RE_PROBE_ANNOTATION = re.compile(r'^(!\w*)$')
|
RE_PROBE_ANNOTATION = re.compile(r'^(!\w*)$')
|
||||||
RE_PROBE_TIMEOUT = re.compile(r'^(\*)$')
|
RE_PROBE_TIMEOUT = re.compile(r'^(\*)$')
|
||||||
|
|
||||||
@ -174,9 +175,13 @@ def loads(data):
|
|||||||
probe_asn = None
|
probe_asn = None
|
||||||
|
|
||||||
probe_name_ip_match = RE_PROBE_NAME_IP.search(hop_string)
|
probe_name_ip_match = RE_PROBE_NAME_IP.search(hop_string)
|
||||||
|
probe_bsd_ipv6_match = RE_PROBE_BSD_IPV6.search(hop_string)
|
||||||
if probe_name_ip_match:
|
if probe_name_ip_match:
|
||||||
probe_name = probe_name_ip_match.group(1)
|
probe_name = probe_name_ip_match.group(1)
|
||||||
probe_ip = probe_name_ip_match.group(2) or probe_name_ip_match.group(3)
|
probe_ip = probe_name_ip_match.group(2)
|
||||||
|
elif probe_bsd_ipv6_match:
|
||||||
|
probe_name = None
|
||||||
|
probe_ip = probe_bsd_ipv6_match.group(0)
|
||||||
else:
|
else:
|
||||||
probe_name = None
|
probe_name = None
|
||||||
probe_ip = None
|
probe_ip = None
|
||||||
|
4
tests/fixtures/osx-10.14.6/traceroute-q.out
vendored
Normal file
4
tests/fixtures/osx-10.14.6/traceroute-q.out
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
traceroute to 8.8.8.8 (8.8.8.8), 3 hops max, 52 byte packets
|
||||||
|
1 dsldevice (192.168.1.254) 3.317 ms 6.373 ms 6.967 ms 5.299 ms 4.605 ms
|
||||||
|
2 76-220-24-1.lightspeed.sntcca.sbcglobal.net (76.220.24.1) 28.829 ms 20.073 ms 26.238 ms 22.052 ms 22.519 ms
|
||||||
|
3 * * * * *
|
Reference in New Issue
Block a user