update conn peerinfo instead of replacing (#445)
* update conn peerinfo instead of replacing * remove unnecesary peerid var
This commit is contained in:
parent
034a1e8b1b
commit
6cc3f4283a
|
@ -505,11 +505,13 @@ method handshake*(p: Noise, conn: Connection, initiator: bool): Future[SecureCon
|
||||||
received_key = $remotePubKey
|
received_key = $remotePubKey
|
||||||
raise newException(NoiseHandshakeError, "Noise handshake, peer infos don't match! " & $pid & " != " & $conn.peerInfo.peerId)
|
raise newException(NoiseHandshakeError, "Noise handshake, peer infos don't match! " & $pid & " != " & $conn.peerInfo.peerId)
|
||||||
|
|
||||||
let peerInfo =
|
conn.peerInfo =
|
||||||
if conn.peerInfo != nil: conn.peerInfo
|
if conn.peerInfo != nil:
|
||||||
else: PeerInfo.init(remotePubKey)
|
conn.peerInfo
|
||||||
|
else:
|
||||||
|
PeerInfo.init(PeerID.init(remotePubKey).tryGet())
|
||||||
|
|
||||||
var tmp = NoiseConnection.init(conn, peerInfo, conn.observedAddr)
|
var tmp = NoiseConnection.init(conn, conn.peerInfo, conn.observedAddr)
|
||||||
|
|
||||||
if initiator:
|
if initiator:
|
||||||
tmp.readCs = handshakeRes.cs2
|
tmp.readCs = handshakeRes.cs2
|
||||||
|
|
|
@ -255,11 +255,13 @@ proc newSecioConn(conn: Connection,
|
||||||
## cipher algorithm ``cipher``, stretched keys ``secrets`` and order
|
## cipher algorithm ``cipher``, stretched keys ``secrets`` and order
|
||||||
## ``order``.
|
## ``order``.
|
||||||
|
|
||||||
let peerInfo =
|
conn.peerInfo =
|
||||||
if conn.peerInfo != nil: conn.peerInfo
|
if conn.peerInfo != nil:
|
||||||
else: PeerInfo.init(remotePubKey)
|
conn.peerInfo
|
||||||
|
else:
|
||||||
|
PeerInfo.init(PeerID.init(remotePubKey).tryGet())
|
||||||
|
|
||||||
result = SecioConn.init(conn, peerInfo, conn.observedAddr)
|
result = SecioConn.init(conn, conn.peerInfo, conn.observedAddr)
|
||||||
|
|
||||||
let i0 = if order < 0: 1 else: 0
|
let i0 = if order < 0: 1 else: 0
|
||||||
let i1 = if order < 0: 0 else: 1
|
let i1 = if order < 0: 0 else: 1
|
||||||
|
|
Loading…
Reference in New Issue