X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=wstracker.go;h=84af9cbfc18fc0de09a2fafd7199d7dec97f04ca;hb=HEAD;hp=431863a064bd0c9ee44a3a630659d25c0f79ba4e;hpb=3e0f34934df4f109b39b5e28e674b438732a7ab8;p=btrtrc.git diff --git a/wstracker.go b/wstracker.go index 431863a0..84af9cbf 100644 --- a/wstracker.go +++ b/wstracker.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "net" + netHttp "net/http" "net/url" "sync" @@ -12,7 +13,7 @@ import ( "github.com/pion/datachannel" "github.com/anacrolix/torrent/tracker" - "github.com/anacrolix/torrent/tracker/http" + httpTracker "github.com/anacrolix/torrent/tracker/http" "github.com/anacrolix/torrent/webtorrent" ) @@ -35,14 +36,16 @@ type refCountedWebtorrentTrackerClient struct { } type websocketTrackers struct { - PeerId [20]byte - Logger log.Logger - GetAnnounceRequest func(event tracker.AnnounceEvent, infoHash [20]byte) (tracker.AnnounceRequest, error) - OnConn func(datachannel.ReadWriteCloser, webtorrent.DataChannelContext) - mu sync.Mutex - clients map[string]*refCountedWebtorrentTrackerClient - Proxy http.ProxyFunc - DialContext func(ctx context.Context, network, addr string) (net.Conn, error) + PeerId [20]byte + Logger log.Logger + GetAnnounceRequest func(event tracker.AnnounceEvent, infoHash [20]byte) (tracker.AnnounceRequest, error) + OnConn func(datachannel.ReadWriteCloser, webtorrent.DataChannelContext) + mu sync.Mutex + clients map[string]*refCountedWebtorrentTrackerClient + Proxy httpTracker.ProxyFunc + DialContext func(ctx context.Context, network, addr string) (net.Conn, error) + WebsocketTrackerHttpHeader func() netHttp.Header + ICEServers []string } func (me *websocketTrackers) Get(url string, infoHash [20]byte) (*webtorrent.TrackerClient, func()) { @@ -61,6 +64,8 @@ func (me *websocketTrackers) Get(url string, infoHash [20]byte) (*webtorrent.Tra Logger: me.Logger.WithText(func(m log.Msg) string { return fmt.Sprintf("tracker client for %q: %v", url, m) }), + WebsocketTrackerHttpHeader: me.WebsocketTrackerHttpHeader, + ICEServers: me.ICEServers, }, } value.TrackerClient.Start(func(err error) {