Observed address handling
This commit is contained in:
parent
af0a9ac66e
commit
905f221355
4
.pinned
4
.pinned
|
@ -8,7 +8,7 @@ json_serialization;https://github.com/status-im/nim-json-serialization@#a7d815ed
|
|||
metrics;https://github.com/status-im/nim-metrics@#21e99a2e9d9f80e68bef65c80ef781613005fccb
|
||||
ngtcp2;https://github.com/status-im/nim-ngtcp2@#76bf92475f55728ff55a2a19b45a5fcbb4faa2ab
|
||||
nimcrypto;https://github.com/cheatfate/nimcrypto@#24e006df85927f64916e60511620583b11403178
|
||||
quic;https://github.com/status-im/nim-quic.git@#9dd9b528cfda50f6482f800175d7350cb03911ff
|
||||
quic;https://github.com/status-im/nim-quic.git@#a4e7cdbfc9c02956942aa12f8b6c35fa877f401a
|
||||
secp256k1;https://github.com/status-im/nim-secp256k1@#fd173fdff863ce2e211cf64c9a03bc7539fe40b0
|
||||
serialization;https://github.com/status-im/nim-serialization@#d77417cba6896c26287a68e6a95762e45a1b87e5
|
||||
stew;https://github.com/status-im/nim-stew@#f2f9685ec904868bbb48485e72ddc026ed51b230
|
||||
|
@ -16,4 +16,4 @@ testutils;https://github.com/status-im/nim-testutils@#dfc4c1b39f9ded9baf6365014d
|
|||
unittest2;https://github.com/status-im/nim-unittest2@#da8398c45cafd5bd7772da1fc96e3924a18d3823
|
||||
upraises;https://github.com/markspanbroek/upraises@#d9f268db1021959fe0f2c7a5e49fba741f9932a0
|
||||
websock;https://github.com/status-im/nim-websock@#691f069b209d372b1240d5ae1f57fb7bbafeaba7
|
||||
zlib;https://github.com/status-im/nim-zlib@#6a6670afba6b97b29b920340e2641978c05ab4d8
|
||||
zlib;https://github.com/status-im/nim-zlib@#6a6670afba6b97b29b920340e2641978c05ab4d8
|
||||
|
|
|
@ -48,6 +48,7 @@ else:
|
|||
stream/connection,
|
||||
transports/transport,
|
||||
transports/tcptransport,
|
||||
transports/quictransport,
|
||||
transports/wstransport,
|
||||
protocols/secure/noise,
|
||||
protocols/ping,
|
||||
|
|
|
@ -33,7 +33,7 @@ type
|
|||
stream: Stream
|
||||
cached: seq[byte]
|
||||
|
||||
proc new(_: type QuicStream, stream: Stream, oaddr: MultiAddress, peerId: PeerId): QuicStream =
|
||||
proc new(_: type QuicStream, stream: Stream, oaddr: Opt[MultiAddress], peerId: PeerId): QuicStream =
|
||||
let quicstream = QuicStream(stream: stream, observedAddr: oaddr, peerId: peerId)
|
||||
procCall P2PConnection(quicstream).initStream()
|
||||
quicstream
|
||||
|
@ -201,9 +201,13 @@ method handles*(transport: QuicTransport, address: MultiAddress): bool =
|
|||
method start*(transport: QuicTransport, addrs: seq[MultiAddress]) {.async.} =
|
||||
doAssert transport.listener.isNil, "start() already called"
|
||||
#TODO handle multiple addr
|
||||
#TODO resolve used address
|
||||
transport.listener = listen(initTAddress(addrs[0]).tryGet)
|
||||
await procCall Transport(transport).start(addrs)
|
||||
transport.addrs[0] =
|
||||
MultiAddress.init(
|
||||
transport.listener.localAddress(),
|
||||
IPPROTO_UDP
|
||||
).tryGet() & MultiAddress.init("/quic").get()
|
||||
transport.running = true
|
||||
|
||||
method stop*(transport: QuicTransport) {.async.} =
|
||||
|
@ -215,11 +219,14 @@ method stop*(transport: QuicTransport) {.async.} =
|
|||
transport.running = false
|
||||
transport.listener = nil
|
||||
|
||||
proc wrapConnection(transport: QuicTransport, connection: QuicConnection): P2PConnection =
|
||||
#TODO currently not exposed from nim-quic
|
||||
proc wrapConnection(
|
||||
transport: QuicTransport,
|
||||
connection: QuicConnection): P2PConnection {.raises: [Defect, TransportOsError, LPError].} =
|
||||
let
|
||||
observedAddr = MultiAddress.init("/ip4/0.0.0.0/udp/0/quic").get()
|
||||
conres = QuicSession(connection: connection, observedAddr: observedAddr)
|
||||
remoteAddr = connection.remoteAddress()
|
||||
observedAddr =
|
||||
MultiAddress.init(remoteAddr, IPPROTO_UDP).get() & MultiAddress.init("/quic").get()
|
||||
conres = QuicSession(connection: connection, observedAddr: Opt.some(observedAddr))
|
||||
conres.initStream()
|
||||
|
||||
transport.connections.add(conres)
|
||||
|
|
Loading…
Reference in New Issue