bind to any address for listening (#20)

This commit is contained in:
Jacek Sieka 2019-03-19 12:15:16 -06:00 committed by GitHub
parent 9146e8e2f0
commit a69e52bf3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 3 deletions

View File

@ -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},

View File

@ -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.} =

View File

@ -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: