aboutsummaryrefslogtreecommitdiff
path: root/tests/test1.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test1.nim')
-rw-r--r--tests/test1.nim18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/test1.nim b/tests/test1.nim
new file mode 100644
index 0000000..6f4ff82
--- /dev/null
+++ b/tests/test1.nim
@@ -0,0 +1,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)