wgtransport

package
v0.12.2 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Overview

Package wgtransport implements a Webmesh WireGuard transport for libp2p.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewOptions

func NewOptions(log *slog.Logger) libp2p.Option

NewOptions returns a chained option for all the components of a webmesh transport.

Types

type Conn

type Conn struct {
	mnet.Conn
	// contains filtered or unexported fields
}

Conn wraps the basic net.Conn with a reference back to the underlying transport.

func (*Conn) Context added in v0.6.3

func (w *Conn) Context() context.Context

Context returns a context that contains the logger tied to this connection

func (*Conn) LocalMultiaddr added in v0.6.3

func (w *Conn) LocalMultiaddr() ma.Multiaddr

func (*Conn) RemoteMultiaddr added in v0.6.3

func (w *Conn) RemoteMultiaddr() ma.Multiaddr

type Constructor

Constructor is the constructor for the webmesh transport.

func NewWithLogger

func NewWithLogger(log *slog.Logger) Constructor

NewWithLogger returns a new constructor for a webmesh transport using the given logger.

type Listener added in v0.6.3

type Listener struct {
	mnet.Listener
	// contains filtered or unexported fields
}

Listener wraps a basic listener to be upgraded and injects the transport into incoming connections.

func (*Listener) Accept added in v0.6.3

func (ln *Listener) Accept() (mnet.Conn, error)

Accept waits for and returns the next connection to the listener.

func (*Listener) Multiaddr added in v0.6.3

func (ln *Listener) Multiaddr() ma.Multiaddr

type SecureConn

type SecureConn struct {
	*Conn
	// contains filtered or unexported fields
}

SecureConn is a simple wrapper around the underlying connection that holds remote peer information.

func NewSecureConn added in v0.6.3

func NewSecureConn(ctx context.Context, insecure *Conn, rpeer peer.ID, psk pnet.PSK, dir network.Direction) (*SecureConn, error)

NewSecureConn upgrades an insecure connection with peer identity.

func (*SecureConn) ConnState

func (c *SecureConn) ConnState() network.ConnectionState

ConnState returns information about the connection state.

func (*SecureConn) LocalPeer

func (c *SecureConn) LocalPeer() peer.ID

LocalPeer returns our peer ID

func (*SecureConn) RemotePeer

func (c *SecureConn) RemotePeer() peer.ID

RemotePeer returns the peer ID of the remote peer.

func (*SecureConn) RemotePublicKey

func (c *SecureConn) RemotePublicKey() crypto.PubKey

RemotePublicKey returns the public key of the remote peer.

type SecureTransport

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

SecureTransport provides a sec.SecureTransport that will automatically set up routes and compute addresses for peers as connections are opened.

func NewSecurity

func NewSecurity(id protocol.ID, host host.Host, psk pnet.PSK, privkey crypto.PrivKey) (*SecureTransport, error)

New is a standalone constructor for SecureTransport.

func (*SecureTransport) ID

func (st *SecureTransport) ID() protocol.ID

ID is the protocol ID of the security protocol.

func (*SecureTransport) SecureInbound

func (st *SecureTransport) SecureInbound(ctx context.Context, insecure net.Conn, p peer.ID) (sec.SecureConn, error)

SecureInbound secures an inbound connection. If p is empty, connections from any peer are accepted.

func (*SecureTransport) SecureOutbound

func (st *SecureTransport) SecureOutbound(ctx context.Context, insecure net.Conn, p peer.ID) (sec.SecureConn, error)

SecureOutbound secures an outbound connection.

type Transport

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

Transport is the webmesh wireguard transport.

func (*Transport) CanDial

func (t *Transport) CanDial(addr ma.Multiaddr) bool

CanDial returns true if this transport knows how to dial the given multiaddr.

Returning true does not guarantee that dialing this multiaddr will succeed. This function should *only* be used to preemptively filter out addresses that we can't dial.

func (*Transport) Close

func (t *Transport) Close() error

Close shuts down the wireguard interface.

func (*Transport) Dial

func (t *Transport) Dial(ctx context.Context, rmaddr ma.Multiaddr, p peer.ID) (transport.CapableConn, error)

Dial dials the given multiaddr.

func (*Transport) Listen

func (t *Transport) Listen(laddr ma.Multiaddr) (transport.Listener, error)

Listen listens on the passed multiaddr.

func (*Transport) Protocols

func (t *Transport) Protocols() []int

Protocol returns the set of protocols handled by this transport.

func (*Transport) Proxy

func (t *Transport) Proxy() bool

Proxy returns true if this is a proxy transport.

func (*Transport) WireGuardEndpoints

func (t *Transport) WireGuardEndpoints() []string

WireGuardEndpoints returns the exposed endpoints for our wireguard interface.

func (*Transport) WrapConn

func (t *Transport) WrapConn(c mnet.Conn) *Conn

func (*Transport) WrapListener

func (t *Transport) WrapListener(l mnet.Listener) *Listener

type WireGuardTransport added in v0.6.3

type WireGuardTransport interface {
	// Closer for the underlying transport that shuts down the webmesh node.
	io.Closer
	// Transport is the underlying libp2p Transport.
	transport.Transport
}

WireGuardTransport is the webmesh wireguard transport. This transport does not run a full mesh node, but rather utilizes libp2p streams to perform an authenticated keypair negotiation to compute IPv6 addresses for peers.

func New

New is the standard constructor for a webmesh transport.

Jump to

Keyboard shortcuts

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