webtorrent

package
v1.58.1 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2025 License: MPL-2.0, MIT Imports: 25 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPeerConnStats added in v1.58.0

func GetPeerConnStats(pc *wrappedPeerConnection) (stats webrtc.StatsReport)

Types

type AnnounceRequest

type AnnounceRequest struct {
	Numwant    int     `json:"numwant"`
	Uploaded   int64   `json:"uploaded"`
	Downloaded int64   `json:"downloaded"`
	Left       int64   `json:"left"`
	Event      string  `json:"event,omitempty"`
	Action     string  `json:"action"`
	InfoHash   string  `json:"info_hash"`
	PeerID     string  `json:"peer_id"`
	Offers     []Offer `json:"offers"`
}

type AnnounceResponse

type AnnounceResponse struct {
	InfoHash   string                     `json:"info_hash"`
	Action     string                     `json:"action"`
	Interval   *int                       `json:"interval,omitempty"`
	Complete   *int                       `json:"complete,omitempty"`
	Incomplete *int                       `json:"incomplete,omitempty"`
	PeerID     string                     `json:"peer_id,omitempty"`
	ToPeerID   string                     `json:"to_peer_id,omitempty"`
	Answer     *webrtc.SessionDescription `json:"answer,omitempty"`
	Offer      *webrtc.SessionDescription `json:"offer,omitempty"`
	OfferID    string                     `json:"offer_id,omitempty"`
}

type DataChannelConn added in v1.58.0

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

WebRTC data channel wrapper that supports operating as a peer conn ReadWriteCloser.

func (DataChannelConn) Close added in v1.58.0

func (me DataChannelConn) Close() error

func (DataChannelConn) Read added in v1.58.0

func (d DataChannelConn) Read(p []byte) (int, error)

func (DataChannelConn) Write added in v1.58.0

func (d DataChannelConn) Write(p []byte) (n int, err error)

type DataChannelContext

type DataChannelContext struct {
	OfferId      string
	LocalOffered bool
	InfoHash     [20]byte

	Span    trace.Span
	Context context.Context
	// contains filtered or unexported fields
}

func (*DataChannelContext) GetSelectedIceCandidatePair added in v1.41.0

func (me *DataChannelContext) GetSelectedIceCandidatePair() (*webrtc.ICECandidatePair, error)

type Offer

type Offer struct {
	OfferID string                    `json:"offer_id"`
	Offer   webrtc.SessionDescription `json:"offer"`
}

type TrackerClient

type TrackerClient struct {
	Url                string
	GetAnnounceRequest func(_ tracker.AnnounceEvent, infoHash [20]byte) (tracker.AnnounceRequest, error)
	PeerId             [20]byte
	OnConn             onDataChannelOpen
	Logger             log.Logger
	Dialer             *websocket.Dialer

	WebsocketTrackerHttpHeader func() http.Header
	ICEServers                 []webrtc.ICEServer
	// contains filtered or unexported fields
}

Client represents the webtorrent client

func (*TrackerClient) Announce

func (tc *TrackerClient) Announce(event tracker.AnnounceEvent, infoHash [20]byte) error

func (*TrackerClient) Close

func (tc *TrackerClient) Close() error

func (*TrackerClient) CloseOffersForInfohash added in v1.47.0

func (tc *TrackerClient) CloseOffersForInfohash(infoHash [20]byte)

func (*TrackerClient) RtcPeerConnStats added in v1.58.0

func (tc *TrackerClient) RtcPeerConnStats() map[string]webrtc.StatsReport

Calculate the stats for all the peer connections the moment they are requested. As the stats will change over the life of a peer connection, this ensures that the updated values are returned.

func (*TrackerClient) Start added in v1.34.0

func (tc *TrackerClient) Start(onStop func(error))

Finishes initialization and spawns the run routine, calling onStop when it completes with the result. We don't let the caller just spawn the runner directly, since then we can race against .Close to finish initialization.

func (*TrackerClient) Stats

func (me *TrackerClient) Stats() TrackerClientStats

type TrackerClientStats

type TrackerClientStats struct {
	Dials                  int64
	ConvertedInboundConns  int64
	ConvertedOutboundConns int64
}

Jump to

Keyboard shortcuts

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