introduce AcceptPort constant; add debug output
This commit is contained in:
parent
2e09016b9c
commit
dcd2c03d45
|
@ -5,6 +5,8 @@ import asyncutils
|
|||
import ../../message
|
||||
import random
|
||||
|
||||
const AcceptPort = Port(2000)
|
||||
|
||||
type
|
||||
PunchdResponse = Future[tuple[msgContent: string, sock: AsyncSocket]]
|
||||
PunchdProgressCb = proc (future: PunchdResponse, msgContent: string) {.async.}
|
||||
|
@ -186,6 +188,7 @@ proc initServerConnection(serverHostname: string, serverPort: Port,
|
|||
assert(args[0] == "ok")
|
||||
assert(args[1] == $id)
|
||||
let endpoint = parseMessage[OkGetEndpoint](args[2])
|
||||
echo "endpoint: ", endpoint
|
||||
result.probedIp = endpoint.ip
|
||||
result.probedPorts.add(endpoint.port)
|
||||
let emptyLine = await sock.recvLine(maxLength = 400)
|
||||
|
@ -208,10 +211,10 @@ proc runApp(serverHostname: string, serverPort: Port, peerId: string,
|
|||
if otherPeerId.len == 0:
|
||||
# register and wait for connections
|
||||
let serverConn = await initServerConnection(serverHostname, serverPort,
|
||||
Port(4321))
|
||||
AcceptPort)
|
||||
asyncCheck handleServerMessages(serverConn)
|
||||
asyncCheck handlePeerNotifications(serverConn, punchdConn, peerId)
|
||||
let myPorts = (@[Port(4321)] & serverConn.probedPorts).join(",")
|
||||
let myPorts = (@[AcceptPort] & serverConn.probedPorts).join(",")
|
||||
let req = &"{peerId}|{serverConn.probedIp}|{myPorts}"
|
||||
echo "registering: ", req
|
||||
discard await serverConn.sendRequest("register", req)
|
||||
|
|
Loading…
Reference in New Issue