Use the specified extip address in the advertised ENR records

This commit is contained in:
Zahary Karadjov 2020-02-22 20:52:08 +02:00
parent 425b0e13da
commit fa0f3b4468
No known key found for this signature in database
GPG Key ID: C8936F8A3073D609
6 changed files with 8 additions and 8 deletions

View File

@ -16,7 +16,7 @@ export
proc new*(T: type Eth2DiscoveryProtocol,
conf: BeaconNodeConf,
rawPrivKeyBytes: openarray[byte]): T =
ip: IpAddress, rawPrivKeyBytes: openarray[byte]): T =
# TODO
# Implement more configuration options:
# * for setting up a specific key
@ -25,7 +25,7 @@ proc new*(T: type Eth2DiscoveryProtocol,
pk = initPrivateKey(rawPrivKeyBytes)
db = DiscoveryDB.init(newMemoryDB())
newProtocol(pk, db, Port conf.tcpPort, Port conf.udpPort)
newProtocol(pk, db, ip, Port conf.tcpPort, Port conf.udpPort)
proc toENode*(a: MultiAddress): Result[ENode, cstring] =
if not IPFS.match(a):

View File

@ -156,7 +156,7 @@ when networkBackend in [libp2p, libp2pDaemon]:
# are running behind a NAT).
var switch = newStandardSwitch(some keys.seckey, hostAddress,
triggerSelf = true, gossip = false)
result = Eth2Node.init(conf, switch, keys.seckey.asEthKey)
result = Eth2Node.init(conf, switch, extIp, keys.seckey.asEthKey)
else:
let keyFile = conf.ensureNetworkIdFile

View File

@ -220,11 +220,11 @@ proc runDiscoveryLoop*(node: Eth2Node) {.async.} =
await sleepAsync seconds(1)
proc init*(T: type Eth2Node, conf: BeaconNodeConf,
switch: Switch, privKey: keys.PrivateKey): T =
switch: Switch, ip: IpAddress, privKey: keys.PrivateKey): T =
new result
result.switch = switch
result.peers = initTable[PeerID, Peer]()
result.discovery = Eth2DiscoveryProtocol.new(conf, privKey.data)
result.discovery = Eth2DiscoveryProtocol.new(conf, ip, privKey.data)
result.wantedPeers = conf.maxPeers
newSeq result.protocolStates, allProtocols.len

@ -1 +1 @@
Subproject commit f1acc470eb01a4d9086e752d103a73e49a372eaf
Subproject commit b9315ced4e2d7926737dab73b2374543088e17fd

2
vendor/nim-eth vendored

@ -1 +1 @@
Subproject commit 5aebab3f41834505af7c694f8caf2e8c9c5716cc
Subproject commit 74d0247e6b69bf45d4e53c27e0089d5bb35b29ed

@ -1 +1 @@
Subproject commit e7a34b74f298eaabd7bdbe2f080bf9747ed6bfd9
Subproject commit 5fb40e4ffd2c5a7eca88203d99150e2d99732e41