libp2pwebrtcdirect

package module
v0.0.0-...-3ebbb50 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2022 License: MIT Imports: 22 Imported by: 2

README

go-libp2p-webrtc-direct

GoDoc Coverage Status Build Status

A transport that enables browser-to-server, and server-to-server, direct communication over WebRTC without requiring signalling servers. This is the Go counterpart to js-libp2p-webrtc-direct.

⚠️ Status: Alpha. ⚠️

Lead maintainer: @backkem

Special thanks to @pion for their fantastic WebRTC Go library, which made this libp2p transport possible.

Install

This package supports gomod builds.

go get github.com/libp2p/go-libp2p-webrtc-direct

Usage

Check out the GoDocs.

Examples

Check the examples folder for usage and integration examples.

Contribute

Feel free to join in. All welcome. Open an issue or send a PR.

This repository falls under the IPFS Code of Conduct.

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

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

Conn is a stream-multiplexing connection to a remote peer.

func (*Conn) AcceptStream

func (c *Conn) AcceptStream() (smux.MuxedStream, error)

AcceptStream accepts a stream opened by the other side.

func (*Conn) Close

func (c *Conn) Close() error

Close closes the stream muxer and the the underlying net.Conn.

func (*Conn) IsClosed

func (c *Conn) IsClosed() bool

IsClosed returns whether a connection is fully closed, so it can be garbage collected.

func (*Conn) LocalMultiaddr

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

LocalMultiaddr returns the local Multiaddr associated with this connection

func (*Conn) LocalPeer

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

LocalPeer returns our peer ID

func (*Conn) LocalPrivateKey

func (c *Conn) LocalPrivateKey() ic.PrivKey

LocalPrivateKey returns our private key

func (*Conn) OpenStream

func (c *Conn) OpenStream(ctx context.Context) (smux.MuxedStream, error)

OpenStream creates a new stream.

func (*Conn) RemoteMultiaddr

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

RemoteMultiaddr returns the remote Multiaddr associated with this connection

func (*Conn) RemotePeer

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

RemotePeer returns the peer ID of the remote peer.

func (*Conn) RemotePublicKey

func (c *Conn) RemotePublicKey() ic.PubKey

RemotePublicKey returns the public key of the remote peer.

func (*Conn) Scope

func (c *Conn) Scope() smux.ConnScope

func (*Conn) Transport

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

Transport returns the transport to which this connection belongs.

type Listener

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

Listener is an interface closely resembling the net.Listener interface.

func (*Listener) Accept

func (l *Listener) Accept() (tpt.CapableConn, error)

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

func (*Listener) Addr

func (l *Listener) Addr() net.Addr

Addr returns the listener's network address.

func (*Listener) Close

func (l *Listener) Close() error

Close closes the listener. Any blocked Accept operations will be unblocked and return errors.

func (*Listener) Multiaddr

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

Multiaddr returns the listener's network Multi address.

type Stream

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

Stream is a bidirectional io pipe within a connection.

func (*Stream) Close

func (s *Stream) Close() error

Close closes the stream for writing. Reading will still work (that is, the remote side can still write).

func (*Stream) CloseRead

func (s *Stream) CloseRead() error

CloseRead closes the stream for writing. Reading will still work (that is, the remote side can still write).

func (*Stream) CloseWrite

func (s *Stream) CloseWrite() error

CloseWrite closes the stream for writing. Reading will still work (that is, the remote side can still write).

func (*Stream) Read

func (s *Stream) Read(p []byte) (int, error)

Read implements the io.Reader.

func (*Stream) Reset

func (s *Stream) Reset() error

Reset closes both ends of the stream. Use this to tell the remote side to hang up and go away.

func (*Stream) SetDeadline

func (s *Stream) SetDeadline(t time.Time) error

SetDeadline is a stub

func (*Stream) SetReadDeadline

func (s *Stream) SetReadDeadline(t time.Time) error

SetReadDeadline is a stub

func (*Stream) SetWriteDeadline

func (s *Stream) SetWriteDeadline(t time.Time) error

SetWriteDeadline is a stub

func (*Stream) Write

func (s *Stream) Write(p []byte) (int, error)

Write implements the io.Writer.

type Transport

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

Transport is the WebRTC transport.

func NewTransport

func NewTransport(webrtcOptions webrtc.Configuration, muxer smux.Multiplexer, rcmgr smux.ResourceManager) *Transport

NewTransport creates a WebRTC transport that signals over a direct HTTP connection. It is currently required to provide a muxer.

func (*Transport) CanDial

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

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

func (*Transport) Dial

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

Dial dials the peer at the remote address.

func (*Transport) Listen

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

Listen listens on the given multiaddr.

func (*Transport) Protocols

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

Protocols returns the list of terminal protocols this transport can dial.

func (*Transport) Proxy

func (t *Transport) Proxy() bool

Proxy always returns false for the TCP transport.

func (*Transport) String

func (t *Transport) String() string

Directories

Path Synopsis
examples
libp2p-echo Module
standalone Module

Jump to

Keyboard shortcuts

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