This module implements wire network connection procedures.
Consts
RTRANSPMA = (operator: Or, args: [(operator: Or, args: [(operator: And, args: [( operator: Or, args: [(operator: Eq, args: [], value: 53), (operator: Eq, args: [], value: 54), (operator: Eq, args: [], value: 55), (operator: Eq, args: [], value: 56)], value: 0), (operator: Eq, args: [], value: 6)], value: 0), (operator: And, args: [( operator: Or, args: [(operator: Eq, args: [], value: 4), (operator: Eq, args: [], value: 41)], value: 0), (operator: Eq, args: [], value: 6)], value: 0)], value: 0), (operator: Or, args: [( operator: And, args: [(operator: Or, args: [(operator: And, args: [( operator: Or, args: [(operator: Eq, args: [], value: 53), (operator: Eq, args: [], value: 54), (operator: Eq, args: [], value: 55), (operator: Eq, args: [], value: 56)], value: 0), (operator: Eq, args: [], value: 6)], value: 0), (operator: And, args: [( operator: Or, args: [(operator: Eq, args: [], value: 4), (operator: Eq, args: [], value: 41)], value: 0), (operator: Eq, args: [], value: 6)], value: 0)], value: 0), (operator: Eq, args: [], value: 477)], value: 0), ( operator: And, args: [(operator: Or, args: [(operator: And, args: [( operator: Or, args: [(operator: Eq, args: [], value: 53), (operator: Eq, args: [], value: 54), (operator: Eq, args: [], value: 55), (operator: Eq, args: [], value: 56)], value: 0), (operator: Eq, args: [], value: 6)], value: 0), (operator: And, args: [( operator: Or, args: [(operator: Eq, args: [], value: 4), (operator: Eq, args: [], value: 41)], value: 0), (operator: Eq, args: [], value: 6)], value: 0)], value: 0), (operator: Or, args: [ (operator: Eq, args: [], value: 478), (operator: And, args: [ (operator: Eq, args: [], value: 448), (operator: Eq, args: [], value: 477)], value: 0)], value: 0)], value: 0)], value: 0), (operator: Eq, args: [], value: 400)], value: 0)
- Source Edit
TRANSPMA = (operator: Or, args: [(operator: Or, args: [(operator: Or, args: [( operator: And, args: [(operator: Or, args: [ (operator: Eq, args: [], value: 53), (operator: Eq, args: [], value: 54), (operator: Eq, args: [], value: 55), (operator: Eq, args: [], value: 56)], value: 0), (operator: Eq, args: [], value: 6)], value: 0), (operator: And, args: [(operator: Or, args: [ (operator: Eq, args: [], value: 4), (operator: Eq, args: [], value: 41)], value: 0), (operator: Eq, args: [], value: 6)], value: 0)], value: 0), (operator: Or, args: [(operator: And, args: [( operator: Or, args: [(operator: And, args: [(operator: Or, args: [ (operator: Eq, args: [], value: 53), (operator: Eq, args: [], value: 54), (operator: Eq, args: [], value: 55), (operator: Eq, args: [], value: 56)], value: 0), (operator: Eq, args: [], value: 6)], value: 0), (operator: And, args: [( operator: Or, args: [(operator: Eq, args: [], value: 4), (operator: Eq, args: [], value: 41)], value: 0), (operator: Eq, args: [], value: 6)], value: 0)], value: 0), (operator: Eq, args: [], value: 477)], value: 0), (operator: And, args: [( operator: Or, args: [(operator: And, args: [(operator: Or, args: [ (operator: Eq, args: [], value: 53), (operator: Eq, args: [], value: 54), (operator: Eq, args: [], value: 55), (operator: Eq, args: [], value: 56)], value: 0), (operator: Eq, args: [], value: 6)], value: 0), (operator: And, args: [( operator: Or, args: [(operator: Eq, args: [], value: 4), (operator: Eq, args: [], value: 41)], value: 0), (operator: Eq, args: [], value: 6)], value: 0)], value: 0), (operator: Or, args: [ (operator: Eq, args: [], value: 478), (operator: And, args: [ (operator: Eq, args: [], value: 448), (operator: Eq, args: [], value: 477)], value: 0)], value: 0)], value: 0)], value: 0), (operator: Eq, args: [], value: 400)], value: 0), (operator: Or, args: [( operator: And, args: [(operator: Or, args: [ (operator: Eq, args: [], value: 53), (operator: Eq, args: [], value: 54), (operator: Eq, args: [], value: 55), (operator: Eq, args: [], value: 56)], value: 0), (operator: Eq, args: [], value: 273)], value: 0), (operator: And, args: [(operator: Or, args: [ (operator: Eq, args: [], value: 4), (operator: Eq, args: [], value: 41)], value: 0), (operator: Eq, args: [], value: 273)], value: 0)], value: 0)], value: 0)
- Source Edit
Procs
proc bindAsyncSocket(sock: AsyncFD; ma: MultiAddress): bool {....raises: [LPError], raises: [], tags: [RootEffect].}
-
Bind socket sock to MultiAddress ma.
Note: This procedure only used in go-libp2p-daemon wrapper.
Source Edit proc connect(ma: MultiAddress; bufferSize = DefaultStreamBufferSize; child: StreamTransport = nil; flags = default(set[SocketFlags]); localAddress: Opt[MultiAddress] = Opt.none(MultiAddress)): Future[ StreamTransport] {.stackTrace: false, ...raises: [], gcsafe, raises: [], raises: [], tags: [RootEffect].}
- Open new connection to remote peer with address ma and create new transport object StreamTransport for established connection. bufferSize is size of internal buffer for transport. Source Edit
proc createAsyncSocket(ma: MultiAddress): AsyncFD {. ...raises: [ValueError, LPError], raises: [], tags: [RootEffect].}
-
Create new asynchronous socket using MultiAddress' ma socket type and protocol information.
Returns asyncInvalidSocket on error.
Note: This procedure only used in go-libp2p-daemon wrapper.
Source Edit proc createStreamServer[T](ma: MultiAddress; cbproc: StreamCallback; flags: set[ServerFlags] = {}; udata: ref T; sock: AsyncFD = asyncInvalidSocket; backlog: int = 100; bufferSize: int = DefaultStreamBufferSize; child: StreamServer = nil; init: TransportInitCallback = nil): StreamServer {. ...raises: [LPError, MaInvalidAddress], raises: [].}
- Create new TCP stream server which bounds to ma address. Source Edit
proc createStreamServer[T](ma: MultiAddress; flags: set[ServerFlags] = {}; udata: ref T; sock: AsyncFD = asyncInvalidSocket; backlog: int = 100; bufferSize: int = DefaultStreamBufferSize; child: StreamServer = nil; init: TransportInitCallback = nil): StreamServer {. ...raises: [LPError, MaInvalidAddress], raises: [].}
- Create new TCP stream server which bounds to ma address. Source Edit
proc getLocalAddress(sock: AsyncFD): TransportAddress {....raises: [], tags: [].}
-
Retrieve local socket sock address.
Note: This procedure only used in go-libp2p-daemon wrapper.
Source Edit proc initTAddress(ma: MultiAddress): MaResult[TransportAddress] {....raises: [], tags: [RootEffect].}
-
Initialize TransportAddress with MultiAddress ma.
MultiAddress must be wire address, e.g. {IP4, IP6, UNIX}/{TCP, UDP}.
Source Edit proc isPublicMA(ma: MultiAddress): bool {....raises: [], tags: [RootEffect].}
- Source Edit
Exports
-
DNS_OR_IP, exclIfIt, hash, UDP_DNS, MaError, IPFS, MaPatternOp, isEmpty, WS_DNS, initVBuffer, ProtoScalar, getProtoHeader, hex, protocols, bytes, ==, getLen, HTTPS, UNIX, isEnough, TranscoderIP6, encode, [], MaResult, init, ProtoField, peekVarint, getRequiredRepeatedField, mapOr, writeSeq, WebSockets_IP, &, DNS6, TLS_WS, [], IpTransportProtocol, QUIC, toOpenArray, IP4, TranscoderPort, withValue, safeConvert, getRequiredField, $, WS_IP, withValue, public, MAKind, getField, checkFieldNumber, TranscoderOnion3, getRepeatedField, matchPartial, protoArgument, match, data, WebSockets, $, isEmpty, HTTP, initVBuffer, finish, VBuffer, init, TcpOnion3, initProtoBuffer, MAProtocol, peekSeq, getPackedRepeatedField, toOpt, getProtoHeader, ProtoHeader, IP, getField, protoAddress, DNS4, readArray, getPtr, withValue, P2PPattern, CircuitRelay, contains, isEnough, Reliable, ProtoBuffer, len, WS, exceptionToAssert, mapAnd, UDP_IP, DNSANY, DNSADDR, append, write, WSS_IP, peekArray, WSS, readSeq, getRepeatedField, TCP_IP, getField, writePacked, Unreliable, TCP_DNS, capLen, init, protoName, protoArgument, validate, mapEq, Onion3, MaPattern, TranscoderIP6Zone, $, initProtoBuffer, concat, TranscoderP2P, WSS_DNS, writeLPVarint, write, ProtoResult, WebRTCDirect, len, UDP, MaPatResult, TranscoderOnion, write, init, shortLog, items, isEmpty, writeArray, write, WebSockets_DNS, init, UTP, [], IP6, shortLog, ProtoFlags, finish, writePBVarint, valueOr, ProtoFieldKind, TCP, TranscoderDNS, getRepeatedField, ProtoError, init, init, getField, MultiAddress, &=, readVarint, compilesOr, vsizeof, getField, TranscoderIP4, init, initVBuffer, protoCode, MaInvalidAddress, initProtoBuffer, DNS, write, TranscoderUnix, high, toString, writeVarint, SupportedWireTypes