1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-17 00:07:37 +02:00

doc update

This commit is contained in:
Kelly Brazil
2024-10-18 14:30:04 -07:00
parent a2e0e6d549
commit 95672c23b7
9 changed files with 519 additions and 24 deletions

View File

@ -1,6 +1,7 @@
jc changelog jc changelog
20241018 v1.25.4 20241018 v1.25.4
- Add `ipconfig` command parser
- Enhance `ping-s` streaming parser to support error replies - Enhance `ping-s` streaming parser to support error replies
- Enhance `ethtool` parser to support `link_partner_advertised_link_modes` - Enhance `ethtool` parser to support `link_partner_advertised_link_modes`
- Enhance `ifconfig` parser to support `utun` interfaces with assigned IPv4 addresses on macOS - Enhance `ifconfig` parser to support `utun` interfaces with assigned IPv4 addresses on macOS

View File

@ -218,6 +218,7 @@ option.
| `--iostat` | `iostat` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/iostat) | | `--iostat` | `iostat` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/iostat) |
| `--iostat-s` | `iostat` command streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/iostat_s) | | `--iostat-s` | `iostat` command streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/iostat_s) |
| `--ip-address` | IPv4 and IPv6 Address string parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ip_address) | | `--ip-address` | IPv4 and IPv6 Address string parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ip_address) |
| `--ipconfig` | `ipconfig` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ipconfig) |
| `--iptables` | `iptables` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/iptables) | | `--iptables` | `iptables` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/iptables) |
| `--ip-route` | `ip route` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ip_route) | | `--ip-route` | `ip route` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ip_route) |
| `--iw-scan` | `iw dev [device] scan` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/iw_scan) | | `--iw-scan` | `iw dev [device] scan` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/iw_scan) |

View File

@ -3,8 +3,8 @@ _jc()
local cur prev words cword jc_commands jc_parsers jc_options \ local cur prev words cword jc_commands jc_parsers jc_options \
jc_about_options jc_about_mod_options jc_help_options jc_special_options jc_about_options jc_about_mod_options jc_help_options jc_special_options
jc_commands=(acpi airport apt-cache apt-get arp blkid bluetoothctl cbt certbot chage cksum crontab curl date debconf-show df dig dmidecode dpkg du efibootmgr env ethtool file findmnt finger free git gpg hciconfig host id ifconfig iostat ip iptables iw iwconfig jobs last lastb ls lsattr lsb_release lsblk lsmod lsof lspci lsusb md5 md5sum mdadm mount mpstat needrestart netstat nmcli nsd-control ntpq os-prober pidstat ping ping6 pip pip3 postconf printenv ps route rpm rsync sfdisk sha1sum sha224sum sha256sum sha384sum sha512sum shasum ss ssh sshd stat sum swapon sysctl systemctl systeminfo timedatectl top tracepath tracepath6 traceroute traceroute6 tune2fs udevadm ufw uname update-alternatives upower uptime vdir veracrypt vmstat w wc who xrandr zipinfo zpool) jc_commands=(acpi airport apt-cache apt-get arp blkid bluetoothctl cbt certbot chage cksum crontab curl date debconf-show df dig dmidecode dpkg du efibootmgr env ethtool file findmnt finger free git gpg hciconfig host id ifconfig iostat ip ipconfig iptables iw iwconfig jobs last lastb ls lsattr lsb_release lsblk lsmod lsof lspci lsusb md5 md5sum mdadm mount mpstat needrestart netstat nmcli nsd-control ntpq os-prober pidstat ping ping6 pip pip3 postconf printenv ps route rpm rsync sfdisk sha1sum sha224sum sha256sum sha384sum sha512sum shasum ss ssh sshd stat sum swapon sysctl systemctl systeminfo timedatectl top tracepath tracepath6 traceroute traceroute6 tune2fs udevadm ufw uname update-alternatives upower uptime vdir veracrypt vmstat w wc who xrandr zipinfo zpool)
jc_parsers=(--acpi --airport --airport-s --apt-cache-show --apt-get-sqq --arp --asciitable --asciitable-m --blkid --bluetoothctl --cbt --cef --cef-s --certbot --chage --cksum --clf --clf-s --crontab --crontab-u --csv --csv-s --curl-head --date --datetime-iso --debconf-show --df --dig --dir --dmidecode --dpkg-l --du --efibootmgr --email-address --env --ethtool --file --find --findmnt --finger --free --fstab --git-log --git-log-s --git-ls-remote --gpg --group --gshadow --hash --hashsum --hciconfig --history --host --hosts --http-headers --id --ifconfig --ini --ini-dup --iostat --iostat-s --ip-address --iptables --ip-route --iw-scan --iwconfig --jar-manifest --jobs --jwt --kv --kv-dup --last --ls --ls-s --lsattr --lsb-release --lsblk --lsmod --lsof --lspci --lsusb --m3u --mdadm --mount --mpstat --mpstat-s --needrestart --netstat --nmcli --nsd-control --ntpq --openvpn --os-prober --os-release --passwd --path --path-list --pci-ids --pgpass --pidstat --pidstat-s --ping --ping-s --pip-list --pip-show --pkg-index-apk --pkg-index-deb --plist --postconf --proc --proc-buddyinfo --proc-cmdline --proc-consoles --proc-cpuinfo --proc-crypto --proc-devices --proc-diskstats --proc-filesystems --proc-interrupts --proc-iomem --proc-ioports --proc-loadavg --proc-locks --proc-meminfo --proc-modules --proc-mtrr --proc-pagetypeinfo --proc-partitions --proc-slabinfo --proc-softirqs --proc-stat --proc-swaps --proc-uptime --proc-version --proc-vmallocinfo --proc-vmstat --proc-zoneinfo --proc-driver-rtc --proc-net-arp --proc-net-dev --proc-net-dev-mcast --proc-net-if-inet6 --proc-net-igmp --proc-net-igmp6 --proc-net-ipv6-route --proc-net-netlink --proc-net-netstat --proc-net-packet --proc-net-protocols --proc-net-route --proc-net-tcp --proc-net-unix --proc-pid-fdinfo --proc-pid-io --proc-pid-maps --proc-pid-mountinfo --proc-pid-numa-maps --proc-pid-smaps --proc-pid-stat --proc-pid-statm --proc-pid-status --ps --resolve-conf --route --rpm-qi --rsync --rsync-s --semver --sfdisk --shadow --srt --ss --ssh-conf --sshd-conf --stat --stat-s --swapon --sysctl --syslog --syslog-s --syslog-bsd --syslog-bsd-s --systemctl --systemctl-lj --systemctl-ls --systemctl-luf --systeminfo --time --timedatectl --timestamp --toml --top --top-s --tracepath --traceroute --tune2fs --udevadm --ufw --ufw-appinfo --uname --update-alt-gs --update-alt-q --upower --uptime --url --ver --veracrypt --vmstat --vmstat-s --w --wc --who --x509-cert --x509-csr --xml --xrandr --yaml --zipinfo --zpool-iostat --zpool-status) jc_parsers=(--acpi --airport --airport-s --apt-cache-show --apt-get-sqq --arp --asciitable --asciitable-m --blkid --bluetoothctl --cbt --cef --cef-s --certbot --chage --cksum --clf --clf-s --crontab --crontab-u --csv --csv-s --curl-head --date --datetime-iso --debconf-show --df --dig --dir --dmidecode --dpkg-l --du --efibootmgr --email-address --env --ethtool --file --find --findmnt --finger --free --fstab --git-log --git-log-s --git-ls-remote --gpg --group --gshadow --hash --hashsum --hciconfig --history --host --hosts --http-headers --id --ifconfig --ini --ini-dup --iostat --iostat-s --ip-address --ipconfig --iptables --ip-route --iw-scan --iwconfig --jar-manifest --jobs --jwt --kv --kv-dup --last --ls --ls-s --lsattr --lsb-release --lsblk --lsmod --lsof --lspci --lsusb --m3u --mdadm --mount --mpstat --mpstat-s --needrestart --netstat --nmcli --nsd-control --ntpq --openvpn --os-prober --os-release --passwd --path --path-list --pci-ids --pgpass --pidstat --pidstat-s --ping --ping-s --pip-list --pip-show --pkg-index-apk --pkg-index-deb --plist --postconf --proc --proc-buddyinfo --proc-cmdline --proc-consoles --proc-cpuinfo --proc-crypto --proc-devices --proc-diskstats --proc-filesystems --proc-interrupts --proc-iomem --proc-ioports --proc-loadavg --proc-locks --proc-meminfo --proc-modules --proc-mtrr --proc-pagetypeinfo --proc-partitions --proc-slabinfo --proc-softirqs --proc-stat --proc-swaps --proc-uptime --proc-version --proc-vmallocinfo --proc-vmstat --proc-zoneinfo --proc-driver-rtc --proc-net-arp --proc-net-dev --proc-net-dev-mcast --proc-net-if-inet6 --proc-net-igmp --proc-net-igmp6 --proc-net-ipv6-route --proc-net-netlink --proc-net-netstat --proc-net-packet --proc-net-protocols --proc-net-route --proc-net-tcp --proc-net-unix --proc-pid-fdinfo --proc-pid-io --proc-pid-maps --proc-pid-mountinfo --proc-pid-numa-maps --proc-pid-smaps --proc-pid-stat --proc-pid-statm --proc-pid-status --ps --resolve-conf --route --rpm-qi --rsync --rsync-s --semver --sfdisk --shadow --srt --ss --ssh-conf --sshd-conf --stat --stat-s --swapon --sysctl --syslog --syslog-s --syslog-bsd --syslog-bsd-s --systemctl --systemctl-lj --systemctl-ls --systemctl-luf --systeminfo --time --timedatectl --timestamp --toml --top --top-s --tracepath --traceroute --tune2fs --udevadm --ufw --ufw-appinfo --uname --update-alt-gs --update-alt-q --upower --uptime --url --ver --veracrypt --vmstat --vmstat-s --w --wc --who --x509-cert --x509-csr --xml --xrandr --yaml --zipinfo --zpool-iostat --zpool-status)
jc_options=(--force-color -C --debug -d --monochrome -m --meta-out -M --pretty -p --quiet -q --raw -r --slurp -s --unbuffer -u --yaml-out -y) jc_options=(--force-color -C --debug -d --monochrome -m --meta-out -M --pretty -p --quiet -q --raw -r --slurp -s --unbuffer -u --yaml-out -y)
jc_about_options=(--about -a) jc_about_options=(--about -a)
jc_about_mod_options=(--pretty -p --yaml-out -y --monochrome -m --force-color -C) jc_about_mod_options=(--pretty -p --yaml-out -y --monochrome -m --force-color -C)

