Skip to content

Commit

Permalink
bind to any address for listening (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
arnetheduck authored Mar 19, 2019
1 parent 9146e8e commit a69e52b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion eth/p2p.nim
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ proc listeningAddress*(node: EthereumNode): ENode =
return initENode(node.keys.pubKey, node.address)

proc startListening*(node: EthereumNode) =
let ta = initTAddress(node.address.ip, node.address.tcpPort)
# TODO allow binding to specific IP / IPv6 / etc
let ta = initTAddress(IPv4_any(), node.address.tcpPort)
if node.listeningServer == nil:
node.listeningServer = createStreamServer(ta, processIncoming,
{ReuseAddr},
Expand Down
3 changes: 2 additions & 1 deletion eth/p2p/discovery.nim
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,8 @@ proc processClient(transp: DatagramTransport,
debug "Receive failed", err = getCurrentExceptionMsg()

proc open*(d: DiscoveryProtocol) =
let ta = initTAddress(d.address.ip, d.address.udpPort)
# TODO allow binding to specific IP / IPv6 / etc
let ta = initTAddress(IPv4_any(), d.address.udpPort)
d.transp = newDatagramTransport(processClient, udata = d, local = ta)

proc lookupRandom*(d: DiscoveryProtocol): Future[seq[Node]] {.inline.} =
Expand Down
2 changes: 1 addition & 1 deletion eth/p2p/private/p2p_types.nim
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type
clientId*: string
connectionState*: ConnectionState
keys*: KeyPair
address*: Address
address*: Address # The external address that the node will be advertising
peerPool*: PeerPool

# Private fields:
Expand Down

0 comments on commit a69e52b

Please sign in to comment.