Detect local "primary" IP address
This commit is contained in:
parent
328901757a
commit
5825dcb0b5
3 changed files with 44 additions and 0 deletions
16
tests/untestable/network/stdlib/tnet.nim
Normal file
16
tests/untestable/network/stdlib/tnet.nim
Normal 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")
|
||||
Loading…
Add table
Add a link
Reference in a new issue