libp2p/wire

    Dark Mode
Search:
Group by:
  Source   Edit

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)): InternalRaisesFuture[
    StreamTransport, (CancelledError, LPError)] {.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: [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: StreamCallback2;
                           flags: set[ServerFlags] = {}; udata: ref T;
                           sock: AsyncFD = asyncInvalidSocket;
                           backlog: int = 100;
                           bufferSize: int = DefaultStreamBufferSize;
                           child: StreamServer = nil;
                           init: TransportInitCallback = nil): StreamServer {.
    ...raises: [LPError], 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], 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