Skip to content

Commit

Permalink
Fix #125 for Linux.
Browse files Browse the repository at this point in the history
Still allows the local node to connect to itself over the local network.
  • Loading branch information
kayabaNerve committed Jan 24, 2020
1 parent 7de9e23 commit 2f876c6
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/Network/Clients.nim
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,20 @@ proc add*(
networkFunctions: NetworkLibFunctionBox
) {.forceCheck: [], async.} =
#Get the IP.
var addressParts: seq[string] = @[]
var
address: string
addressParts: seq[string]
try:
addressParts = socket.getPeerAddr()[0].split(".")
address = socket.getPeerAddr()[0]

if (socket.getLocalAddr()[0] == address) and (address != "127.0.0.1"):
try:
socket.close()
except Exception as e:
doAssert(false, "Failed to close a socket: " & e.msg)
return

addressParts = address.split(".")
except OSError as e:
doAssert(false, "Failed to get a peer's address: " & e.msg)

Expand Down

0 comments on commit 2f876c6

Please sign in to comment.