Documentation
¶
Overview ¶
Package wgtransport implements a Webmesh WireGuard transport for libp2p.
Index ¶
- func NewOptions(log *slog.Logger) libp2p.Option
- type Conn
- type Constructor
- type Listener
- type SecureConn
- type SecureTransport
- type Transport
- func (t *Transport) CanDial(addr ma.Multiaddr) bool
- func (t *Transport) Close() error
- func (t *Transport) Dial(ctx context.Context, rmaddr ma.Multiaddr, p peer.ID) (transport.CapableConn, error)
- func (t *Transport) Listen(laddr ma.Multiaddr) (transport.Listener, error)
- func (t *Transport) Protocols() []int
- func (t *Transport) Proxy() bool
- func (t *Transport) WireGuardEndpoints() []string
- func (t *Transport) WrapConn(c mnet.Conn) *Conn
- func (t *Transport) WrapListener(l mnet.Listener) *Listener
- type WireGuardTransport
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Conn ¶
Conn wraps the basic net.Conn with a reference back to the underlying transport.
func (*Conn) Context ¶ added in v0.6.3
Context returns a context that contains the logger tied to this connection
func (*Conn) LocalMultiaddr ¶ added in v0.6.3
func (*Conn) RemoteMultiaddr ¶ added in v0.6.3
type Constructor ¶
type Constructor func(tu transport.Upgrader, host host.Host, key crypto.PrivKey, psk pnet.PSK, gater connmgr.ConnectionGater, rcmgr network.ResourceManager) (WireGuardTransport, error)
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
Listener wraps a basic listener to be upgraded and injects the transport into incoming connections.
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 ¶
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) Dial ¶
func (t *Transport) Dial(ctx context.Context, rmaddr ma.Multiaddr, p peer.ID) (transport.CapableConn, error)
Dial dials the given multiaddr.
func (*Transport) WireGuardEndpoints ¶
WireGuardEndpoints returns the exposed endpoints for our wireguard interface.
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.