Documentation
¶
Index ¶
- func FirstTCPAddr(h *Host) string
- func GenerateIdentityB64() (string, error)
- func PrivateKeyFromB64(encoded string) (crypto.PrivKey, error)
- type Host
- func (h *Host) AttachDiscovery(mgr *discovery.Manager)
- func (h *Host) Close() error
- func (h *Host) ConnectByAddr(ctx context.Context, addrStr string) (PeerInfo, error)
- func (h *Host) FindByNickname(ctx context.Context, nickname string) (peer.AddrInfo, error)
- func (h *Host) NicknameFor(id peer.ID) string
- func (h *Host) RememberNickname(id peer.ID, nickname string)
- func (h *Host) SendFrame(ctx context.Context, peerID peer.ID, frame proto.Frame) error
- func (h *Host) StartDHTDiscovery(ctx context.Context, mgr *discovery.Manager)
- func (h *Host) StartStreamHandler()
- type PeerInfo
- type WebRTCConn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FirstTCPAddr ¶
FirstTCPAddr returns the best TCP listen multiaddr of h (with peer ID appended). Prefers non-loopback addresses so the displayed address is reachable from other machines.
func GenerateIdentityB64 ¶
Types ¶
type Host ¶
type Host struct {
Libp2p host.Host
Nickname string
OnFrame func(peer.ID, proto.Frame)
OnFileStream func(peer.ID, proto.Frame, io.Reader)
OnConnected func(peer.ID)
OnLog func(string)
// contains filtered or unexported fields
}
func NewHostWithIdentity ¶
func (*Host) AttachDiscovery ¶
func (*Host) ConnectByAddr ¶
ConnectByAddr connects to a peer by full multiaddr string (e.g., /ip4/1.2.3.4/tcp/4001/p2p/QmXxx)
func (*Host) FindByNickname ¶ added in v0.2.8
FindByNickname searches the DHT for a peer advertising under the given nickname.
func (*Host) StartDHTDiscovery ¶
StartDHTDiscovery advertises on the DHT and periodically finds peers.
func (*Host) StartStreamHandler ¶
func (h *Host) StartStreamHandler()
StartStreamHandler registers the /bdpeer/1.0.0 stream handler.
type WebRTCConn ¶ added in v0.2.11
type WebRTCConn struct {
// contains filtered or unexported fields
}
WebRTCConn wraps a pion PeerConnection with a reliable data channel. It implements io.ReadWriteCloser so it can carry bdpeer protocol frames.
func NewWebRTCAnswer ¶ added in v0.2.11
NewWebRTCAnswer creates a peer connection from a remote offer and returns an SDP answer.
func NewWebRTCOffer ¶ added in v0.2.11
func NewWebRTCOffer(ctx context.Context) (*WebRTCConn, string, error)
NewWebRTCOffer creates a peer connection and returns an SDP offer string. Call SetAnswer with the remote answer to complete the handshake.
func (*WebRTCConn) Close ¶ added in v0.2.11
func (c *WebRTCConn) Close() error
func (*WebRTCConn) Connected ¶ added in v0.2.11
func (c *WebRTCConn) Connected() <-chan struct{}
Connected returns true once ICE connection is established.
func (*WebRTCConn) SetAnswer ¶ added in v0.2.11
func (c *WebRTCConn) SetAnswer(answerSDP string) error
SetAnswer completes the offer side handshake with the remote answer SDP.