eyre.network-parse
compress-ipv6
(compress-ipv6 s)Takes a string representation of an IPv6 address (full or already compressed) and returns its canonical, maximally-compressed form per RFC 5952 (lowercase hex, no leading zeros, longest zero-run collapsed to ‘::’, leftmost run wins ties).
ifconfig-blocks
(ifconfig-blocks s)Splits ifconfig -a output into a list of name header-line body-lines.
ipv4-in-subnet?
(ipv4-in-subnet? ip network netmask)Returns true if ip belongs to network/netmask.
ipv4-octets
(ipv4-octets ip)join-ip-o-lines
(join-ip-o-lines s)ip -o output escapes continuation lines with a trailing backslash. Join those physical lines back into single logical lines.
parse-angled-flags
(parse-angled-flags s)Parses a token like flags=1008843<UP,BROADCAST,RUNNING> or options=880028<VLAN_MTU,JUMBO_MTU> returning {:value 1008843 :flags #{:UP :BROADCAST :RUNNING}} or nil.
parse-ifconfig
(parse-ifconfig s)Parses ifconfig -a output into a seq of interface maps.
parse-ifconfig-block
(parse-ifconfig-block [name header body])parse-ip-o-addr
(parse-ip-o-addr s)parse-ip-o-link
(parse-ip-o-link s)Parses ip -o link output into a map of interface-name -> {:mac :mtu :status :loopback?}.
parse-ip-route-default
(parse-ip-route-default s)Parses ip route show default output, returns the first default route as {:address :interface}.
parse-netsh-ipv4-show-config
(parse-netsh-ipv4-show-config s)parse-netsh-ipv4-show-interfaces
(parse-netsh-ipv4-show-interfaces s)parse-netstat-default-route
(parse-netstat-default-route s)Parses netstat -rn output for the default route. Returns hashmap with :gateway and :interface
parse-pipe-rows
(parse-pipe-rows s)Splits content into seqs of fields split on |. Skips blank lines.
parse-proc-net-default-route
(parse-proc-net-default-route proc-net-route)parse-proc-network-info
(parse-proc-network-info sys-class-net proc-net-route proc-net-fib-trie)Parses raw /sys/class/net, /proc/net/route and /proc/net/fib_trie dumps into a seq of interface maps, mirroring parse-ifconfig.
Local IPv4 addresses are the host LOCAL /32 leaf entries from fib_trie. Each is assigned to the interface whose subnet contains it (subnets come from fib_trie; the owning interface is resolved through /proc/net/route, with 127.0.0.0/8 inferred as the loopback). The reported prefix is the containing subnet’s prefix length, matching ifconfig’s netmask reporting rather than the /32 host route. The IPv6 loopback address (::1/128) is added to loopback interfaces.
parse-scutil-dns
(parse-scutil-dns s)Parses scutil --dns output, returning the union of nameservers and search domains across resolvers.