let puncher handle message whenever a message is received for a non-existing connection

master
Christian Ulrich 2020-11-17 23:58:38 +01:00
parent dc7c94ed0d
commit e20a4b223d
No known key found for this signature in database
GPG Key ID: 8241BE099775A097
2 changed files with 12 additions and 14 deletions

View File

@ -72,6 +72,7 @@ proc handleMsg*(puncher: Puncher, msg: string, peerIp: IpAddress,
## ``initiate`` and ``respond``. ## ``initiate`` and ``respond``.
if msg != "ACK": if msg != "ACK":
return return
echo &"handling ACK message from {peerIp}:{peerPort}"
let (_, myPort) = puncher.sock.getLocalAddr() let (_, myPort) = puncher.sock.getLocalAddr()
let query = Attempt(srcPort: myPort, dstIp: peerIp, dstPorts: @[peerPort]) let query = Attempt(srcPort: myPort, dstIp: peerIp, dstPorts: @[peerPort])
let i = puncher.attempts.find(query) let i = puncher.attempts.find(query)

View File

@ -310,20 +310,17 @@ proc handleMsg(ctx: QuicP2PContext, msg: string, peerId: string,
conn = c.conn conn = c.conn
break break
if conn != nil: if conn != nil:
let receiveResult = quicly_receive(conn, nil, peerAddr, addr decoded) discard quicly_receive(conn, nil, peerAddr, addr decoded)
if receiveResult != 0: else:
ctx.puncher.handleMsg(msg, peerAddr[], peerSockLen) # The puncher needs to be informed about this message because it may
elif peerId.len == 0: # be the peer's response to our respond call.
let acceptResult = quicly_accept(addr conn, addr ctx.quiclyCtx, nil, ctx.puncher.handleMsg(msg, peerAddr[], peerSockLen)
peerAddr, addr decoded, nil, if peerId.len == 0:
addr ctx.nextCid, nil) let acceptResult = quicly_accept(addr conn, addr ctx.quiclyCtx, nil,
echo "acceptResult: ", acceptResult peerAddr, addr decoded, nil,
if acceptResult != 0: addr ctx.nextCid, nil)
# The puncher needs to be informed about this message because it may if acceptResult == 0:
# be the peer's response to our respond call. ctx.addConnection(conn, peerId)
ctx.puncher.handleMsg(msg, peerAddr[], peerSockLen)
else:
ctx.addConnection(conn, peerId)
proc receive(ctx: QuicP2PContext, peerId: string) {.async.} = proc receive(ctx: QuicP2PContext, peerId: string) {.async.} =
while true: while true: