i2p

package module
v0.0.0-...-426a594 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2022 License: Unlicense Imports: 16 Imported by: 1

README

I2P Transport for go-libp2p

This library can be used to build go-libp2p applications using the i2p network.

Look at transport_test.go for example usage

Open to contribution sand bug reports

License

this library is released as public-domain. Do whatever you want with it

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func I2PAddrToMultiAddr

func I2PAddrToMultiAddr(addr string) (ma.Multiaddr, error)

expects either a base32 or base64 i2p destination expects there to be no :port suffix to the address

func MultiAddrToI2PAddr

func MultiAddrToI2PAddr(addr ma.Multiaddr) (string, error)

Types

type ConnWithoutAddr

type ConnWithoutAddr interface {
	Read(b []byte) (n int, err error)
	Write(b []byte) (n int, err error)
	Close() error
	SetDeadline(t time.Time) error
	SetReadDeadline(t time.Time) error
	SetWriteDeadline(t time.Time) error
}

ConnWithoutAddr is a net.Conn like but without LocalAddr and RemoteAddr.

type Connection

type Connection struct {
	ConnWithoutAddr
	// contains filtered or unexported fields
}

This struct only exists to satify libp2p interfaces

func NewConnection

func NewConnection(conn ConnWithoutAddr, localAddr, remoteAddr ma.Multiaddr) (*Connection, error)

func (*Connection) LocalAddr

func (c *Connection) LocalAddr() net.Addr

I don't think these are used anywhere.. but must match the interface

func (*Connection) LocalMultiaddr

func (c *Connection) LocalMultiaddr() ma.Multiaddr

func (*Connection) RemoteAddr

func (c *Connection) RemoteAddr() net.Addr

func (*Connection) RemoteMultiaddr

func (c *Connection) RemoteMultiaddr() ma.Multiaddr

type I2PTransport

type I2PTransport struct {
	// Connection upgrader for upgrading insecure stream connections to
	// secure multiplex connections.
	Upgrader transport.Upgrader
	// contains filtered or unexported fields
}

func (*I2PTransport) CanDial

func (i2p *I2PTransport) CanDial(addr ma.Multiaddr) bool

CanDial returns true if this transport believes it can dial the given multiaddr.

func (*I2PTransport) Close

func (i2p *I2PTransport) Close()

Closes all SAM sessions by closing the PRIMARY session

func (*I2PTransport) Dial

func (i2p *I2PTransport) Dial(ctx context.Context, remoteAddress ma.Multiaddr, peerID peer.ID) (transport.CapableConn, error)

func (*I2PTransport) Listen

func (i2p *I2PTransport) Listen(_ ma.Multiaddr) (transport.Listener, error)

input argument isn't used because we'll be listening on whichever destination is provided by i2p

func (*I2PTransport) Protocols

func (i2p *I2PTransport) Protocols() []int

Protocols returns the list of protocols this transport can dial.

func (*I2PTransport) Proxy

func (i2p *I2PTransport) Proxy() bool

Proxy always returns false for the I2P transport.

func (*I2PTransport) String

func (i2p *I2PTransport) String() string

type Option

type Option func(*I2PTransport) error

type TransportBuilderFunc

type TransportBuilderFunc = func(transport.Upgrader) (*I2PTransport, error)

func I2PTransportBuilder

func I2PTransportBuilder(sam *sam3.SAM,
	i2pKeys i2pkeys.I2PKeys, outboundPort string, rngSeed int) (TransportBuilderFunc, ma.Multiaddr, error)

returns a function that when called by go-libp2p, creates an I2PTransport Initializes SAM sessions/tunnel which can take about 4-25 seconds depending on i2p network conditions

type TransportListener

type TransportListener struct {
	// contains filtered or unexported fields
}

this struct only exists to satisfy the interface requirements for libp2p connection upgrader

func NewTransportListener

func NewTransportListener(streamListener *sam3.StreamListener) (*TransportListener, error)

func (*TransportListener) Accept

func (t *TransportListener) Accept() (manet.Conn, error)

func (*TransportListener) Addr

func (t *TransportListener) Addr() net.Addr

func (*TransportListener) Close

func (t *TransportListener) Close() error

func (*TransportListener) Multiaddr

func (t *TransportListener) Multiaddr() ma.Multiaddr

Jump to

Keyboard shortcuts

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