transport

package
v0.1.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2023 License: Unlicense Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LocalhostZeroIPv4TCP is the default localhost to bind to any address. Used in
	// tests.
	LocalhostZeroIPv4TCP = "/ip4/127.0.0.1/tcp/0"

	// DefaultMTU is the default maximum size for a packet.
	DefaultMTU = 1382

	// ConnBufs is the number of buffers to use in message dispatch channels.
	ConnBufs = 8192

	// IndraLibP2PID is the indra protocol identifier.
	IndraLibP2PID = "/indra/relay/" + indra.SemVer
)

Variables

This section is empty.

Functions

func Discover

func Discover(ctx context.Context, h host.Host, dht *dht.IpfsDHT,
	rendezvous string)

func GetHostAddress

func GetHostAddress(ha host.Host) string

func GetHostOnlyAddress

func GetHostOnlyAddress(ha host.Host) string

func NewDHT

func NewDHT(ctx context.Context, host host.Host,
	bootstrapPeers []multiaddr.Multiaddr) (d *dht.IpfsDHT, e error)

Types

type ByteChan

type ByteChan chan slice.Bytes

func NewByteChan

func NewByteChan(bufs int) ByteChan

func (ByteChan) Receive

func (s ByteChan) Receive() <-chan slice.Bytes

func (ByteChan) Send

func (s ByteChan) Send(b slice.Bytes) error

type Conn

type Conn struct {
	network.Conn
	MTU       int
	RemoteKey *crypto.Pub
	MultiAddr multiaddr.Multiaddr
	Host      host.Host

	Transport *DuplexByteChan
	sync.Mutex
	qu.C
	// contains filtered or unexported fields
}

func (*Conn) GetMTU

func (c *Conn) GetMTU() int

func (*Conn) GetRecv

func (c *Conn) GetRecv() tpt.Transport

func (*Conn) GetRemoteKey

func (c *Conn) GetRemoteKey() (remoteKey *crypto.Pub)

func (*Conn) GetSend

func (c *Conn) GetSend() tpt.Transport

func (*Conn) SetMTU

func (c *Conn) SetMTU(mtu int)

func (*Conn) SetRemoteKey

func (c *Conn) SetRemoteKey(remoteKey *crypto.Pub)

type DuplexByteChan

type DuplexByteChan struct {
	Receiver, Sender tpt.Transport
}

DuplexByteChan is intended to be connected up in chains with other processing steps as a pipeline. The send and receive functions send bytes to their respective send and receive channels, and the processing is added by a consuming type by listening to the send channel for requests to send, and forwarding data from the upstream to the receive channel.

func NewDuplexByteChan

func NewDuplexByteChan(bufs int) *DuplexByteChan

func NewSimDuplex

func NewSimDuplex(bufs int, ctx context.Context) (d *DuplexByteChan)

NewSimDuplex creates a DuplexByteChan that behaves like a single ByteChan by forwarding from the send channel to the receiver channel. This creates something like a virtual in memory packet connection, as used in many of the Onion tests for testing correct forwarding without a full network.

A network-using version of the same tests should also work exactly the same.

func (*DuplexByteChan) Receive

func (d *DuplexByteChan) Receive() (C <-chan slice.Bytes)

func (*DuplexByteChan) Send

func (d *DuplexByteChan) Send(b slice.Bytes) (e error)

type Listener

type Listener struct {
	DHT  *dht.IpfsDHT
	MTU  int
	Host host.Host

	*crypto.Keys
	context.Context
	sync.Mutex
	// contains filtered or unexported fields
}

func NewListener

func NewListener(rendezvous, multiAddr, storePath string, keys *crypto.Keys,
	ctx context.Context, mtu int) (c *Listener, e error)

func (*Listener) Accept

func (l *Listener) Accept() <-chan *Conn

func (*Listener) AddConn

func (l *Listener) AddConn(d *Conn)

func (*Listener) DelConn

func (l *Listener) DelConn(d *Conn)

func (*Listener) Dial

func (l *Listener) Dial(multiAddr string) (d *Conn)

func (*Listener) FindConn

func (l *Listener) FindConn(multiAddr string) (d *Conn)

func (*Listener) GetConnRecv

func (l *Listener) GetConnRecv(multiAddr string) (recv tpt.Transport)

func (*Listener) GetConnSend

func (l *Listener) GetConnSend(multiAddr string) (send tpt.Transport)

func (*Listener) SetMTU

func (l *Listener) SetMTU(mtu int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL