libp2p/wire

    Dark Mode
Search:
Group by:
  Source   Edit

Nim-Libp2p Copyright (c) 2018 Status Research & Development GmbH

Licensed under either of

at your option. This file may not be copied, modified, or distributed except according to those terms.

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: Eq, args: [], value: 478)], 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: Eq, args: [], value: 478)], 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: [Defect, LPError], raises: [Defect], tags: [].}

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): Future[StreamTransport] {.
    ...raises: [Defect, LPError, MaInvalidAddress], raises: [Defect], tags: [].}
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: [Defect, LPError],
    raises: [Defect], 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: [Defect, LPError, MaInvalidAddress], raises: [Defect].}
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: [Defect, LPError, MaInvalidAddress], raises: [Defect].}
Create new TCP stream server which bounds to ma address.   Source   Edit
proc getLocalAddress(sock: AsyncFD): TransportAddress {....raises: [Defect],
    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: [Defect], tags: [].}

Initialize TransportAddress with MultiAddress ma.

MultiAddress must be wire address, e.g. {IP4, IP6, UNIX}/{TCP, UDP}.

  Source   Edit