View File

@ -9,7 +9,7 @@ _jc() {
jc_help_options jc_help_options_describe \ jc_help_options jc_help_options_describe \
jc_special_options jc_special_options_describe jc_special_options jc_special_options_describe
jc_commands=(acpi airport apt-cache apt-get arp blkid bluetoothctl cbt certbot chage cksum crontab curl date debconf-show df dig dmidecode dpkg du efibootmgr env ethtool file findmnt finger free git gpg hciconfig host id ifconfig iostat ip iptables iw iwconfig jobs last lastb ls lsattr lsb_release lsblk lsmod lsof lspci lsusb md5 md5sum mdadm mount mpstat needrestart netstat nmcli nsd-control ntpq os-prober pidstat ping ping6 pip pip3 postconf printenv ps route rpm rsync sfdisk sha1sum sha224sum sha256sum sha384sum sha512sum shasum ss ssh sshd stat sum swapon sysctl systemctl systeminfo timedatectl top tracepath tracepath6 traceroute traceroute6 tune2fs udevadm ufw uname update-alternatives upower uptime vdir veracrypt vmstat w wc who xrandr zipinfo zpool) jc_commands=(acpi airport apt-cache apt-get arp blkid bluetoothctl cbt certbot chage cksum crontab curl date debconf-show df dig dmidecode dpkg du efibootmgr env ethtool file findmnt finger free git gpg hciconfig host id ifconfig iostat ip ipconfig iptables iw iwconfig jobs last lastb ls lsattr lsb_release lsblk lsmod lsof lspci lsusb md5 md5sum mdadm mount mpstat needrestart netstat nmcli nsd-control ntpq os-prober pidstat ping ping6 pip pip3 postconf printenv ps route rpm rsync sfdisk sha1sum sha224sum sha256sum sha384sum sha512sum shasum ss ssh sshd stat sum swapon sysctl systemctl systeminfo timedatectl top tracepath tracepath6 traceroute traceroute6 tune2fs udevadm ufw uname update-alternatives upower uptime vdir veracrypt vmstat w wc who xrandr zipinfo zpool)
jc_commands_describe=( jc_commands_describe=(
'acpi:run "acpi" command with magic syntax.' 'acpi:run "acpi" command with magic syntax.'
'airport:run "airport" command with magic syntax.' 'airport:run "airport" command with magic syntax.'
@ -46,6 +46,7 @@ _jc() {
'ifconfig:run "ifconfig" command with magic syntax.' 'ifconfig:run "ifconfig" command with magic syntax.'
'iostat:run "iostat" command with magic syntax.' 'iostat:run "iostat" command with magic syntax.'
'ip:run "ip" command with magic syntax.' 'ip:run "ip" command with magic syntax.'
'ipconfig:run "ipconfig" command with magic syntax.'
'iptables:run "iptables" command with magic syntax.' 'iptables:run "iptables" command with magic syntax.'
'iw:run "iw" command with magic syntax.' 'iw:run "iw" command with magic syntax.'
'iwconfig:run "iwconfig" command with magic syntax.' 'iwconfig:run "iwconfig" command with magic syntax.'
@ -121,7 +122,7 @@ _jc() {
'zipinfo:run "zipinfo" command with magic syntax.' 'zipinfo:run "zipinfo" command with magic syntax.'
'zpool:run "zpool" command with magic syntax.' 'zpool:run "zpool" command with magic syntax.'
) )
jc_parsers=(--acpi --airport --airport-s --apt-cache-show --apt-get-sqq --arp --asciitable --asciitable-m --blkid --bluetoothctl --cbt --cef --cef-s --certbot --chage --cksum --clf --clf-s --crontab --crontab-u --csv --csv-s --curl-head --date --datetime-iso --debconf-show --df --dig --dir --dmidecode --dpkg-l --du --efibootmgr --email-address --env --ethtool --file --find --findmnt --finger --free --fstab --git-log --git-log-s --git-ls-remote --gpg --group --gshadow --hash --hashsum --hciconfig --history --host --hosts --http-headers --id --ifconfig --ini --ini-dup --iostat --iostat-s --ip-address --iptables --ip-route --iw-scan --iwconfig --jar-manifest --jobs --jwt --kv --kv-dup --last --ls --ls-s --lsattr --lsb-release --lsblk --lsmod --lsof --lspci --lsusb --m3u --mdadm --mount --mpstat --mpstat-s --needrestart --netstat --nmcli --nsd-control --ntpq --openvpn --os-prober --os-release --passwd --path --path-list --pci-ids --pgpass --pidstat --pidstat-s --ping --ping-s --pip-list --pip-show --pkg-index-apk --pkg-index-deb --plist --postconf --proc --proc-buddyinfo --proc-cmdline --proc-consoles --proc-cpuinfo --proc-crypto --proc-devices --proc-diskstats --proc-filesystems --proc-interrupts --proc-iomem --proc-ioports --proc-loadavg --proc-locks --proc-meminfo --proc-modules --proc-mtrr --proc-pagetypeinfo --proc-partitions --proc-slabinfo --proc-softirqs --proc-stat --proc-swaps --proc-uptime --proc-version --proc-vmallocinfo --proc-vmstat --proc-zoneinfo --proc-driver-rtc --proc-net-arp --proc-net-dev --proc-net-dev-mcast --proc-net-if-inet6 --proc-net-igmp --proc-net-igmp6 --proc-net-ipv6-route --proc-net-netlink --proc-net-netstat --proc-net-packet --proc-net-protocols --proc-net-route --proc-net-tcp --proc-net-unix --proc-pid-fdinfo --proc-pid-io --proc-pid-maps --proc-pid-mountinfo --proc-pid-numa-maps --proc-pid-smaps --proc-pid-stat --proc-pid-statm --proc-pid-status --ps --resolve-conf --route --rpm-qi --rsync --rsync-s --semver --sfdisk --shadow --srt --ss --ssh-conf --sshd-conf --stat --stat-s --swapon --sysctl --syslog --syslog-s --syslog-bsd --syslog-bsd-s --systemctl --systemctl-lj --systemctl-ls --systemctl-luf --systeminfo --time --timedatectl --timestamp --toml --top --top-s --tracepath --traceroute --tune2fs --udevadm --ufw --ufw-appinfo --uname --update-alt-gs --update-alt-q --upower --uptime --url --ver --veracrypt --vmstat --vmstat-s --w --wc --who --x509-cert --x509-csr --xml --xrandr --yaml --zipinfo --zpool-iostat --zpool-status) jc_parsers=(--acpi --airport --airport-s --apt-cache-show --apt-get-sqq --arp --asciitable --asciitable-m --blkid --bluetoothctl --cbt --cef --cef-s --certbot --chage --cksum --clf --clf-s --crontab --crontab-u --csv --csv-s --curl-head --date --datetime-iso --debconf-show --df --dig --dir --dmidecode --dpkg-l --du --efibootmgr --email-address --env --ethtool --file --find --findmnt --finger --free --fstab --git-log --git-log-s --git-ls-remote --gpg --group --gshadow --hash --hashsum --hciconfig --history --host --hosts --http-headers --id --ifconfig --ini --ini-dup --iostat --iostat-s --ip-address --ipconfig --iptables --ip-route --iw-scan --iwconfig --jar-manifest --jobs --jwt --kv --kv-dup --last --ls --ls-s --lsattr --lsb-release --lsblk --lsmod --lsof --lspci --lsusb --m3u --mdadm --mount --mpstat --mpstat-s --needrestart --netstat --nmcli --nsd-control --ntpq --openvpn --os-prober --os-release --passwd --path --path-list --pci-ids --pgpass --pidstat --pidstat-s --ping --ping-s --pip-list --pip-show --pkg-index-apk --pkg-index-deb --plist --postconf --proc --proc-buddyinfo --proc-cmdline --proc-consoles --proc-cpuinfo --proc-crypto --proc-devices --proc-diskstats --proc-filesystems --proc-interrupts --proc-iomem --proc-ioports --proc-loadavg --proc-locks --proc-meminfo --proc-modules --proc-mtrr --proc-pagetypeinfo --proc-partitions --proc-slabinfo --proc-softirqs --proc-stat --proc-swaps --proc-uptime --proc-version --proc-vmallocinfo --proc-vmstat --proc-zoneinfo --proc-driver-rtc --proc-net-arp --proc-net-dev --proc-net-dev-mcast --proc-net-if-inet6 --proc-net-igmp --proc-net-igmp6 --proc-net-ipv6-route --proc-net-netlink --proc-net-netstat --proc-net-packet --proc-net-protocols --proc-net-route --proc-net-tcp --proc-net-unix --proc-pid-fdinfo --proc-pid-io --proc-pid-maps --proc-pid-mountinfo --proc-pid-numa-maps --proc-pid-smaps --proc-pid-stat --proc-pid-statm --proc-pid-status --ps --resolve-conf --route --rpm-qi --rsync --rsync-s --semver --sfdisk --shadow --srt --ss --ssh-conf --sshd-conf --stat --stat-s --swapon --sysctl --syslog --syslog-s --syslog-bsd --syslog-bsd-s --systemctl --systemctl-lj --systemctl-ls --systemctl-luf --systeminfo --time --timedatectl --timestamp --toml --top --top-s --tracepath --traceroute --tune2fs --udevadm --ufw --ufw-appinfo --uname --update-alt-gs --update-alt-q --upower --uptime --url --ver --veracrypt --vmstat --vmstat-s --w --wc --who --x509-cert --x509-csr --xml --xrandr --yaml --zipinfo --zpool-iostat --zpool-status)
jc_parsers_describe=( jc_parsers_describe=(
'--acpi:`acpi` command parser' '--acpi:`acpi` command parser'
'--airport:`airport -I` command parser' '--airport:`airport -I` command parser'
@ -185,6 +186,7 @@ _jc() {
'--iostat:`iostat` command parser' '--iostat:`iostat` command parser'
'--iostat-s:`iostat` command streaming parser' '--iostat-s:`iostat` command streaming parser'
'--ip-address:IPv4 and IPv6 Address string parser' '--ip-address:IPv4 and IPv6 Address string parser'
'--ipconfig:`ipconfig` command parser'
'--iptables:`iptables` command parser' '--iptables:`iptables` command parser'
'--ip-route:`ip route` command parser' '--ip-route:`ip route` command parser'
'--iw-scan:`iw dev [device] scan` command parser' '--iw-scan:`iw dev [device] scan` command parser'

View File

@ -33,6 +33,8 @@ a controller and a device but there might be fields corresponding to one entity.
Controller: Controller:
[ [
{ {
"manufacturer": string,
"version": string,
"name": string, "name": string,
"is_default": boolean, "is_default": boolean,
"is_public": boolean, "is_public": boolean,
@ -134,4 +136,4 @@ Compatibility: linux
Source: [`jc/parsers/bluetoothctl.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/bluetoothctl.py) Source: [`jc/parsers/bluetoothctl.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/bluetoothctl.py)
Version 1.2 by Jake Ob (iakopap at gmail.com) Version 1.3 by Jake Ob (iakopap at gmail.com)

458
docs/parsers/ipconfig.md Normal file
View File

@ -0,0 +1,458 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.ipconfig"></a>
# jc.parsers.ipconfig
jc - JSON Convert `ipconfig` command output parser
Usage (cli):
$ ipconfig /all | jc --ipconfig
$ ipconfig | jc --ipconfig
$ jc ipconfig /all
Usage (module):
import jc
result = jc.parse('ipconfig', ipconfig_command_output)
Schema:
{
"host_name": string,
"primary_dns_suffix": string,
"node_type": string,
"ip_routing_enabled": boolean,
"wins_proxy_enabled": boolean,
"dns_suffix_search_list": [
string
],
"adapters": [
{
"name_long": string,
"name": string,
"type": string,
"connection_specific_dns_suffix": string,
"connection_specific_dns_suffix_search_list": [
string
]
"description": string,
"physical_address": string,
"dhcp_enabled": boolean,
"autoconfiguration_enabled": boolean,
"ipv6_addresses": [
{
"address": string,
"status": string,
},
],
"temporary_ipv6_addresses": [
{
"address": string,
"status": string,
},
],
"link_local_ipv6_addresses": [
{
"address": string,
"status": string,
"prefix_length": int,
}
],
"ipv4_addresses": [
{
"address": string, # [2]
"subnet_mask": string,
"status": string,
"autoconfigured": boolean # [1]
}
],
"default_gateways": [
string
],
"dhcp_server": null,
"dhcpv6_iaid": string,
"dhcpv6_client_duid": string,
"dns_servers": [
string
],
"primary_wins_server": string,
"lease_expires": string, # [0]
"lease_obtained": string, # [0]
"netbios_over_tcpip": boolean,
"media_state": string,
"extras": [
string: string
]
}
],
"extras": []
}
Notes:
[0] - 'lease_expires' and 'lease_obtained' are parsed to ISO8601
format date strings. if the value was unable to be parsed by
datetime, the fields will be in their raw form
[1] - 'autoconfigured' under 'ipv4_address' is only providing
indication if the ipv4 address was labeled as "Autoconfiguration
IPv4 Address" vs "IPv4 Address". It does not infer any
information from other fields
[2] - Windows XP uses 'IP Address' instead of 'IPv4 Address'. Both
values are parsed to the 'ipv4_address' object for consistency
Examples:
$ ipconfig /all | jc --ipconfig -p
{
"host_name": "DESKTOP-WIN11-HOME",
"primary_dns_suffix": null,
"node_type": "Hybrid",
"ip_routing_enabled": false,
"wins_proxy_enabled": false,
"dns_suffix_search_list": [
"localdomain"
],
"adapters": [
{
"name_long": "Ethernet adapter Ethernet",
"name": "Ethernet",
"type": "Ethernet",
"connection_specific_dns_suffix": null,
"connection_specific_dns_suffix_search_list": [],
"description": "Intel(R) I211 Gigabit Network Connection",
"physical_address": "24-4B-FE-AB-43-C3",
"dhcp_enabled": true,
"autoconfiguration_enabled": true,
"ipv6_addresses": [],
"temporary_ipv6_addresses": [],
"link_local_ipv6_addresses": [],
"ipv4_addresses": [],
"default_gateways": [],
"dhcp_server": null,
"dhcpv6_iaid": null,
"dhcpv6_client_duid": null,
"dns_servers": [],
"primary_wins_server": null,
"lease_expires": null,
"lease_obtained": null,
"netbios_over_tcpip": null,
"media_state": "Media disconnected",
"extras": []
},
{
"name_long": "Ethernet adapter Ethernet 2",
"name": "Ethernet 2",
"type": "Ethernet",
"connection_specific_dns_suffix": null,
"connection_specific_dns_suffix_search_list": [],
"description": "Realtek PCIe 2.5GbE Family Controller",
"physical_address": "24-4B-FE-57-3D-F2",
"dhcp_enabled": true,
"autoconfiguration_enabled": true,
"ipv6_addresses": [],
"temporary_ipv6_addresses": [],
"link_local_ipv6_addresses": [],
"ipv4_addresses": [],
"default_gateways": [],
"dhcp_server": null,
"dhcpv6_iaid": null,
"dhcpv6_client_duid": null,
"dns_servers": [],
"primary_wins_server": null,
"lease_expires": null,
"lease_obtained": null,
"netbios_over_tcpip": null,
"media_state": "Media disconnected",
"extras": []
},
{
"name_long": "Unknown adapter OpenVPN Data Channel Offload for NordVPN",
"name": "OpenVPN Data Channel Offload for NordVPN",
"type": "Unknown",
"connection_specific_dns_suffix": null,
"connection_specific_dns_suffix_search_list": [],
"description": "OpenVPN Data Channel Offload",
"physical_address": null,
"dhcp_enabled": true,
"autoconfiguration_enabled": true,
"ipv6_addresses": [],
"temporary_ipv6_addresses": [],
"link_local_ipv6_addresses": [],
"ipv4_addresses": [],
"default_gateways": [],
"dhcp_server": null,
"dhcpv6_iaid": null,
"dhcpv6_client_duid": null,
"dns_servers": [],
"primary_wins_server": null,
"lease_expires": null,
"lease_obtained": null,
"netbios_over_tcpip": null,
"media_state": "Media disconnected",
"extras": []
},
{
"name_long": "Unknown adapter Local Area Connection",
"name": "Local Area Connection",
"type": "Unknown",
"connection_specific_dns_suffix": null,
"connection_specific_dns_suffix_search_list": [],
"description": "TAP-NordVPN Windows Adapter V9",
"physical_address": "00-FF-4C-F4-5E-49",
"dhcp_enabled": true,
"autoconfiguration_enabled": true,
"ipv6_addresses": [],
"temporary_ipv6_addresses": [],
"link_local_ipv6_addresses": [],
"ipv4_addresses": [],
"default_gateways": [],
"dhcp_server": null,
"dhcpv6_iaid": null,
"dhcpv6_client_duid": null,
"dns_servers": [],
"primary_wins_server": null,
"lease_expires": null,
"lease_obtained": null,
"netbios_over_tcpip": null,
"media_state": "Media disconnected",
"extras": []
},
{
"name_long": "Wireless LAN adapter Local Area Connection* 1",
"name": "Local Area Connection* 1",
"type": "Wireless LAN",
"connection_specific_dns_suffix": null,
"connection_specific_dns_suffix_search_list": [],
"description": "Microsoft Wi-Fi Direct Virtual Adapter",
"physical_address": "A8-7E-EA-5A-7F-DE",
"dhcp_enabled": true,
"autoconfiguration_enabled": true,
"ipv6_addresses": [],
"temporary_ipv6_addresses": [],
"link_local_ipv6_addresses": [],
"ipv4_addresses": [],
"default_gateways": [],
"dhcp_server": null,
"dhcpv6_iaid": null,
"dhcpv6_client_duid": null,
"dns_servers": [],
"primary_wins_server": null,
"lease_expires": null,
"lease_obtained": null,
"netbios_over_tcpip": null,
"media_state": "Media disconnected",
"extras": []
},
{
"name_long": "Wireless LAN adapter Local Area Connection* 2",
"name": "Local Area Connection* 2",
"type": "Wireless LAN",
"connection_specific_dns_suffix": null,
"connection_specific_dns_suffix_search_list": [],
"description": "Microsoft Wi-Fi Direct Virtual Adapter #2",
"physical_address": "AA-7E-EA-F3-64-C3",
"dhcp_enabled": true,
"autoconfiguration_enabled": true,
"ipv6_addresses": [],
"temporary_ipv6_addresses": [],
"link_local_ipv6_addresses": [],
"ipv4_addresses": [],
"default_gateways": [],
"dhcp_server": null,
"dhcpv6_iaid": null,
"dhcpv6_client_duid": null,
"dns_servers": [],
"primary_wins_server": null,
"lease_expires": null,
"lease_obtained": null,
"netbios_over_tcpip": null,
"media_state": "Media disconnected",
"extras": []
},
{
"name_long": "Ethernet adapter VMware Network Adapter VMnet1",
"name": "VMware Network Adapter VMnet1",
"type": "Ethernet",
"connection_specific_dns_suffix": null,
"connection_specific_dns_suffix_search_list": [],
"description": "VMware Virtual Ethernet Adapter for VMnet1",
"physical_address": "00-50-56-CC-27-73",
"dhcp_enabled": true,
"autoconfiguration_enabled": true,
"ipv6_addresses": [],
"temporary_ipv6_addresses": [],
"link_local_ipv6_addresses": [
{
"address": "fe80::f47d:9c7f:69dc:591e",
"prefix_length": 8,
"status": "Preferred"
}
],
"ipv4_addresses": [
{
"address": "192.168.181.1",
"subnet_mask": "255.255.255.0",
"status": "Preferred",
"autoconfigured": false
}
],
"default_gateways": [],
"dhcp_server": "192.168.181.254",
"dhcpv6_iaid": "771772502",
"dhcpv6_client_duid": "00-01-00-01-2C-CF-19-EB-24-4B-FE-5B-9B-E6",
"dns_servers": [],
"primary_wins_server": null,
"lease_expires": "2024-09-19T18:01:29",
"lease_obtained": "2024-09-19T08:31:29",
"netbios_over_tcpip": true,
"media_state": null,
"extras": []
},
{
"name_long": "Ethernet adapter VMware Network Adapter VMnet8",
"name": "VMware Network Adapter VMnet8",
"type": "Ethernet",
"connection_specific_dns_suffix": null,
"connection_specific_dns_suffix_search_list": [],
"description": "VMware Virtual Ethernet Adapter for VMnet8",
"physical_address": "00-50-56-C9-A3-78",
"dhcp_enabled": true,
"autoconfiguration_enabled": true,
"ipv6_addresses": [],
"temporary_ipv6_addresses": [],
"link_local_ipv6_addresses": [
{
"address": "fe80::4551:bf0d:59dd:a4f0",
"prefix_length": 10,
"status": "Preferred"
}
],
"ipv4_addresses": [
{
"address": "192.168.213.1",
"subnet_mask": "255.255.255.0",
"status": "Preferred",
"autoconfigured": false
}
],
"default_gateways": [],
"dhcp_server": "192.168.213.254",
"dhcpv6_iaid": "788549718",
"dhcpv6_client_duid": "00-01-00-01-2C-CF-19-EB-24-4B-FE-5B-9B-E6",
"dns_servers": [],
"primary_wins_server": "192.168.213.2",
"lease_expires": "2024-09-19T18:01:29",
"lease_obtained": "2024-09-19T08:31:29",
"netbios_over_tcpip": true,
"media_state": null,
"extras": []
},
{
"name_long": "Wireless LAN adapter Wi-Fi",
"name": "Wi-Fi",
"type": "Wireless LAN",
"connection_specific_dns_suffix": "localdomain",
"connection_specific_dns_suffix_search_list": [],
"description": "Intel(R) Wi-Fi 6 AX200 160MHz",
"physical_address": "A8-7E-EA-55-26-B0",
"dhcp_enabled": true,
"autoconfiguration_enabled": true,
"ipv6_addresses": [
{
"address": "fd63:cc9c:65eb:3f95:57c2:aa:10d8:db08",
"status": "Preferred"
}
],
"temporary_ipv6_addresses": [
{
"address": "fd63:cc9c:65eb:3f95:8928:348e:d692:b7ef",
"status": "Preferred"
}
],
"link_local_ipv6_addresses": [
{
"address": "fe80::4fae:1380:5a1b:8b6b",
"prefix_length": 11,
"status": "Preferred"
}
],
"ipv4_addresses": [
{
"address": "192.168.1.169",
"subnet_mask": "255.255.255.0",
"status": "Preferred",
"autoconfigured": false
}
],
"default_gateways": [
"192.168.1.1"
],
"dhcp_server": "192.168.1.1",
"dhcpv6_iaid": "162037482",
"dhcpv6_client_duid": "00-01-00-01-2C-CF-19-EB-24-4B-FE-5B-9B-E6",
"dns_servers": [
"192.168.1.1"
],
"primary_wins_server": null,
"lease_expires": "2024-09-20T08:31:30",
"lease_obtained": "2024-09-19T08:31:30",
"netbios_over_tcpip": true,
"media_state": null,
"extras": []
},
{
"name_long": "Ethernet adapter Bluetooth Network Connection",
"name": "Bluetooth Network Connection",
"type": "Ethernet",
"connection_specific_dns_suffix": null,
"connection_specific_dns_suffix_search_list": [],
"description": "Bluetooth Device (Personal Area Network)",
"physical_address": "A8-7E-EA-43-23-14",
"dhcp_enabled": true,
"autoconfiguration_enabled": true,
"ipv6_addresses": [],
"temporary_ipv6_addresses": [],
"link_local_ipv6_addresses": [],
"ipv4_addresses": [],
"default_gateways": [],
"dhcp_server": null,
"dhcpv6_iaid": null,
"dhcpv6_client_duid": null,
"dns_servers": [],
"primary_wins_server": null,
"lease_expires": null,
"lease_obtained": null,
"netbios_over_tcpip": null,
"media_state": "Media disconnected",
"extras": []
}
],
"extras": []
}
<a id="jc.parsers.ipconfig.parse"></a>
### parse
```python
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
Parsed dictionary. The raw and processed data structures are the same.
### Parser Information
Compatibility: windows
Source: [`jc/parsers/ipconfig.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/ipconfig.py)
Version 1.0 by joehacksalot (joehacksalot@gmail.com)

View File

@ -69,7 +69,8 @@ Parameters:
binary: (boolean) `True` to use binary multiples of bytes binary: (boolean) `True` to use binary multiples of bytes
(base-2) for ambiguous unit symbols and names, (base-2) for ambiguous unit symbols and names,
`False` to use decimal multiples of bytes (base-10). `False` to use decimal multiples of bytes (base-10).
posix_mode: Treat one-letter units (k, m, g, etc.) as binary. posix_mode: (boolean) Treat one-letter units (k, m, g, etc.) as
binary.
decimal_bias: (boolean) `True` to treat slightly ambiguous two- decimal_bias: (boolean) `True` to treat slightly ambiguous two-
letter unit symbols ending in "i" (e.g. Ki, Gi) to letter unit symbols ending in "i" (e.g. Ki, Gi) to
use decimal multiples of bytes (base-10). `False` use decimal multiples of bytes (base-10). `False`

View File

@ -1,10 +1,10 @@
r"""jc - JSON Convert `ipconfig` command output parser r"""jc - JSON Convert `ipconfig` command output parser
Usage (cli): Usage (cli):
$ ipconfig /all | jc --ipconfig $ ipconfig /all | jc --ipconfig
$ ipconfig | jc --ipconfig $ ipconfig | jc --ipconfig
$ jc ipconfig /all
Usage (module): Usage (module):
@ -85,12 +85,15 @@ Schema:
} }
Notes: Notes:
[0] - 'lease_expires' and 'lease_obtained' are parsed to ISO8601 format date strings. if the value was unable [0] - 'lease_expires' and 'lease_obtained' are parsed to ISO8601
to be parsed by datetime, the fields will be in their raw form format date strings. if the value was unable to be parsed by
[1] - 'autoconfigured' under 'ipv4_address' is only providing indication if the ipv4 address was labeled as datetime, the fields will be in their raw form
"Autoconfiguration IPv4 Address" vs "IPv4 Address". It does not infer any information from other fields [1] - 'autoconfigured' under 'ipv4_address' is only providing
[2] - Windows XP uses 'IP Address' instead of 'IPv4 Address'. Both values are parsed to the 'ipv4_address' indication if the ipv4 address was labeled as "Autoconfiguration
object for consistency IPv4 Address" vs "IPv4 Address". It does not infer any
information from other fields
[2] - Windows XP uses 'IP Address' instead of 'IPv4 Address'. Both
values are parsed to the 'ipv4_address' object for consistency
Examples: Examples:
@ -421,7 +424,6 @@ Examples:
], ],
"extras": [] "extras": []
} }
""" """
from datetime import datetime from datetime import datetime
import re import re
@ -466,6 +468,7 @@ def parse(data, raw=False, quiet=False):
return raw_output if raw else _process(raw_output) return raw_output if raw else _process(raw_output)
def _process_ipv6_address(ip_address): def _process_ipv6_address(ip_address):
address_split = ip_address["address"].split('%') address_split = ip_address["address"].split('%')
try: try:
@ -484,6 +487,7 @@ def _process_ipv6_address(ip_address):
"status": ip_address["status"] "status": ip_address["status"]
} }
def _process_ipv4_address(ip_address): def _process_ipv4_address(ip_address):
autoconfigured = True if ip_address.get("autoconfigured","") is not None and 'autoconfigured' in ip_address.get("autoconfigured","") else False autoconfigured = True if ip_address.get("autoconfigured","") is not None and 'autoconfigured' in ip_address.get("autoconfigured","") else False
subnet_mask = ip_address["subnet_mask"] subnet_mask = ip_address["subnet_mask"]
@ -494,6 +498,7 @@ def _process_ipv4_address(ip_address):
"autoconfigured": autoconfigured "autoconfigured": autoconfigured
} }
def _process(proc_data): def _process(proc_data):
""" """
Final processing to conform to the schema. Final processing to conform to the schema.
@ -508,7 +513,6 @@ def _process(proc_data):
""" """
processed = proc_data processed = proc_data
if "ip_routing_enabled" in processed and processed["ip_routing_enabled"] is not None: if "ip_routing_enabled" in processed and processed["ip_routing_enabled"] is not None:
processed["ip_routing_enabled"] = (processed["ip_routing_enabled"].lower() == "yes") processed["ip_routing_enabled"] = (processed["ip_routing_enabled"].lower() == "yes")
@ -518,38 +522,49 @@ def _process(proc_data):
for adapter in processed["adapters"]: for adapter in processed["adapters"]:
if "dhcp_enabled" in adapter and adapter["dhcp_enabled"] is not None: if "dhcp_enabled" in adapter and adapter["dhcp_enabled"] is not None:
adapter["dhcp_enabled"] = (adapter["dhcp_enabled"].lower() == "yes") adapter["dhcp_enabled"] = (adapter["dhcp_enabled"].lower() == "yes")
if "autoconfiguration_enabled" in adapter and adapter["autoconfiguration_enabled"] is not None: if "autoconfiguration_enabled" in adapter and adapter["autoconfiguration_enabled"] is not None:
adapter["autoconfiguration_enabled"] = (adapter["autoconfiguration_enabled"].lower() == "yes") adapter["autoconfiguration_enabled"] = (adapter["autoconfiguration_enabled"].lower() == "yes")
if "netbios_over_tcpip" in adapter and adapter["netbios_over_tcpip"] is not None: if "netbios_over_tcpip" in adapter and adapter["netbios_over_tcpip"] is not None:
adapter["netbios_over_tcpip"] = (adapter["netbios_over_tcpip"].lower() == "enabled") adapter["netbios_over_tcpip"] = (adapter["netbios_over_tcpip"].lower() == "enabled")
if "lease_expires" in adapter and adapter["lease_expires"] is not None and adapter["lease_expires"] != "": if "lease_expires" in adapter and adapter["lease_expires"] is not None and adapter["lease_expires"] != "":
try: try:
adapter["lease_expires"] = datetime.strptime(adapter["lease_expires"], "%A, %B %d, %Y %I:%M:%S %p").isoformat() adapter["lease_expires"] = datetime.strptime(adapter["lease_expires"], "%A, %B %d, %Y %I:%M:%S %p").isoformat()
except: except:
pass # Leave date in raw format if not parseable pass # Leave date in raw format if not parseable
if "lease_obtained" in adapter and adapter["lease_obtained"] is not None and adapter["lease_obtained"] != "": if "lease_obtained" in adapter and adapter["lease_obtained"] is not None and adapter["lease_obtained"] != "":
try: try:
adapter["lease_obtained"] = datetime.strptime(adapter["lease_obtained"], "%A, %B %d, %Y %I:%M:%S %p").isoformat() adapter["lease_obtained"] = datetime.strptime(adapter["lease_obtained"], "%A, %B %d, %Y %I:%M:%S %p").isoformat()
except: except:
pass # Leave date in raw format if not parseable pass # Leave date in raw format if not parseable
adapter["link_local_ipv6_addresses"] = [_process_ipv6_address(address) for address in adapter.get("link_local_ipv6_addresses", [])] adapter["link_local_ipv6_addresses"] = [_process_ipv6_address(address) for address in adapter.get("link_local_ipv6_addresses", [])]
adapter["ipv4_addresses"] = [_process_ipv4_address(address) for address in adapter.get("ipv4_addresses", [])] adapter["ipv4_addresses"] = [_process_ipv4_address(address) for address in adapter.get("ipv4_addresses", [])]
return processed return processed
class _PushbackIterator: class _PushbackIterator:
def __init__(self, iterator): def __init__(self, iterator):
self.iterator = iterator self.iterator = iterator
self.pushback_stack = [] self.pushback_stack = []
def __iter__(self): def __iter__(self):
return self return self
def __next__(self): def __next__(self):
if self.pushback_stack: if self.pushback_stack:
return self.pushback_stack.pop() return self.pushback_stack.pop()
else: else:
return next(self.iterator) return next(self.iterator)
def pushback(self, value): def pushback(self, value):
self.pushback_stack.append(value) self.pushback_stack.append(value)
def _parse(data): def _parse(data):
# Initialize the parsed output dictionary with all fields set to None or empty lists # Initialize the parsed output dictionary with all fields set to None or empty lists
parse_output = { parse_output = {
@ -609,10 +624,12 @@ def _parse(data):
return parse_output return parse_output
def _is_adapter_start_line(line): def _is_adapter_start_line(line):
# Detect adapter start lines, e.g., "Ethernet adapter Ethernet:" # Detect adapter start lines, e.g., "Ethernet adapter Ethernet:"
return re.match(r"^[^\s].*adapter.*:", line, re.IGNORECASE) return re.match(r"^[^\s].*adapter.*:", line, re.IGNORECASE)
def _initialize_adapter(adapter_name): def _initialize_adapter(adapter_name):
adapter_name_split = adapter_name.split(" adapter ", 1) adapter_name_split = adapter_name.split(" adapter ", 1)
if len(adapter_name_split) > 1: if len(adapter_name_split) > 1:
@ -650,6 +667,7 @@ def _initialize_adapter(adapter_name):
"extras": [] # To store unrecognized fields "extras": [] # To store unrecognized fields
} }
def _parse_line(line): def _parse_line(line):
# Split the line into key and value using ':' or multiple spaces # Split the line into key and value using ':' or multiple spaces
key_value = re.split(r":", line.strip(), 1) key_value = re.split(r":", line.strip(), 1)
@ -662,6 +680,7 @@ def _parse_line(line):
else: else:
return None, None return None, None
def _parse_header_line(result, key, value, line_iter): def _parse_header_line(result, key, value, line_iter):
if key in ["host_name", "primary_dns_suffix", "node_type", "ip_routing_enabled", "wins_proxy_enabled"]: if key in ["host_name", "primary_dns_suffix", "node_type", "ip_routing_enabled", "wins_proxy_enabled"]:
result[key] = value result[key] = value
@ -674,11 +693,13 @@ def _parse_header_line(result, key, value, line_iter):
# Store unrecognized fields in extras # Store unrecognized fields in extras
result["extras"].append({key: value}) result["extras"].append({key: value})
def _parse_adapter_line(adapter, key, value, line_iter): def _parse_adapter_line(adapter, key, value, line_iter):
if key in ["connection_specific_dns_suffix","media_state", "description", "physical_address", "dhcp_enabled", if key in ["connection_specific_dns_suffix","media_state", "description", "physical_address", "dhcp_enabled",
"autoconfiguration_enabled", "dhcpv6_iaid", "dhcpv6_client_duid", "netbios_over_tcpip", "dhcp_server", "autoconfiguration_enabled", "dhcpv6_iaid", "dhcpv6_client_duid", "netbios_over_tcpip", "dhcp_server",
"lease_obtained", "lease_expires", "primary_wins_server"]: "lease_obtained", "lease_expires", "primary_wins_server"]:
adapter[key] = value adapter[key] = value
elif key in ["ipv6_address", "temporary_ipv6_address", "link_local_ipv6_address"]: elif key in ["ipv6_address", "temporary_ipv6_address", "link_local_ipv6_address"]:
address_dict = _parse_ipv6_address(value) address_dict = _parse_ipv6_address(value)
if key == "ipv6_address": if key == "ipv6_address":
@ -687,32 +708,39 @@ def _parse_adapter_line(adapter, key, value, line_iter):
adapter["temporary_ipv6_addresses"].append(address_dict) adapter["temporary_ipv6_addresses"].append(address_dict)
elif key == "link_local_ipv6_address": elif key == "link_local_ipv6_address":
adapter["link_local_ipv6_addresses"].append(address_dict) adapter["link_local_ipv6_addresses"].append(address_dict)
elif key in ["ipv4_address", "autoconfiguration_ipv4_address", "ip_address", "autoconfiguration_ip_address"]: elif key in ["ipv4_address", "autoconfiguration_ipv4_address", "ip_address", "autoconfiguration_ip_address"]:
ipv4_address_dict = _parse_ipv4_address(value, key, line_iter) ipv4_address_dict = _parse_ipv4_address(value, key, line_iter)
adapter["ipv4_addresses"].append(ipv4_address_dict) adapter["ipv4_addresses"].append(ipv4_address_dict)
elif key == "connection_specific_dns_suffix_search_list": elif key == "connection_specific_dns_suffix_search_list":
if value: if value:
adapter["connection_specific_dns_suffix_search_list"].append(value) adapter["connection_specific_dns_suffix_search_list"].append(value)
# Process additional connection specific dns suffix search list entries # Process additional connection specific dns suffix search list entries
_parse_additional_entries(adapter["connection_specific_dns_suffix_search_list"], line_iter) _parse_additional_entries(adapter["connection_specific_dns_suffix_search_list"], line_iter)
elif key == "default_gateway": elif key == "default_gateway":
if value: if value:
adapter["default_gateways"].append(value) adapter["default_gateways"].append(value)
# Process additional gateways # Process additional gateways
_parse_additional_entries(adapter["default_gateways"], line_iter) _parse_additional_entries(adapter["default_gateways"], line_iter)
elif key == "dns_servers": elif key == "dns_servers":
if value: if value:
adapter["dns_servers"].append(value) adapter["dns_servers"].append(value)
# Process additional DNS servers # Process additional DNS servers
_parse_additional_entries(adapter["dns_servers"], line_iter) _parse_additional_entries(adapter["dns_servers"], line_iter)
elif key == "subnet_mask": elif key == "subnet_mask":
# Subnet Mask should be associated with the last IPv4 address # Subnet Mask should be associated with the last IPv4 address
if adapter["ipv4_addresses"]: if adapter["ipv4_addresses"]:
adapter["ipv4_addresses"][-1]["subnet_mask"] = value adapter["ipv4_addresses"][-1]["subnet_mask"] = value
else: else:
# Store unrecognized fields in extras # Store unrecognized fields in extras
adapter["extras"].append({key: value}) adapter["extras"].append({key: value})
def _parse_ipv6_address(value): def _parse_ipv6_address(value):
# Handle multiple status indicators # Handle multiple status indicators
match = re.match(r"([^\(]+)\((.*)\)", value) if value else None match = re.match(r"([^\(]+)\((.*)\)", value) if value else None
@ -727,6 +755,7 @@ def _parse_ipv6_address(value):
"status": status "status": status
} }
def _parse_ipv4_address(value, key, line_iter): def _parse_ipv4_address(value, key, line_iter):
# Handle autoconfigured status # Handle autoconfigured status
match = re.match(r"([^\(]+)\((.*)\)", value) if value else None match = re.match(r"([^\(]+)\((.*)\)", value) if value else None
@ -758,6 +787,7 @@ def _parse_ipv4_address(value, key, line_iter):
"status": status "status": status
} }
def _parse_additional_entries(entry_list, line_iter): def _parse_additional_entries(entry_list, line_iter):
# Process additional lines that belong to the current entry (e.g., additional DNS servers, DNS Suffix Search List) # Process additional lines that belong to the current entry (e.g., additional DNS servers, DNS Suffix Search List)
while True: while True:

View File

@ -1,4 +1,4 @@
.TH jc 1 2024-09-22 1.25.4 "JSON Convert" .TH jc 1 2024-10-18 1.25.4 "JSON Convert"
.SH NAME .SH NAME
\fBjc\fP \- JSON Convert JSONifies the output of many CLI tools, file-types, \fBjc\fP \- JSON Convert JSONifies the output of many CLI tools, file-types,
and strings and strings
@ -347,6 +347,11 @@ INI with duplicate key file parser
\fB--ip-address\fP \fB--ip-address\fP
IPv4 and IPv6 Address string parser IPv4 and IPv6 Address string parser
.TP
.B
\fB--ipconfig\fP
`ipconfig` command parser
.TP .TP
.B .B
\fB--iptables\fP \fB--iptables\fP
@ -507,11 +512,6 @@ openvpn-status.log file parser
\fB--os-release\fP \fB--os-release\fP
`/etc/os-release` file parser `/etc/os-release` file parser
.TP
.B
\fB--pacman\fP
`pacman` command parser
.TP .TP
.B .B
\fB--passwd\fP \fB--passwd\fP