let puncher handle message whenever a message is received for a non-existing connection
This commit is contained in:
parent
dc7c94ed0d
commit
e20a4b223d
|
@ -72,6 +72,7 @@ proc handleMsg*(puncher: Puncher, msg: string, peerIp: IpAddress,
|
|||
## ``initiate`` and ``respond``.
|
||||
if msg != "ACK":
|
||||
return
|
||||
echo &"handling ACK message from {peerIp}:{peerPort}"
|
||||
let (_, myPort) = puncher.sock.getLocalAddr()
|
||||
let query = Attempt(srcPort: myPort, dstIp: peerIp, dstPorts: @[peerPort])
|
||||
let i = puncher.attempts.find(query)
|
||||
|
|
25
quicp2p.nim
25
quicp2p.nim
|
@ -310,20 +310,17 @@ proc handleMsg(ctx: QuicP2PContext, msg: string, peerId: string,
|
|||
conn = c.conn
|
||||
break
|
||||
if conn != nil:
|
||||
let receiveResult = quicly_receive(conn, nil, peerAddr, addr decoded)
|
||||
if receiveResult != 0:
|
||||
ctx.puncher.handleMsg(msg, peerAddr[], peerSockLen)
|
||||
elif peerId.len == 0:
|
||||
let acceptResult = quicly_accept(addr conn, addr ctx.quiclyCtx, nil,
|
||||
peerAddr, addr decoded, nil,
|
||||
addr ctx.nextCid, nil)
|
||||
echo "acceptResult: ", acceptResult
|
||||
if acceptResult != 0:
|
||||
# The puncher needs to be informed about this message because it may
|
||||
# be the peer's response to our respond call.
|
||||
ctx.puncher.handleMsg(msg, peerAddr[], peerSockLen)
|
||||
else:
|
||||
ctx.addConnection(conn, peerId)
|
||||
discard quicly_receive(conn, nil, peerAddr, addr decoded)
|
||||
else:
|
||||
# The puncher needs to be informed about this message because it may
|
||||
# be the peer's response to our respond call.
|
||||
ctx.puncher.handleMsg(msg, peerAddr[], peerSockLen)
|
||||
if peerId.len == 0:
|
||||
let acceptResult = quicly_accept(addr conn, addr ctx.quiclyCtx, nil,
|
||||
peerAddr, addr decoded, nil,
|
||||
addr ctx.nextCid, nil)
|
||||
if acceptResult == 0:
|
||||
ctx.addConnection(conn, peerId)
|
||||
|
||||
proc receive(ctx: QuicP2PContext, peerId: string) {.async.} =
|
||||
while true:
|
||||
|
|
Loading…
Reference in New Issue