Detect local "primary" IP address

This commit is contained in:
Federico Ceratto 2019-03-16 18:51:26 +00:00
commit 5825dcb0b5
3 changed files with 44 additions and 0 deletions

View file

@ -0,0 +1,8 @@
This directory contains tests that require networking and cannot be run in CI.
The tests can be run manually during development using:
```nim
./koch tests cat untestable/network/stdlib
```
The directory structure mimics tests/

View file

@ -0,0 +1,16 @@
discard """
outputsub: ""
"""
import net, nativesockets
import unittest
suite "getPrimaryIPAddr":
test "localhost v4":
check getPrimaryIPAddr(parseIpAddress("127.0.0.1")) == parseIpAddress("127.0.0.1")
test "localhost v6":
check getPrimaryIPAddr(parseIpAddress("::1")) == parseIpAddress("::1")
test "v4":
check getPrimaryIPAddr() != parseIpAddress("127.0.0.1")