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