mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-10-08 23:22:21 +02:00
fixup route-print parser
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
jc changelog
|
||||
|
||||
20250724 v1.25.6
|
||||
20250904 v1.25.6
|
||||
- Add `x509-crl` file parser to support Certificate Revocation List PEM and DER files
|
||||
- Add `route-print` Windows command parser
|
||||
- Fix `bluetoothctl` command parser to support output with the `cable_pairing` attribute
|
||||
- Fix `nmcli` command parser to support blank `team.config` JSON value and `team-port.config` JSON value
|
||||
- Fix `top` command parsers to correct memory size field parsing. Several new unit
|
||||
|
@@ -111,8 +111,6 @@ Examples:
|
||||
]
|
||||
"""
|
||||
import jc.utils
|
||||
import jc.parsers.universal
|
||||
|
||||
|
||||
class info():
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
|
@@ -1,6 +1,5 @@
|
||||
r"""jc - JSON Convert `route print` command output parser
|
||||
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ route print | jc --route-print
|
||||
@@ -27,7 +26,8 @@ Schema:
|
||||
"netmask": string,
|
||||
"gateway": string,
|
||||
"interface": string,
|
||||
"metric": string
|
||||
"metric": integer,
|
||||
"metric_set_to_default": boolean # if metric="Default"
|
||||
}
|
||||
],
|
||||
"persistent_routes": [
|
||||
@@ -35,7 +35,8 @@ Schema:
|
||||
"network_address": string,
|
||||
"netmask": string,
|
||||
"gateway_address": string,
|
||||
"metric": string
|
||||
"metric": integer
|
||||
"metric_set_to_default": boolean # if metric="Default"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -43,7 +44,8 @@ Schema:
|
||||
"active_routes": [
|
||||
{
|
||||
"interface": integer,
|
||||
"metric": string,
|
||||
"metric": integer,
|
||||
"metric_set_to_default": boolean, # if metric="Default"
|
||||
"network_destination": string,
|
||||
"gateway": string
|
||||
}
|
||||
@@ -51,7 +53,8 @@ Schema:
|
||||
"persistent_routes": [
|
||||
{
|
||||
"interface": integer,
|
||||
"metric": string,
|
||||
"metric": integer,
|
||||
"metric_set_to_default": boolean, # if metric="Default"
|
||||
"network_destination": string,
|
||||
"gateway": string
|
||||
}
|
||||
@@ -59,14 +62,9 @@ Schema:
|
||||
}
|
||||
}
|
||||
|
||||
Notes:
|
||||
- The `metric` field is typically an integer but can sometimes be set to "Default"
|
||||
|
||||
|
||||
Examples:
|
||||
|
||||
$ route print | jc --route-print -p | jq
|
||||
|
||||
$ route print | jc --route-print -p
|
||||
{
|
||||
"interface_list": [
|
||||
{
|
||||
@@ -92,126 +90,25 @@ Examples:
|
||||
"netmask": "0.0.0.0",
|
||||
"gateway": "10.211.55.1",
|
||||
"interface": "10.211.55.3",
|
||||
"metric": "15"
|
||||
"metric": 15,
|
||||
"metric_set_to_default": false
|
||||
},
|
||||
{
|
||||
"network_destination": "10.0.0.0",
|
||||
"netmask": "255.0.0.0",
|
||||
"gateway": "192.168.22.1",
|
||||
"interface": "10.211.55.3",
|
||||
"metric": "16"
|
||||
},
|
||||
{
|
||||
"network_destination": "10.0.1.0",
|
||||
"netmask": "255.255.255.0",
|
||||
"gateway": "192.168.22.1",
|
||||
"interface": "10.211.55.3",
|
||||
"metric": "16"
|
||||
},
|
||||
{
|
||||
"network_destination": "10.0.3.0",
|
||||
"netmask": "255.255.255.0",
|
||||
"gateway": "192.168.22.1",
|
||||
"interface": "10.211.55.3",
|
||||
"metric": "16"
|
||||
},
|
||||
{
|
||||
"network_destination": "10.0.4.0",
|
||||
"netmask": "255.255.255.0",
|
||||
"gateway": "192.168.22.1",
|
||||
"interface": "10.211.55.3",
|
||||
"metric": "16"
|
||||
},
|
||||
{
|
||||
"network_destination": "10.211.55.0",
|
||||
"netmask": "255.255.255.0",
|
||||
"gateway": "On-link",
|
||||
"interface": "10.211.55.3",
|
||||
"metric": "271"
|
||||
},
|
||||
{
|
||||
"network_destination": "10.211.55.3",
|
||||
"netmask": "255.255.255.255",
|
||||
"gateway": "On-link",
|
||||
"interface": "10.211.55.3",
|
||||
"metric": "271"
|
||||
},
|
||||
{
|
||||
"network_destination": "10.211.55.255",
|
||||
"netmask": "255.255.255.255",
|
||||
"gateway": "On-link",
|
||||
"interface": "10.211.55.3",
|
||||
"metric": "271"
|
||||
},
|
||||
{
|
||||
"network_destination": "127.0.0.0",
|
||||
"netmask": "255.0.0.0",
|
||||
"gateway": "On-link",
|
||||
"interface": "127.0.0.1",
|
||||
"metric": "331"
|
||||
},
|
||||
{
|
||||
"network_destination": "127.0.0.1",
|
||||
"netmask": "255.255.255.255",
|
||||
"gateway": "On-link",
|
||||
"interface": "127.0.0.1",
|
||||
"metric": "331"
|
||||
},
|
||||
{
|
||||
"network_destination": "127.255.255.255",
|
||||
"netmask": "255.255.255.255",
|
||||
"gateway": "On-link",
|
||||
"interface": "127.0.0.1",
|
||||
"metric": "331"
|
||||
},
|
||||
{
|
||||
"network_destination": "169.254.0.0",
|
||||
"netmask": "255.255.0.0",
|
||||
"gateway": "On-link",
|
||||
"interface": "169.254.83.107",
|
||||
"metric": "261"
|
||||
},
|
||||
{
|
||||
"network_destination": "169.254.83.107",
|
||||
"netmask": "255.255.255.255",
|
||||
"gateway": "On-link",
|
||||
"interface": "169.254.83.107",
|
||||
"metric": "261"
|
||||
},
|
||||
{
|
||||
"network_destination": "169.254.255.255",
|
||||
"netmask": "255.255.255.255",
|
||||
"gateway": "On-link",
|
||||
"interface": "169.254.83.107",
|
||||
"metric": "261"
|
||||
},
|
||||
{
|
||||
"network_destination": "224.0.0.0",
|
||||
"netmask": "240.0.0.0",
|
||||
"gateway": "On-link",
|
||||
"interface": "127.0.0.1",
|
||||
"metric": "331"
|
||||
},
|
||||
{
|
||||
"network_destination": "224.0.0.0",
|
||||
"netmask": "240.0.0.0",
|
||||
"gateway": "On-link",
|
||||
"interface": "10.211.55.3",
|
||||
"metric": "271"
|
||||
},
|
||||
{
|
||||
"network_destination": "255.255.255.255",
|
||||
"netmask": "255.255.255.255",
|
||||
"gateway": "On-link",
|
||||
"interface": "127.0.0.1",
|
||||
"metric": "331"
|
||||
"metric": 16,
|
||||
"metric_set_to_default": false
|
||||
},
|
||||
...
|
||||
{
|
||||
"network_destination": "255.255.255.255",
|
||||
"netmask": "255.255.255.255",
|
||||
"gateway": "On-link",
|
||||
"interface": "10.211.55.3",
|
||||
"metric": "271"
|
||||
"metric": null,
|
||||
"metric_set_to_default": true
|
||||
}
|
||||
],
|
||||
"persistent_routes": [
|
||||
@@ -219,100 +116,58 @@ Examples:
|
||||
"network_address": "10.0.1.0",
|
||||
"netmask": "255.255.255.0",
|
||||
"gateway_address": "192.168.22.1",
|
||||
"metric": "1"
|
||||
"metric": 1,
|
||||
"metric_set_to_default": false
|
||||
},
|
||||
{
|
||||
"network_address": "10.0.3.0",
|
||||
"netmask": "255.255.255.0",
|
||||
"gateway_address": "192.168.22.1",
|
||||
"metric": "1"
|
||||
"metric": 1,
|
||||
"metric_set_to_default": false
|
||||
},
|
||||
{
|
||||
"network_address": "10.0.4.0",
|
||||
"netmask": "255.255.255.0",
|
||||
"gateway_address": "192.168.22.1",
|
||||
"metric": "1"
|
||||
},
|
||||
{
|
||||
"network_address": "10.0.0.0",
|
||||
"netmask": "255.0.0.0",
|
||||
"gateway_address": "192.168.22.1",
|
||||
"metric": "1"
|
||||
}
|
||||
...
|
||||
]
|
||||
},
|
||||
"ipv6_route_table": {
|
||||
"active_routes": [
|
||||
{
|
||||
"interface": 1,
|
||||
"metric": "331",
|
||||
"metric": 331,
|
||||
"network_destination": "::1/128",
|
||||
"gateway": "On-link"
|
||||
"gateway": "On-link",
|
||||
"metric_set_to_default": false
|
||||
},
|
||||
{
|
||||
"interface": 12,
|
||||
"metric": "271",
|
||||
"metric": 271,
|
||||
"network_destination": "2001:db8::/64",
|
||||
"gateway": "fe80::1"
|
||||
"gateway": "fe80::1",
|
||||
"metric_set_to_default": false
|
||||
},
|
||||
...
|
||||
{
|
||||
"interface": 12,
|
||||
"metric": "271",
|
||||
"network_destination": "fdb2:2c26:f4e4::/64",
|
||||
"gateway": "On-link"
|
||||
},
|
||||
{
|
||||
"interface": 12,
|
||||
"metric": "271",
|
||||
"network_destination": "fdb2:2c26:f4e4:0:670f:fec7:75b7:eb83/128",
|
||||
"gateway": "On-link"
|
||||
},
|
||||
{
|
||||
"interface": 12,
|
||||
"metric": "271",
|
||||
"network_destination": "fdb2:2c26:f4e4:0:b4d5:8083:6ce6:37d/128",
|
||||
"gateway": "On-link"
|
||||
},
|
||||
{
|
||||
"interface": 12,
|
||||
"metric": "271",
|
||||
"network_destination": "fe80::/64",
|
||||
"gateway": "On-link"
|
||||
},
|
||||
{
|
||||
"interface": 12,
|
||||
"metric": "271",
|
||||
"network_destination": "fe80::4abd:fa70:3d36:83fd/128",
|
||||
"gateway": "On-link"
|
||||
},
|
||||
{
|
||||
"interface": 1,
|
||||
"metric": "331",
|
||||
"metric": 271,
|
||||
"network_destination": "ff00::/8",
|
||||
"gateway": "On-link"
|
||||
},
|
||||
{
|
||||
"interface": 12,
|
||||
"metric": "271",
|
||||
"network_destination": "ff00::/8",
|
||||
"gateway": "On-link"
|
||||
"gateway": "On-link",
|
||||
"metric_set_to_default": false
|
||||
}
|
||||
],
|
||||
"persistent_routes": [
|
||||
{
|
||||
"interface": 0,
|
||||
"metric": "4294967295",
|
||||
"metric": 4294967295,
|
||||
"network_destination": "2001:db8::/64",
|
||||
"gateway": "fe80::1"
|
||||
"gateway": "fe80::1",
|
||||
"metric_set_to_default": false
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
import re
|
||||
import jc.utils
|
||||
from jc.exceptions import ParseError
|
||||
|
||||
|
||||
class info():
|
||||
@@ -321,7 +176,7 @@ class info():
|
||||
description = '`route-print` command parser'
|
||||
author = 'joehacksalot'
|
||||
author_email = 'joehacksalot@gmail.com'
|
||||
compatible = ['windows']
|
||||
compatible = ['win32']
|
||||
magic_commands = ['route print']
|
||||
tags = ['command']
|
||||
|
||||
@@ -348,13 +203,24 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
raw_output = {}
|
||||
if jc.utils.has_data(data):
|
||||
try:
|
||||
raw_output = _parse(data)
|
||||
raw_data = {
|
||||
"interface_list": [],
|
||||
"ipv4_route_table": {
|
||||
"active_routes": [],
|
||||
"persistent_routes": []
|
||||
},
|
||||
"ipv6_route_table": {
|
||||
"active_routes": [],
|
||||
"persistent_routes": []
|
||||
}
|
||||
}
|
||||
|
||||
lines = data.splitlines()
|
||||
_parse_interface_list(raw_data, _PushbackIterator(iter(lines)))
|
||||
_parse_ipv4_route_table(raw_data, _PushbackIterator(iter(lines)))
|
||||
_parse_ipv6_route_table(raw_data, _PushbackIterator(iter(lines)))
|
||||
raw_output = raw_data
|
||||
return raw_output if raw else _process(raw_output)
|
||||
except Exception as e:
|
||||
if not quiet:
|
||||
raise ParseError('Could not parse data due to unexpected format.')
|
||||
return {}
|
||||
|
||||
def _process(proc_data):
|
||||
"""
|
||||
@@ -368,18 +234,56 @@ def _process(proc_data):
|
||||
|
||||
Processed Dictionary. Structured data to conform to the schema.
|
||||
"""
|
||||
if not proc_data:
|
||||
return {}
|
||||
|
||||
for interface in proc_data['interface_list']:
|
||||
if interface["mac_address"] == '' or interface["mac_address"] == '00 00 00 00 00 00 00 e0': # Placeholder MAC address for virtual adapters
|
||||
mac_address = None
|
||||
else:
|
||||
mac_address = interface["mac_address"].replace(" ", ":")
|
||||
|
||||
interface["mac_address"] = mac_address
|
||||
interface["interface_index"] = int(interface["interface_index"],0) # allow failure to convert to int exception to flow upwards
|
||||
|
||||
interface["interface_index"] = jc.utils.convert_to_int(interface["interface_index"])
|
||||
|
||||
for ipv4_active_route in proc_data['ipv4_route_table']['active_routes']:
|
||||
if ipv4_active_route["metric"] != "Default":
|
||||
ipv4_active_route["metric"] = jc.utils.convert_to_int(ipv4_active_route["metric"])
|
||||
ipv4_active_route["metric_set_to_default"] = False
|
||||
else:
|
||||
ipv4_active_route["metric"] = None
|
||||
ipv4_active_route["metric_set_to_default"] = True
|
||||
|
||||
for ipv4_persistent_route in proc_data['ipv4_route_table']['persistent_routes']:
|
||||
if ipv4_persistent_route["metric"] != "Default":
|
||||
ipv4_persistent_route["metric"] = jc.utils.convert_to_int(ipv4_persistent_route["metric"])
|
||||
ipv4_persistent_route["metric_set_to_default"] = False
|
||||
else:
|
||||
ipv4_persistent_route["metric"] = None
|
||||
ipv4_persistent_route["metric_set_to_default"] = True
|
||||
|
||||
for ipv6_active_route in proc_data['ipv6_route_table']['active_routes']:
|
||||
ipv6_active_route["interface"] = int(ipv6_active_route["interface"],0)
|
||||
ipv6_active_route["interface"] = jc.utils.convert_to_int(ipv6_active_route["interface"])
|
||||
|
||||
if ipv6_active_route["metric"] != "Default":
|
||||
ipv6_active_route["metric"] = jc.utils.convert_to_int(ipv6_active_route["metric"])
|
||||
ipv6_active_route["metric_set_to_default"] = False
|
||||
else:
|
||||
ipv6_active_route["metric"] = None
|
||||
ipv6_active_route["metric_set_to_default"] = True
|
||||
|
||||
for ipv6_persistent_route in proc_data['ipv6_route_table']['persistent_routes']:
|
||||
ipv6_persistent_route["interface"] = int(ipv6_persistent_route["interface"],0)
|
||||
return proc_data # No further processing is needed
|
||||
ipv6_persistent_route["interface"] = jc.utils.convert_to_int(ipv6_persistent_route["interface"])
|
||||
|
||||
if ipv6_persistent_route["metric"] != "Default":
|
||||
ipv6_persistent_route["metric"] = jc.utils.convert_to_int(ipv6_persistent_route["metric"])
|
||||
ipv6_persistent_route["metric_set_to_default"] = False
|
||||
else:
|
||||
ipv6_persistent_route["metric"] = None
|
||||
ipv6_persistent_route["metric_set_to_default"] = True
|
||||
|
||||
return proc_data
|
||||
|
||||
|
||||
class _PushbackIterator:
|
||||
@@ -543,24 +447,3 @@ def _parse_ipv6_route_table(data, lines_iter):
|
||||
line = next(lines_iter, '') # Skip the separator line
|
||||
_parse_ipv6_active_routes(data, lines_iter)
|
||||
_parse_ipv6_persistent_routes(data, lines_iter)
|
||||
|
||||
|
||||
def _parse(output):
|
||||
data = {
|
||||
"interface_list": [],
|
||||
"ipv4_route_table": {
|
||||
"active_routes": [],
|
||||
"persistent_routes": []
|
||||
},
|
||||
"ipv6_route_table": {
|
||||
"active_routes": [],
|
||||
"persistent_routes": []
|
||||
}
|
||||
}
|
||||
|
||||
lines = output.splitlines()
|
||||
_parse_interface_list(data, _PushbackIterator(iter(lines)))
|
||||
_parse_ipv4_route_table(data, _PushbackIterator(iter(lines)))
|
||||
_parse_ipv6_route_table(data, _PushbackIterator(iter(lines)))
|
||||
|
||||
return data
|
||||
|
242
tests/fixtures/windows/windows-10/route_print.json
vendored
242
tests/fixtures/windows/windows-10/route_print.json
vendored
@@ -1,241 +1 @@
|
||||
{
|
||||
"interface_list": [
|
||||
{
|
||||
"interface_index": 28,
|
||||
"mac_address": null,
|
||||
"description": "Tailscale Tunnel"
|
||||
},
|
||||
{
|
||||
"interface_index": 12,
|
||||
"mac_address": "00:1c:42:da:01:6a",
|
||||
"description": "Parallels VirtIO Ethernet Adapter"
|
||||
},
|
||||
{
|
||||
"interface_index": 1,
|
||||
"mac_address": null,
|
||||
"description": "Software Loopback Interface 1"
|
||||
}
|
||||
],
|
||||
"ipv4_route_table": {
|
||||
"active_routes": [
|
||||
{
|
||||
"network_destination": "0.0.0.0",
|
||||
"netmask": "0.0.0.0",
|
||||
"gateway": "10.211.55.1",
|
||||
"interface": "10.211.55.3",
|
||||
"metric": "15"
|
||||
},
|
||||
{
|
||||
"network_destination": "10.0.0.0",
|
||||
"netmask": "255.0.0.0",
|
||||
"gateway": "192.168.22.1",
|
||||
"interface": "10.211.55.3",
|
||||
"metric": "16"
|
||||
},
|
||||
{
|
||||
"network_destination": "10.0.1.0",
|
||||
"netmask": "255.255.255.0",
|
||||
"gateway": "192.168.22.1",
|
||||
"interface": "10.211.55.3",
|
||||
"metric": "16"
|
||||
},
|
||||
{
|
||||
"network_destination": "10.0.3.0",
|
||||
"netmask": "255.255.255.0",
|
||||
"gateway": "192.168.22.1",
|
||||
"interface": "10.211.55.3",
|
||||
"metric": "16"
|
||||
},
|
||||
{
|
||||
"network_destination": "10.0.4.0",
|
||||
"netmask": "255.255.255.0",
|
||||
"gateway": "192.168.22.1",
|
||||
"interface": "10.211.55.3",
|
||||
"metric": "16"
|
||||
},
|
||||
{
|
||||
"network_destination": "10.211.55.0",
|
||||
"netmask": "255.255.255.0",
|
||||
"gateway": "On-link",
|
||||
"interface": "10.211.55.3",
|
||||
"metric": "271"
|
||||
},
|
||||
{
|
||||
"network_destination": "10.211.55.3",
|
||||
"netmask": "255.255.255.255",
|
||||
"gateway": "On-link",
|
||||
"interface": "10.211.55.3",
|
||||
"metric": "271"
|
||||
},
|
||||
{
|
||||
"network_destination": "10.211.55.255",
|
||||
"netmask": "255.255.255.255",
|
||||
"gateway": "On-link",
|
||||
"interface": "10.211.55.3",
|
||||
"metric": "271"
|
||||
},
|
||||
{
|
||||
"network_destination": "127.0.0.0",
|
||||
"netmask": "255.0.0.0",
|
||||
"gateway": "On-link",
|
||||
"interface": "127.0.0.1",
|
||||
"metric": "331"
|
||||
},
|
||||
{
|
||||
"network_destination": "127.0.0.1",
|
||||
"netmask": "255.255.255.255",
|
||||
"gateway": "On-link",
|
||||
"interface": "127.0.0.1",
|
||||
"metric": "331"
|
||||
},
|
||||
{
|
||||
"network_destination": "127.255.255.255",
|
||||
"netmask": "255.255.255.255",
|
||||
"gateway": "On-link",
|
||||
"interface": "127.0.0.1",
|
||||
"metric": "331"
|
||||
},
|
||||
{
|
||||
"network_destination": "169.254.0.0",
|
||||
"netmask": "255.255.0.0",
|
||||
"gateway": "On-link",
|
||||
"interface": "169.254.83.107",
|
||||
"metric": "261"
|
||||
},
|
||||
{
|
||||
"network_destination": "169.254.83.107",
|
||||
"netmask": "255.255.255.255",
|
||||
"gateway": "On-link",
|
||||
"interface": "169.254.83.107",
|
||||
"metric": "261"
|
||||
},
|
||||
{
|
||||
"network_destination": "169.254.255.255",
|
||||
"netmask": "255.255.255.255",
|
||||
"gateway": "On-link",
|
||||
"interface": "169.254.83.107",
|
||||
"metric": "261"
|
||||
},
|
||||
{
|
||||
"network_destination": "224.0.0.0",
|
||||
"netmask": "240.0.0.0",
|
||||
"gateway": "On-link",
|
||||
"interface": "127.0.0.1",
|
||||
"metric": "331"
|
||||
},
|
||||
{
|
||||
"network_destination": "224.0.0.0",
|
||||
"netmask": "240.0.0.0",
|
||||
"gateway": "On-link",
|
||||
"interface": "10.211.55.3",
|
||||
"metric": "271"
|
||||
},
|
||||
{
|
||||
"network_destination": "255.255.255.255",
|
||||
"netmask": "255.255.255.255",
|
||||
"gateway": "On-link",
|
||||
"interface": "127.0.0.1",
|
||||
"metric": "331"
|
||||
},
|
||||
{
|
||||
"network_destination": "255.255.255.255",
|
||||
"netmask": "255.255.255.255",
|
||||
"gateway": "On-link",
|
||||
"interface": "10.211.55.3",
|
||||
"metric": "271"
|
||||
}
|
||||
],
|
||||
"persistent_routes": [
|
||||
{
|
||||
"network_address": "10.0.1.0",
|
||||
"netmask": "255.255.255.0",
|
||||
"gateway_address": "192.168.22.1",
|
||||
"metric": "1"
|
||||
},
|
||||
{
|
||||
"network_address": "10.0.3.0",
|
||||
"netmask": "255.255.255.0",
|
||||
"gateway_address": "192.168.22.1",
|
||||
"metric": "1"
|
||||
},
|
||||
{
|
||||
"network_address": "10.0.4.0",
|
||||
"netmask": "255.255.255.0",
|
||||
"gateway_address": "192.168.22.1",
|
||||
"metric": "1"
|
||||
},
|
||||
{
|
||||
"network_address": "10.0.0.0",
|
||||
"netmask": "255.0.0.0",
|
||||
"gateway_address": "192.168.22.1",
|
||||
"metric": "1"
|
||||
}
|
||||
]
|
||||
},
|
||||
"ipv6_route_table": {
|
||||
"active_routes": [
|
||||
{
|
||||
"interface": 1,
|
||||
"metric": "331",
|
||||
"network_destination": "::1/128",
|
||||
"gateway": "On-link"
|
||||
},
|
||||
{
|
||||
"interface": 12,
|
||||
"metric": "271",
|
||||
"network_destination": "2001:db8::/64",
|
||||
"gateway": "fe80::1"
|
||||
},
|
||||
{
|
||||
"interface": 12,
|
||||
"metric": "271",
|
||||
"network_destination": "fdb2:2c26:f4e4::/64",
|
||||
"gateway": "On-link"
|
||||
},
|
||||
{
|
||||
"interface": 12,
|
||||
"metric": "271",
|
||||
"network_destination": "fdb2:2c26:f4e4:0:670f:fec7:75b7:eb83/128",
|
||||
"gateway": "On-link"
|
||||
},
|
||||
{
|
||||
"interface": 12,
|
||||
"metric": "271",
|
||||
"network_destination": "fdb2:2c26:f4e4:0:b4d5:8083:6ce6:37d/128",
|
||||
"gateway": "On-link"
|
||||
},
|
||||
{
|
||||
"interface": 12,
|
||||
"metric": "271",
|
||||
"network_destination": "fe80::/64",
|
||||
"gateway": "On-link"
|
||||
},
|
||||
{
|
||||
"interface": 12,
|
||||
"metric": "271",
|
||||
"network_destination": "fe80::4abd:fa70:3d36:83fd/128",
|
||||
"gateway": "On-link"
|
||||
},
|
||||
{
|
||||
"interface": 1,
|
||||
"metric": "331",
|
||||
"network_destination": "ff00::/8",
|
||||
"gateway": "On-link"
|
||||
},
|
||||
{
|
||||
"interface": 12,
|
||||
"metric": "271",
|
||||
"network_destination": "ff00::/8",
|
||||
"gateway": "On-link"
|
||||
}
|
||||
],
|
||||
"persistent_routes": [
|
||||
{
|
||||
"interface": 0,
|
||||
"metric": "4294967295",
|
||||
"network_destination": "2001:db8::/64",
|
||||
"gateway": "fe80::1"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
{"interface_list":[{"interface_index":28,"mac_address":null,"description":"Tailscale Tunnel"},{"interface_index":12,"mac_address":"00:1c:42:da:01:6a","description":"Parallels VirtIO Ethernet Adapter"},{"interface_index":1,"mac_address":null,"description":"Software Loopback Interface 1"}],"ipv4_route_table":{"active_routes":[{"network_destination":"0.0.0.0","netmask":"0.0.0.0","gateway":"10.211.55.1","interface":"10.211.55.3","metric":15,"metric_set_to_default":false},{"network_destination":"10.0.0.0","netmask":"255.0.0.0","gateway":"192.168.22.1","interface":"10.211.55.3","metric":16,"metric_set_to_default":false},{"network_destination":"10.0.1.0","netmask":"255.255.255.0","gateway":"192.168.22.1","interface":"10.211.55.3","metric":16,"metric_set_to_default":false},{"network_destination":"10.0.3.0","netmask":"255.255.255.0","gateway":"192.168.22.1","interface":"10.211.55.3","metric":16,"metric_set_to_default":false},{"network_destination":"10.0.4.0","netmask":"255.255.255.0","gateway":"192.168.22.1","interface":"10.211.55.3","metric":16,"metric_set_to_default":false},{"network_destination":"10.211.55.0","netmask":"255.255.255.0","gateway":"On-link","interface":"10.211.55.3","metric":271,"metric_set_to_default":false},{"network_destination":"10.211.55.3","netmask":"255.255.255.255","gateway":"On-link","interface":"10.211.55.3","metric":271,"metric_set_to_default":false},{"network_destination":"10.211.55.255","netmask":"255.255.255.255","gateway":"On-link","interface":"10.211.55.3","metric":271,"metric_set_to_default":false},{"network_destination":"127.0.0.0","netmask":"255.0.0.0","gateway":"On-link","interface":"127.0.0.1","metric":331,"metric_set_to_default":false},{"network_destination":"127.0.0.1","netmask":"255.255.255.255","gateway":"On-link","interface":"127.0.0.1","metric":331,"metric_set_to_default":false},{"network_destination":"127.255.255.255","netmask":"255.255.255.255","gateway":"On-link","interface":"127.0.0.1","metric":331,"metric_set_to_default":false},{"network_destination":"169.254.0.0","netmask":"255.255.0.0","gateway":"On-link","interface":"169.254.83.107","metric":261,"metric_set_to_default":false},{"network_destination":"169.254.83.107","netmask":"255.255.255.255","gateway":"On-link","interface":"169.254.83.107","metric":261,"metric_set_to_default":false},{"network_destination":"169.254.255.255","netmask":"255.255.255.255","gateway":"On-link","interface":"169.254.83.107","metric":261,"metric_set_to_default":false},{"network_destination":"224.0.0.0","netmask":"240.0.0.0","gateway":"On-link","interface":"127.0.0.1","metric":331,"metric_set_to_default":false},{"network_destination":"224.0.0.0","netmask":"240.0.0.0","gateway":"On-link","interface":"10.211.55.3","metric":271,"metric_set_to_default":false},{"network_destination":"255.255.255.255","netmask":"255.255.255.255","gateway":"On-link","interface":"127.0.0.1","metric":331,"metric_set_to_default":false},{"network_destination":"255.255.255.255","netmask":"255.255.255.255","gateway":"On-link","interface":"10.211.55.3","metric":null,"metric_set_to_default":true}],"persistent_routes":[{"network_address":"10.0.1.0","netmask":"255.255.255.0","gateway_address":"192.168.22.1","metric":1,"metric_set_to_default":false},{"network_address":"10.0.3.0","netmask":"255.255.255.0","gateway_address":"192.168.22.1","metric":1,"metric_set_to_default":false},{"network_address":"10.0.4.0","netmask":"255.255.255.0","gateway_address":"192.168.22.1","metric":1,"metric_set_to_default":false},{"network_address":"10.0.0.0","netmask":"255.0.0.0","gateway_address":"192.168.22.1","metric":1,"metric_set_to_default":false}]},"ipv6_route_table":{"active_routes":[{"interface":1,"metric":331,"network_destination":"::1/128","gateway":"On-link","metric_set_to_default":false},{"interface":12,"metric":271,"network_destination":"2001:db8::/64","gateway":"fe80::1","metric_set_to_default":false},{"interface":12,"metric":271,"network_destination":"fdb2:2c26:f4e4::/64","gateway":"On-link","metric_set_to_default":false},{"interface":12,"metric":271,"network_destination":"fdb2:2c26:f4e4:0:670f:fec7:75b7:eb83/128","gateway":"On-link","metric_set_to_default":false},{"interface":12,"metric":271,"network_destination":"fdb2:2c26:f4e4:0:b4d5:8083:6ce6:37d/128","gateway":"On-link","metric_set_to_default":false},{"interface":12,"metric":271,"network_destination":"fe80::/64","gateway":"On-link","metric_set_to_default":false},{"interface":12,"metric":271,"network_destination":"fe80::4abd:fa70:3d36:83fd/128","gateway":"On-link","metric_set_to_default":false},{"interface":1,"metric":331,"network_destination":"ff00::/8","gateway":"On-link","metric_set_to_default":false},{"interface":12,"metric":271,"network_destination":"ff00::/8","gateway":"On-link","metric_set_to_default":false}],"persistent_routes":[{"interface":0,"metric":4294967295,"network_destination":"2001:db8::/64","gateway":"fe80::1","metric_set_to_default":false}]}}
|
||||
|
@@ -26,7 +26,7 @@ Network Destination Netmask Gateway Interface Metric
|
||||
224.0.0.0 240.0.0.0 On-link 127.0.0.1 331
|
||||
224.0.0.0 240.0.0.0 On-link 10.211.55.3 271
|
||||
255.255.255.255 255.255.255.255 On-link 127.0.0.1 331
|
||||
255.255.255.255 255.255.255.255 On-link 10.211.55.3 271
|
||||
255.255.255.255 255.255.255.255 On-link 10.211.55.3 Default
|
||||
===========================================================================
|
||||
Persistent Routes:
|
||||
Network Address Netmask Gateway Address Metric
|
||||
|
313
tests/fixtures/windows/windows-11/route_print.json
vendored
313
tests/fixtures/windows/windows-11/route_print.json
vendored
File diff suppressed because one or more lines are too long
144
tests/fixtures/windows/windows-2008/route_print.json
vendored
144
tests/fixtures/windows/windows-2008/route_print.json
vendored
@@ -1,143 +1 @@
|
||||
{
|
||||
"interface_list": [
|
||||
{
|
||||
"interface_index": 11,
|
||||
"mac_address": "00:0c:29:76:c8:d0",
|
||||
"description": "Intel(R) PRO/1000 MT Network Connection"
|
||||
},
|
||||
{
|
||||
"interface_index": 1,
|
||||
"mac_address": null,
|
||||
"description": "Software Loopback Interface 1"
|
||||
},
|
||||
{
|
||||
"interface_index": 12,
|
||||
"mac_address": null,
|
||||
"description": "Microsoft ISATAP Adapter"
|
||||
}
|
||||
],
|
||||
"ipv4_route_table": {
|
||||
"active_routes": [
|
||||
{
|
||||
"network_destination": "0.0.0.0",
|
||||
"netmask": "0.0.0.0",
|
||||
"gateway": "192.168.23.1",
|
||||
"interface": "192.168.23.154",
|
||||
"metric": "266"
|
||||
},
|
||||
{
|
||||
"network_destination": "127.0.0.0",
|
||||
"netmask": "255.0.0.0",
|
||||
"gateway": "On-link",
|
||||
"interface": "127.0.0.1",
|
||||
"metric": "306"
|
||||
},
|
||||
{
|
||||
"network_destination": "127.0.0.1",
|
||||
"netmask": "255.255.255.255",
|
||||
"gateway": "On-link",
|
||||
"interface": "127.0.0.1",
|
||||
"metric": "306"
|
||||
},
|
||||
{
|
||||
"network_destination": "127.255.255.255",
|
||||
"netmask": "255.255.255.255",
|
||||
"gateway": "On-link",
|
||||
"interface": "127.0.0.1",
|
||||
"metric": "306"
|
||||
},
|
||||
{
|
||||
"network_destination": "192.168.23.0",
|
||||
"netmask": "255.255.255.0",
|
||||
"gateway": "On-link",
|
||||
"interface": "192.168.23.154",
|
||||
"metric": "266"
|
||||
},
|
||||
{
|
||||
"network_destination": "192.168.23.154",
|
||||
"netmask": "255.255.255.255",
|
||||
"gateway": "On-link",
|
||||
"interface": "192.168.23.154",
|
||||
"metric": "266"
|
||||
},
|
||||
{
|
||||
"network_destination": "192.168.23.255",
|
||||
"netmask": "255.255.255.255",
|
||||
"gateway": "On-link",
|
||||
"interface": "192.168.23.154",
|
||||
"metric": "266"
|
||||
},
|
||||
{
|
||||
"network_destination": "224.0.0.0",
|
||||
"netmask": "240.0.0.0",
|
||||
"gateway": "On-link",
|
||||
"interface": "127.0.0.1",
|
||||
"metric": "306"
|
||||
},
|
||||
{
|
||||
"network_destination": "224.0.0.0",
|
||||
"netmask": "240.0.0.0",
|
||||
"gateway": "On-link",
|
||||
"interface": "192.168.23.154",
|
||||
"metric": "266"
|
||||
},
|
||||
{
|
||||
"network_destination": "255.255.255.255",
|
||||
"netmask": "255.255.255.255",
|
||||
"gateway": "On-link",
|
||||
"interface": "127.0.0.1",
|
||||
"metric": "306"
|
||||
},
|
||||
{
|
||||
"network_destination": "255.255.255.255",
|
||||
"netmask": "255.255.255.255",
|
||||
"gateway": "On-link",
|
||||
"interface": "192.168.23.154",
|
||||
"metric": "266"
|
||||
}
|
||||
],
|
||||
"persistent_routes": [
|
||||
{
|
||||
"network_address": "0.0.0.0",
|
||||
"netmask": "0.0.0.0",
|
||||
"gateway_address": "192.168.23.1",
|
||||
"metric": "Default"
|
||||
}
|
||||
]
|
||||
},
|
||||
"ipv6_route_table": {
|
||||
"active_routes": [
|
||||
{
|
||||
"interface": 1,
|
||||
"metric": "306",
|
||||
"network_destination": "::1/128",
|
||||
"gateway": "On-link"
|
||||
},
|
||||
{
|
||||
"interface": 11,
|
||||
"metric": "266",
|
||||
"network_destination": "fe80::/64",
|
||||
"gateway": "On-link"
|
||||
},
|
||||
{
|
||||
"interface": 11,
|
||||
"metric": "266",
|
||||
"network_destination": "fe80::9595:e8d9:b190:ecac/128",
|
||||
"gateway": "On-link"
|
||||
},
|
||||
{
|
||||
"interface": 1,
|
||||
"metric": "306",
|
||||
"network_destination": "ff00::/8",
|
||||
"gateway": "On-link"
|
||||
},
|
||||
{
|
||||
"interface": 11,
|
||||
"metric": "266",
|
||||
"network_destination": "ff00::/8",
|
||||
"gateway": "On-link"
|
||||
}
|
||||
],
|
||||
"persistent_routes": []
|
||||
}
|
||||
}
|
||||
{"interface_list":[{"interface_index":11,"mac_address":"00:0c:29:76:c8:d0","description":"Intel(R) PRO/1000 MT Network Connection"},{"interface_index":1,"mac_address":null,"description":"Software Loopback Interface 1"},{"interface_index":12,"mac_address":null,"description":"Microsoft ISATAP Adapter"}],"ipv4_route_table":{"active_routes":[{"network_destination":"0.0.0.0","netmask":"0.0.0.0","gateway":"192.168.23.1","interface":"192.168.23.154","metric":266,"metric_set_to_default":false},{"network_destination":"127.0.0.0","netmask":"255.0.0.0","gateway":"On-link","interface":"127.0.0.1","metric":306,"metric_set_to_default":false},{"network_destination":"127.0.0.1","netmask":"255.255.255.255","gateway":"On-link","interface":"127.0.0.1","metric":306,"metric_set_to_default":false},{"network_destination":"127.255.255.255","netmask":"255.255.255.255","gateway":"On-link","interface":"127.0.0.1","metric":306,"metric_set_to_default":false},{"network_destination":"192.168.23.0","netmask":"255.255.255.0","gateway":"On-link","interface":"192.168.23.154","metric":266,"metric_set_to_default":false},{"network_destination":"192.168.23.154","netmask":"255.255.255.255","gateway":"On-link","interface":"192.168.23.154","metric":266,"metric_set_to_default":false},{"network_destination":"192.168.23.255","netmask":"255.255.255.255","gateway":"On-link","interface":"192.168.23.154","metric":266,"metric_set_to_default":false},{"network_destination":"224.0.0.0","netmask":"240.0.0.0","gateway":"On-link","interface":"127.0.0.1","metric":306,"metric_set_to_default":false},{"network_destination":"224.0.0.0","netmask":"240.0.0.0","gateway":"On-link","interface":"192.168.23.154","metric":266,"metric_set_to_default":false},{"network_destination":"255.255.255.255","netmask":"255.255.255.255","gateway":"On-link","interface":"127.0.0.1","metric":306,"metric_set_to_default":false},{"network_destination":"255.255.255.255","netmask":"255.255.255.255","gateway":"On-link","interface":"192.168.23.154","metric":266,"metric_set_to_default":false}],"persistent_routes":[{"network_address":"0.0.0.0","netmask":"0.0.0.0","gateway_address":"192.168.23.1","metric":null,"metric_set_to_default":true}]},"ipv6_route_table":{"active_routes":[{"interface":1,"metric":306,"network_destination":"::1/128","gateway":"On-link","metric_set_to_default":false},{"interface":11,"metric":266,"network_destination":"fe80::/64","gateway":"On-link","metric_set_to_default":false},{"interface":11,"metric":266,"network_destination":"fe80::9595:e8d9:b190:ecac/128","gateway":"On-link","metric_set_to_default":false},{"interface":1,"metric":306,"network_destination":"ff00::/8","gateway":"On-link","metric_set_to_default":false},{"interface":11,"metric":266,"network_destination":"ff00::/8","gateway":"On-link","metric_set_to_default":false}],"persistent_routes":[]}}
|
||||
|
144
tests/fixtures/windows/windows-2016/route_print.json
vendored
144
tests/fixtures/windows/windows-2016/route_print.json
vendored
@@ -1,143 +1 @@
|
||||
{
|
||||
"interface_list": [
|
||||
{
|
||||
"interface_index": 2,
|
||||
"mac_address": "00:0c:29:a1:38:2c",
|
||||
"description": "Intel(R) 82574L Gigabit Network Connection"
|
||||
},
|
||||
{
|
||||
"interface_index": 1,
|
||||
"mac_address": null,
|
||||
"description": "Software Loopback Interface 1"
|
||||
},
|
||||
{
|
||||
"interface_index": 6,
|
||||
"mac_address": null,
|
||||
"description": "Microsoft ISATAP Adapter #2"
|
||||
}
|
||||
],
|
||||
"ipv4_route_table": {
|
||||
"active_routes": [
|
||||
{
|
||||
"network_destination": "0.0.0.0",
|
||||
"netmask": "0.0.0.0",
|
||||
"gateway": "192.168.22.1",
|
||||
"interface": "192.168.22.153",
|
||||
"metric": "281"
|
||||
},
|
||||
{
|
||||
"network_destination": "127.0.0.0",
|
||||
"netmask": "255.0.0.0",
|
||||
"gateway": "On-link",
|
||||
"interface": "127.0.0.1",
|
||||
"metric": "331"
|
||||
},
|
||||
{
|
||||
"network_destination": "127.0.0.1",
|
||||
"netmask": "255.255.255.255",
|
||||
"gateway": "On-link",
|
||||
"interface": "127.0.0.1",
|
||||
"metric": "331"
|
||||
},
|
||||
{
|
||||
"network_destination": "127.255.255.255",
|
||||
"netmask": "255.255.255.255",
|
||||
"gateway": "On-link",
|
||||
"interface": "127.0.0.1",
|
||||
"metric": "331"
|
||||
},
|
||||
{
|
||||
"network_destination": "192.168.22.0",
|
||||
"netmask": "255.255.255.0",
|
||||
"gateway": "On-link",
|
||||
"interface": "192.168.22.153",
|
||||
"metric": "281"
|
||||
},
|
||||
{
|
||||
"network_destination": "192.168.22.153",
|
||||
"netmask": "255.255.255.255",
|
||||
"gateway": "On-link",
|
||||
"interface": "192.168.22.153",
|
||||
"metric": "281"
|
||||
},
|
||||
{
|
||||
"network_destination": "192.168.22.255",
|
||||
"netmask": "255.255.255.255",
|
||||
"gateway": "On-link",
|
||||
"interface": "192.168.22.153",
|
||||
"metric": "281"
|
||||
},
|
||||
{
|
||||
"network_destination": "224.0.0.0",
|
||||
"netmask": "240.0.0.0",
|
||||
"gateway": "On-link",
|
||||
"interface": "127.0.0.1",
|
||||
"metric": "331"
|
||||
},
|
||||
{
|
||||
"network_destination": "224.0.0.0",
|
||||
"netmask": "240.0.0.0",
|
||||
"gateway": "On-link",
|
||||
"interface": "192.168.22.153",
|
||||
"metric": "281"
|
||||
},
|
||||
{
|
||||
"network_destination": "255.255.255.255",
|
||||
"netmask": "255.255.255.255",
|
||||
"gateway": "On-link",
|
||||
"interface": "127.0.0.1",
|
||||
"metric": "331"
|
||||
},
|
||||
{
|
||||
"network_destination": "255.255.255.255",
|
||||
"netmask": "255.255.255.255",
|
||||
"gateway": "On-link",
|
||||
"interface": "192.168.22.153",
|
||||
"metric": "281"
|
||||
}
|
||||
],
|
||||
"persistent_routes": [
|
||||
{
|
||||
"network_address": "0.0.0.0",
|
||||
"netmask": "0.0.0.0",
|
||||
"gateway_address": "192.168.22.1",
|
||||
"metric": "Default"
|
||||
}
|
||||
]
|
||||
},
|
||||
"ipv6_route_table": {
|
||||
"active_routes": [
|
||||
{
|
||||
"interface": 1,
|
||||
"metric": "331",
|
||||
"network_destination": "::1/128",
|
||||
"gateway": "On-link"
|
||||
},
|
||||
{
|
||||
"interface": 2,
|
||||
"metric": "281",
|
||||
"network_destination": "fe80::/64",
|
||||
"gateway": "On-link"
|
||||
},
|
||||
{
|
||||
"interface": 2,
|
||||
"metric": "281",
|
||||
"network_destination": "fe80::40c:2f5f:6658:9dc3/128",
|
||||
"gateway": "On-link"
|
||||
},
|
||||
{
|
||||
"interface": 1,
|
||||
"metric": "331",
|
||||
"network_destination": "ff00::/8",
|
||||
"gateway": "On-link"
|
||||
},
|
||||
{
|
||||
"interface": 2,
|
||||
"metric": "281",
|
||||
"network_destination": "ff00::/8",
|
||||
"gateway": "On-link"
|
||||
}
|
||||
],
|
||||
"persistent_routes": []
|
||||
}
|
||||
}
|
||||
{"interface_list":[{"interface_index":2,"mac_address":"00:0c:29:a1:38:2c","description":"Intel(R) 82574L Gigabit Network Connection"},{"interface_index":1,"mac_address":null,"description":"Software Loopback Interface 1"},{"interface_index":6,"mac_address":null,"description":"Microsoft ISATAP Adapter #2"}],"ipv4_route_table":{"active_routes":[{"network_destination":"0.0.0.0","netmask":"0.0.0.0","gateway":"192.168.22.1","interface":"192.168.22.153","metric":281,"metric_set_to_default":false},{"network_destination":"127.0.0.0","netmask":"255.0.0.0","gateway":"On-link","interface":"127.0.0.1","metric":331,"metric_set_to_default":false},{"network_destination":"127.0.0.1","netmask":"255.255.255.255","gateway":"On-link","interface":"127.0.0.1","metric":331,"metric_set_to_default":false},{"network_destination":"127.255.255.255","netmask":"255.255.255.255","gateway":"On-link","interface":"127.0.0.1","metric":331,"metric_set_to_default":false},{"network_destination":"192.168.22.0","netmask":"255.255.255.0","gateway":"On-link","interface":"192.168.22.153","metric":281,"metric_set_to_default":false},{"network_destination":"192.168.22.153","netmask":"255.255.255.255","gateway":"On-link","interface":"192.168.22.153","metric":281,"metric_set_to_default":false},{"network_destination":"192.168.22.255","netmask":"255.255.255.255","gateway":"On-link","interface":"192.168.22.153","metric":281,"metric_set_to_default":false},{"network_destination":"224.0.0.0","netmask":"240.0.0.0","gateway":"On-link","interface":"127.0.0.1","metric":331,"metric_set_to_default":false},{"network_destination":"224.0.0.0","netmask":"240.0.0.0","gateway":"On-link","interface":"192.168.22.153","metric":281,"metric_set_to_default":false},{"network_destination":"255.255.255.255","netmask":"255.255.255.255","gateway":"On-link","interface":"127.0.0.1","metric":331,"metric_set_to_default":false},{"network_destination":"255.255.255.255","netmask":"255.255.255.255","gateway":"On-link","interface":"192.168.22.153","metric":281,"metric_set_to_default":false}],"persistent_routes":[{"network_address":"0.0.0.0","netmask":"0.0.0.0","gateway_address":"192.168.22.1","metric":null,"metric_set_to_default":true}]},"ipv6_route_table":{"active_routes":[{"interface":1,"metric":331,"network_destination":"::1/128","gateway":"On-link","metric_set_to_default":false},{"interface":2,"metric":281,"network_destination":"fe80::/64","gateway":"On-link","metric_set_to_default":false},{"interface":2,"metric":281,"network_destination":"fe80::40c:2f5f:6658:9dc3/128","gateway":"On-link","metric_set_to_default":false},{"interface":1,"metric":331,"network_destination":"ff00::/8","gateway":"On-link","metric_set_to_default":false},{"interface":2,"metric":281,"network_destination":"ff00::/8","gateway":"On-link","metric_set_to_default":false}],"persistent_routes":[]}}
|
||||
|
137
tests/fixtures/windows/windows-7/route_print.json
vendored
137
tests/fixtures/windows/windows-7/route_print.json
vendored
@@ -1,136 +1 @@
|
||||
{
|
||||
"interface_list": [
|
||||
{
|
||||
"interface_index": 10,
|
||||
"mac_address": "00:0c:29:86:1e:1f",
|
||||
"description": "Intel(R) PRO/1000 MT Network Connection"
|
||||
},
|
||||
{
|
||||
"interface_index": 1,
|
||||
"mac_address": null,
|
||||
"description": "Software Loopback Interface 1"
|
||||
},
|
||||
{
|
||||
"interface_index": 11,
|
||||
"mac_address": null,
|
||||
"description": "Microsoft ISATAP Adapter"
|
||||
}
|
||||
],
|
||||
"ipv4_route_table": {
|
||||
"active_routes": [
|
||||
{
|
||||
"network_destination": "0.0.0.0",
|
||||
"netmask": "0.0.0.0",
|
||||
"gateway": "192.168.22.1",
|
||||
"interface": "192.168.22.33",
|
||||
"metric": "10"
|
||||
},
|
||||
{
|
||||
"network_destination": "127.0.0.0",
|
||||
"netmask": "255.0.0.0",
|
||||
"gateway": "On-link",
|
||||
"interface": "127.0.0.1",
|
||||
"metric": "306"
|
||||
},
|
||||
{
|
||||
"network_destination": "127.0.0.1",
|
||||
"netmask": "255.255.255.255",
|
||||
"gateway": "On-link",
|
||||
"interface": "127.0.0.1",
|
||||
"metric": "306"
|
||||
},
|
||||
{
|
||||
"network_destination": "127.255.255.255",
|
||||
"netmask": "255.255.255.255",
|
||||
"gateway": "On-link",
|
||||
"interface": "127.0.0.1",
|
||||
"metric": "306"
|
||||
},
|
||||
{
|
||||
"network_destination": "192.168.22.0",
|
||||
"netmask": "255.255.255.0",
|
||||
"gateway": "On-link",
|
||||
"interface": "192.168.22.33",
|
||||
"metric": "266"
|
||||
},
|
||||
{
|
||||
"network_destination": "192.168.22.33",
|
||||
"netmask": "255.255.255.255",
|
||||
"gateway": "On-link",
|
||||
"interface": "192.168.22.33",
|
||||
"metric": "266"
|
||||
},
|
||||
{
|
||||
"network_destination": "192.168.22.255",
|
||||
"netmask": "255.255.255.255",
|
||||
"gateway": "On-link",
|
||||
"interface": "192.168.22.33",
|
||||
"metric": "266"
|
||||
},
|
||||
{
|
||||
"network_destination": "224.0.0.0",
|
||||
"netmask": "240.0.0.0",
|
||||
"gateway": "On-link",
|
||||
"interface": "127.0.0.1",
|
||||
"metric": "306"
|
||||
},
|
||||
{
|
||||
"network_destination": "224.0.0.0",
|
||||
"netmask": "240.0.0.0",
|
||||
"gateway": "On-link",
|
||||
"interface": "192.168.22.33",
|
||||
"metric": "266"
|
||||
},
|
||||
{
|
||||
"network_destination": "255.255.255.255",
|
||||
"netmask": "255.255.255.255",
|
||||
"gateway": "On-link",
|
||||
"interface": "127.0.0.1",
|
||||
"metric": "306"
|
||||
},
|
||||
{
|
||||
"network_destination": "255.255.255.255",
|
||||
"netmask": "255.255.255.255",
|
||||
"gateway": "On-link",
|
||||
"interface": "192.168.22.33",
|
||||
"metric": "266"
|
||||
}
|
||||
],
|
||||
"persistent_routes": []
|
||||
},
|
||||
"ipv6_route_table": {
|
||||
"active_routes": [
|
||||
{
|
||||
"interface": 1,
|
||||
"metric": "306",
|
||||
"network_destination": "::1/128",
|
||||
"gateway": "On-link"
|
||||
},
|
||||
{
|
||||
"interface": 10,
|
||||
"metric": "266",
|
||||
"network_destination": "fe80::/64",
|
||||
"gateway": "On-link"
|
||||
},
|
||||
{
|
||||
"interface": 10,
|
||||
"metric": "266",
|
||||
"network_destination": "fe80::c447:d1ef:c29f:c48c/128",
|
||||
"gateway": "On-link"
|
||||
},
|
||||
{
|
||||
"interface": 1,
|
||||
"metric": "306",
|
||||
"network_destination": "ff00::/8",
|
||||
"gateway": "On-link"
|
||||
},
|
||||
{
|
||||
"interface": 10,
|
||||
"metric": "266",
|
||||
"network_destination": "ff00::/8",
|
||||
"gateway": "On-link"
|
||||
}
|
||||
],
|
||||
"persistent_routes": []
|
||||
}
|
||||
}
|
||||
{"interface_list":[{"interface_index":10,"mac_address":"00:0c:29:86:1e:1f","description":"Intel(R) PRO/1000 MT Network Connection"},{"interface_index":1,"mac_address":null,"description":"Software Loopback Interface 1"},{"interface_index":11,"mac_address":null,"description":"Microsoft ISATAP Adapter"}],"ipv4_route_table":{"active_routes":[{"network_destination":"0.0.0.0","netmask":"0.0.0.0","gateway":"192.168.22.1","interface":"192.168.22.33","metric":10,"metric_set_to_default":false},{"network_destination":"127.0.0.0","netmask":"255.0.0.0","gateway":"On-link","interface":"127.0.0.1","metric":306,"metric_set_to_default":false},{"network_destination":"127.0.0.1","netmask":"255.255.255.255","gateway":"On-link","interface":"127.0.0.1","metric":306,"metric_set_to_default":false},{"network_destination":"127.255.255.255","netmask":"255.255.255.255","gateway":"On-link","interface":"127.0.0.1","metric":306,"metric_set_to_default":false},{"network_destination":"192.168.22.0","netmask":"255.255.255.0","gateway":"On-link","interface":"192.168.22.33","metric":266,"metric_set_to_default":false},{"network_destination":"192.168.22.33","netmask":"255.255.255.255","gateway":"On-link","interface":"192.168.22.33","metric":266,"metric_set_to_default":false},{"network_destination":"192.168.22.255","netmask":"255.255.255.255","gateway":"On-link","interface":"192.168.22.33","metric":266,"metric_set_to_default":false},{"network_destination":"224.0.0.0","netmask":"240.0.0.0","gateway":"On-link","interface":"127.0.0.1","metric":306,"metric_set_to_default":false},{"network_destination":"224.0.0.0","netmask":"240.0.0.0","gateway":"On-link","interface":"192.168.22.33","metric":266,"metric_set_to_default":false},{"network_destination":"255.255.255.255","netmask":"255.255.255.255","gateway":"On-link","interface":"127.0.0.1","metric":306,"metric_set_to_default":false},{"network_destination":"255.255.255.255","netmask":"255.255.255.255","gateway":"On-link","interface":"192.168.22.33","metric":266,"metric_set_to_default":false}],"persistent_routes":[]},"ipv6_route_table":{"active_routes":[{"interface":1,"metric":306,"network_destination":"::1/128","gateway":"On-link","metric_set_to_default":false},{"interface":10,"metric":266,"network_destination":"fe80::/64","gateway":"On-link","metric_set_to_default":false},{"interface":10,"metric":266,"network_destination":"fe80::c447:d1ef:c29f:c48c/128","gateway":"On-link","metric_set_to_default":false},{"interface":1,"metric":306,"network_destination":"ff00::/8","gateway":"On-link","metric_set_to_default":false},{"interface":10,"metric":266,"network_destination":"ff00::/8","gateway":"On-link","metric_set_to_default":false}],"persistent_routes":[]}}
|
||||
|
@@ -1,86 +1 @@
|
||||
{
|
||||
"interface_list": [
|
||||
{
|
||||
"interface_index": 1,
|
||||
"mac_address": null,
|
||||
"description": ". MS TCP Loopback interface"
|
||||
},
|
||||
{
|
||||
"interface_index": 2,
|
||||
"mac_address": "00:0c:29:21:f9:3e",
|
||||
"description": ". Intel(R) PRO/1000 MT Network Connection - Packet Scheduler Miniport"
|
||||
}
|
||||
],
|
||||
"ipv4_route_table": {
|
||||
"active_routes": [
|
||||
{
|
||||
"network_destination": "0.0.0.0",
|
||||
"netmask": "0.0.0.0",
|
||||
"gateway": "192.168.22.1",
|
||||
"interface": "192.168.22.135",
|
||||
"metric": "10"
|
||||
},
|
||||
{
|
||||
"network_destination": "10.0.4.0",
|
||||
"netmask": "255.255.255.0",
|
||||
"gateway": "192.168.22.1",
|
||||
"interface": "192.168.22.135",
|
||||
"metric": "1"
|
||||
},
|
||||
{
|
||||
"network_destination": "127.0.0.0",
|
||||
"netmask": "255.0.0.0",
|
||||
"gateway": "127.0.0.1",
|
||||
"interface": "127.0.0.1",
|
||||
"metric": "1"
|
||||
},
|
||||
{
|
||||
"network_destination": "192.168.22.0",
|
||||
"netmask": "255.255.255.0",
|
||||
"gateway": "192.168.22.135",
|
||||
"interface": "192.168.22.135",
|
||||
"metric": "10"
|
||||
},
|
||||
{
|
||||
"network_destination": "192.168.22.135",
|
||||
"netmask": "255.255.255.255",
|
||||
"gateway": "127.0.0.1",
|
||||
"interface": "127.0.0.1",
|
||||
"metric": "10"
|
||||
},
|
||||
{
|
||||
"network_destination": "192.168.22.255",
|
||||
"netmask": "255.255.255.255",
|
||||
"gateway": "192.168.22.135",
|
||||
"interface": "192.168.22.135",
|
||||
"metric": "10"
|
||||
},
|
||||
{
|
||||
"network_destination": "224.0.0.0",
|
||||
"netmask": "240.0.0.0",
|
||||
"gateway": "192.168.22.135",
|
||||
"interface": "192.168.22.135",
|
||||
"metric": "10"
|
||||
},
|
||||
{
|
||||
"network_destination": "255.255.255.255",
|
||||
"netmask": "255.255.255.255",
|
||||
"gateway": "192.168.22.135",
|
||||
"interface": "192.168.22.135",
|
||||
"metric": "1"
|
||||
}
|
||||
],
|
||||
"persistent_routes": [
|
||||
{
|
||||
"network_address": "10.0.4.0",
|
||||
"netmask": "255.255.255.0",
|
||||
"gateway_address": "192.168.22.1",
|
||||
"metric": "1"
|
||||
}
|
||||
]
|
||||
},
|
||||
"ipv6_route_table": {
|
||||
"active_routes": [],
|
||||
"persistent_routes": []
|
||||
}
|
||||
}
|
||||
{"interface_list":[{"interface_index":1,"mac_address":null,"description":". MS TCP Loopback interface"},{"interface_index":2,"mac_address":"00:0c:29:21:f9:3e","description":". Intel(R) PRO/1000 MT Network Connection - Packet Scheduler Miniport"}],"ipv4_route_table":{"active_routes":[{"network_destination":"0.0.0.0","netmask":"0.0.0.0","gateway":"192.168.22.1","interface":"192.168.22.135","metric":10,"metric_set_to_default":false},{"network_destination":"10.0.4.0","netmask":"255.255.255.0","gateway":"192.168.22.1","interface":"192.168.22.135","metric":1,"metric_set_to_default":false},{"network_destination":"127.0.0.0","netmask":"255.0.0.0","gateway":"127.0.0.1","interface":"127.0.0.1","metric":1,"metric_set_to_default":false},{"network_destination":"192.168.22.0","netmask":"255.255.255.0","gateway":"192.168.22.135","interface":"192.168.22.135","metric":10,"metric_set_to_default":false},{"network_destination":"192.168.22.135","netmask":"255.255.255.255","gateway":"127.0.0.1","interface":"127.0.0.1","metric":10,"metric_set_to_default":false},{"network_destination":"192.168.22.255","netmask":"255.255.255.255","gateway":"192.168.22.135","interface":"192.168.22.135","metric":10,"metric_set_to_default":false},{"network_destination":"224.0.0.0","netmask":"240.0.0.0","gateway":"192.168.22.135","interface":"192.168.22.135","metric":10,"metric_set_to_default":false},{"network_destination":"255.255.255.255","netmask":"255.255.255.255","gateway":"192.168.22.135","interface":"192.168.22.135","metric":1,"metric_set_to_default":false}],"persistent_routes":[{"network_address":"10.0.4.0","netmask":"255.255.255.0","gateway_address":"192.168.22.1","metric":1,"metric_set_to_default":false}]},"ipv6_route_table":{"active_routes":[],"persistent_routes":[]}}
|
||||
|
@@ -1,50 +1,107 @@
|
||||
import json
|
||||
import os
|
||||
import unittest
|
||||
import jc.parsers.ipconfig
|
||||
import jc.parsers.net_localgroup
|
||||
import jc.parsers.route_print
|
||||
import json
|
||||
from typing import Dict
|
||||
from jc.parsers.route_print import parse
|
||||
|
||||
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
|
||||
class MyTests(unittest.TestCase):
|
||||
test_files = [
|
||||
"tests/fixtures/windows/windows-xp/route_print",
|
||||
"tests/fixtures/windows/windows-7/route_print",
|
||||
"tests/fixtures/windows/windows-2008/route_print",
|
||||
"tests/fixtures/windows/windows-2016/route_print",
|
||||
"tests/fixtures/windows/windows-10/route_print",
|
||||
"tests/fixtures/windows/windows-11/route_print"
|
||||
]
|
||||
f_in: Dict = {}
|
||||
f_json: Dict = {}
|
||||
|
||||
def setUp(self):
|
||||
for tf in MyTests.test_files:
|
||||
in_file = os.path.join(THIS_DIR, os.pardir, f"{tf}.out")
|
||||
out_file = os.path.join(THIS_DIR, os.pardir, f"{tf}.json")
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
fixtures = {
|
||||
'windows_xp_route_print': (
|
||||
'fixtures/windows/windows-xp/route_print.out',
|
||||
'fixtures/windows/windows-xp/route_print.json'),
|
||||
'windows_7_route_print': (
|
||||
'fixtures/windows/windows-7/route_print.out',
|
||||
'fixtures/windows/windows-7/route_print.json'),
|
||||
'windows_2008_route_print': (
|
||||
'fixtures/windows/windows-2008/route_print.out',
|
||||
'fixtures/windows/windows-2008/route_print.json'),
|
||||
'windows_2016_route_print': (
|
||||
'fixtures/windows/windows-2016/route_print.out',
|
||||
'fixtures/windows/windows-2016/route_print.json'),
|
||||
'windows_10_route_print': (
|
||||
'fixtures/windows/windows-10/route_print.out',
|
||||
'fixtures/windows/windows-10/route_print.json'),
|
||||
'windows_11_route_print': (
|
||||
'fixtures/windows/windows-11/route_print.out',
|
||||
'fixtures/windows/windows-11/route_print.json')
|
||||
}
|
||||
|
||||
with open(in_file, "r", encoding="utf-8") as f:
|
||||
setattr(self, self.varName(tf), f.read())
|
||||
with open(out_file, "r", encoding="utf-8") as f:
|
||||
setattr(self, self.varName(tf) + "_json", json.loads(f.read()))
|
||||
for file, filepaths in fixtures.items():
|
||||
with open(os.path.join(THIS_DIR, filepaths[0]), 'r', encoding='utf-8') as a, \
|
||||
open(os.path.join(THIS_DIR, filepaths[1]), 'r', encoding='utf-8') as b:
|
||||
cls.f_in[file] = a.read()
|
||||
cls.f_json[file] = json.loads(b.read())
|
||||
|
||||
def varName(self, path):
|
||||
return (
|
||||
path.replace("tests/fixtures/windows", "")
|
||||
.replace("-", "_")
|
||||
.replace("/", "_")
|
||||
|
||||
def test_route_print_nodata(self):
|
||||
"""
|
||||
Test 'route_print' with no data
|
||||
"""
|
||||
self.assertEqual(parse('', quiet=True), {})
|
||||
|
||||
|
||||
def test_route_print_windows_xp(self):
|
||||
"""
|
||||
Test 'route_print' on Windows XP
|
||||
"""
|
||||
self.assertEqual(
|
||||
parse(self.f_in['windows_xp_route_print'], quiet=True),
|
||||
self.f_json['windows_xp_route_print']
|
||||
)
|
||||
|
||||
def test_windows_route_print(self):
|
||||
def test_route_print_windows_7(self):
|
||||
"""
|
||||
Test a sample Windows "route print" command output
|
||||
Test 'route_print' on Windows 7
|
||||
"""
|
||||
for tf in MyTests.test_files:
|
||||
in_var = getattr(self, self.varName(tf))
|
||||
out_var = getattr(self, self.varName(tf) + "_json")
|
||||
self.assertEqual(
|
||||
parse(self.f_in['windows_7_route_print'], quiet=True),
|
||||
self.f_json['windows_7_route_print']
|
||||
)
|
||||
|
||||
self.assertEqual(jc.parsers.route_print.parse(in_var, quiet=True), out_var)
|
||||
def test_route_print_windows_2008(self):
|
||||
"""
|
||||
Test 'route_print' on Windows 2008
|
||||
"""
|
||||
self.assertEqual(
|
||||
parse(self.f_in['windows_2008_route_print'], quiet=True),
|
||||
self.f_json['windows_2008_route_print']
|
||||
)
|
||||
|
||||
def test_route_print_windows_2016(self):
|
||||
"""
|
||||
Test 'route_print' on Windows 2016
|
||||
"""
|
||||
self.assertEqual(
|
||||
parse(self.f_in['windows_2016_route_print'], quiet=True),
|
||||
self.f_json['windows_2016_route_print']
|
||||
)
|
||||
|
||||
def test_route_print_windows_10(self):
|
||||
"""
|
||||
Test 'route_print' on Windows 10
|
||||
"""
|
||||
self.assertEqual(
|
||||
parse(self.f_in['windows_10_route_print'], quiet=True),
|
||||
self.f_json['windows_10_route_print']
|
||||
)
|
||||
|
||||
def test_route_print_windows_11(self):
|
||||
"""
|
||||
Test 'route_print' on Windows 11
|
||||
"""
|
||||
self.assertEqual(
|
||||
parse(self.f_in['windows_11_route_print'], quiet=True),
|
||||
self.f_json['windows_11_route_print']
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
Reference in New Issue
Block a user