adapt rendezvous server protocol to multi-server probing
This commit is contained in:
parent
278f066797
commit
b7236bfe45
|
@ -9,13 +9,15 @@ type
|
|||
Client = object
|
||||
sock: AsyncSocket
|
||||
ip: IpAddress
|
||||
ports: seq[Port]
|
||||
port: Port
|
||||
probedPorts: seq[Port]
|
||||
|
||||
# Requests
|
||||
Register = object
|
||||
peerId: string
|
||||
ip: IpAddress
|
||||
ports: seq[Port]
|
||||
port: Port
|
||||
probedPorts: seq[Port]
|
||||
|
||||
GetPeerinfo = object
|
||||
peerId: string
|
||||
|
@ -88,7 +90,8 @@ proc processClient(client: AsyncSocket,
|
|||
let req = parseMessage[Register](args[2])
|
||||
echo "register: ", req
|
||||
peerId = req.peerId
|
||||
clients[peerId] = Client(sock: client, ip: req.ip, ports: req.ports)
|
||||
clients[peerId] = Client(sock: client, ip: req.ip, port: req.port,
|
||||
probedPorts: req.probedPorts)
|
||||
asyncCheck client.send(&"ok|{id}\n")
|
||||
of "get-endpoint":
|
||||
echo "get-endpoint"
|
||||
|
@ -99,8 +102,8 @@ proc processClient(client: AsyncSocket,
|
|||
let req = parseMessage[GetPeerinfo](args[2])
|
||||
echo "get-info: ", req
|
||||
let peer = clients[req.peerId]
|
||||
let peerPorts = peer.ports.join(",")
|
||||
asyncCheck client.send(&"ok|{id}|{peer.ip}|{peerPorts}\n")
|
||||
let probedPorts = peer.probedPorts.join(",")
|
||||
asyncCheck client.send(&"ok|{id}|{peer.ip}|{peer.port}|{probedPorts}\n")
|
||||
of "notify-peer":
|
||||
let req = parseMessage[NotifyPeer](args[2])
|
||||
echo "notify-peer: ", req
|
||||
|
|
Loading…
Reference in New Issue