blob: 6f4ff824fdc2dc262f1313a0a2faa59d74f3451d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
from net import IpAddressFamily
from strutils import join, toHex
from sequtils import mapIt
import ifaddr
proc `$`(ip: IP): string =
case ip.ip.family
of IpAddressFamily.IPv6:
result = join(mapIt(ip.ip.address_v6, it.toHex()), ":")
of IpAddressFamily.IPv4:
result = join(ip.ip.address_v4, ".")
result &= "/" & $ip.networkPrefix
for adapter in getAdapters():
echo("IPs of network adapter ", adapter.niceName)
for ip in adapter.ips:
echo(" ", ip)
|