mirror of https://github.com/status-im/nim-eth.git
Update address to UDP endpoint and delete keys on removal from DHT
This commit is contained in:
parent
00c2bac465
commit
55b8e3e23f
|
@ -282,6 +282,11 @@ proc decodeEncrypted*(c: var Codec,
|
|||
return HandshakeError
|
||||
c.handshakes.del(key)
|
||||
|
||||
# For an incoming handshake, we are not sure the address in the ENR is there
|
||||
# and if it is the real external IP, so we use the one we know from the
|
||||
# UDP packet.
|
||||
updateEndpoint(newNode, fromAddr)
|
||||
|
||||
# Swap keys to match remote
|
||||
swap(sec.readKey, sec.writeKey)
|
||||
# TODO: is it safe to ignore the error here?
|
||||
|
|
|
@ -53,6 +53,8 @@ proc `==`*(a, b: Node): bool = (a.isNil and b.isNil) or (not a.isNil and not b.i
|
|||
|
||||
proc address*(n: Node): Address {.inline.} = n.node.address
|
||||
|
||||
proc updateEndpoint*(n: Node, a: Address) {.inline.} = n.node.address = a
|
||||
|
||||
proc `$`*(n: Node): string =
|
||||
if n == nil:
|
||||
"Node[local]"
|
||||
|
|
|
@ -397,9 +397,11 @@ proc revalidateNode(p: Protocol, n: Node)
|
|||
if n notin p.bootstrapNodes:
|
||||
trace "Revalidation of node failed, removing node", node = $n
|
||||
p.routingTable.removeNode(n)
|
||||
# TODO: Do we delete the shared secrets here?
|
||||
# And if so, the current way they are stored, we might not have the key
|
||||
# (specifically if the ENR does not have the correct address)
|
||||
# Remove shared secrets when removing the node from routing table.
|
||||
# This might be to direct, so we could keep these longer. But better
|
||||
# would be to simply not remove the nodes immediatly but only after x
|
||||
# amount of failures.
|
||||
discard p.codec.db.deleteKeys(n.id, n.address)
|
||||
|
||||
proc revalidateLoop(p: Protocol) {.async.} =
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue