diff --git a/client.go b/client.go index 3f126c842a..9001fce1f9 100644 --- a/client.go +++ b/client.go @@ -313,12 +313,7 @@ func NewClient(cfg *ClientConfig) (cl *Client, err error) { } } - var obs *webtorrent.TrackerObserver - if cl.config.Observers != nil { - obs = &cl.config.Observers.Trackers - } cl.websocketTrackers = websocketTrackers{ - obs: obs, PeerId: cl.peerID, Logger: cl.logger.WithNames("websocketTrackers"), GetAnnounceRequest: func( @@ -749,10 +744,6 @@ func doProtocolHandshakeOnDialResult( nc := dr.Conn addrIpPort, _ := tryIpPortFromNetAddr(addr) - var obs *PeerObserver - if t.cl.config.Observers != nil { - obs = &t.cl.config.Observers.Peers - } c, err = cl.initiateProtocolHandshakes( context.Background(), nc, t, obfuscatedHeader, newConnectionOpts{ @@ -762,7 +753,6 @@ func doProtocolHandshakeOnDialResult( localPublicAddr: cl.publicAddr(addrIpPort.IP), network: dr.Dialer.DialerNetwork(), connString: regularNetConnPeerConnConnString(nc), - obs: obs, }) if err != nil { nc.Close() @@ -1666,7 +1656,6 @@ type newConnectionOpts struct { localPublicAddr peerLocalPublicAddr network string connString string - obs *PeerObserver } func (cl *Client) newConnection(nc net.Conn, opts newConnectionOpts) (c *PeerConn) { @@ -1687,7 +1676,6 @@ func (cl *Client) newConnection(nc net.Conn, opts newConnectionOpts) (c *PeerCon }, connString: opts.connString, conn: nc, - Observers: opts.obs, } c.peerRequestDataAllocLimiter.Max = cl.config.MaxAllocPeerRequestDataPerConn c.initRequestState() diff --git a/config.go b/config.go index 7fdd89f450..76979463cc 100644 --- a/config.go +++ b/config.go @@ -7,8 +7,6 @@ import ( "net/url" "time" - "github.com/anacrolix/torrent/webtorrent" - "github.com/anacrolix/dht/v2" "github.com/anacrolix/dht/v2/krpc" "github.com/anacrolix/log" @@ -22,23 +20,6 @@ import ( "github.com/anacrolix/torrent/version" ) -type Observers struct { - Trackers webtorrent.TrackerObserver - Peers PeerObserver -} - -func NewClientObservers() *Observers { - return &Observers{ - Trackers: webtorrent.TrackerObserver{ - ConnStatus: make(chan webtorrent.TrackerStatus), - AnnounceStatus: make(chan webtorrent.AnnounceStatus), - }, - Peers: PeerObserver{ - PeerStatus: make(chan PeerStatus), - }, - } -} - // Contains config elements that are exclusive to tracker handling. There may be other fields in // ClientConfig that are also relevant. type ClientTrackerConfig struct { @@ -51,7 +32,6 @@ type ClientTrackerConfig struct { // Takes a tracker's hostname and requests DNS A and AAAA records. // Used in case DNS lookups require a special setup (i.e., dns-over-https) LookupTrackerIp func(*url.URL) ([]net.IP, error) - Observers *Observers } type ClientDhtConfig struct { diff --git a/peerconn.go b/peerconn.go index 96664d36c0..ad069a293d 100644 --- a/peerconn.go +++ b/peerconn.go @@ -38,10 +38,6 @@ type PeerStatus struct { Err string // see https://github.com/golang/go/issues/5161 } -type PeerObserver struct { - PeerStatus chan PeerStatus -} - // Maintains the state of a BitTorrent-protocol based connection with a peer. type PeerConn struct { Peer @@ -100,7 +96,6 @@ type PeerConn struct { // we can verify all the pieces for a file when they're all arrived before submitting them to // the torrent. receivedHashPieces map[[32]byte][][32]byte - Observers *PeerObserver } func (cn *PeerConn) pexStatus() string { diff --git a/torrent.go b/torrent.go index 58dc2db802..8f7e41fa24 100644 --- a/torrent.go +++ b/torrent.go @@ -1874,11 +1874,6 @@ func (t *Torrent) onWebRtcConn( } localAddrIpPort := missinggo.IpPortFromNetAddr(netConn.LocalAddr()) - var obs *PeerObserver - if t.cl.config.Observers != nil { - obs = &t.cl.config.Observers.Peers - } - pc, err := t.cl.initiateProtocolHandshakes( context.Background(), netConn, @@ -1890,7 +1885,6 @@ func (t *Torrent) onWebRtcConn( localPublicAddr: localAddrIpPort, network: webrtcNetwork, connString: fmt.Sprintf("webrtc offer_id %x: %v", dcc.OfferId, regularNetConnPeerConnConnString(netConn)), - obs: obs, }, ) if err != nil { diff --git a/webtorrent/tracker-client.go b/webtorrent/tracker-client.go index 0a862794ef..cf02b629b5 100644 --- a/webtorrent/tracker-client.go +++ b/webtorrent/tracker-client.go @@ -19,23 +19,6 @@ import ( "github.com/anacrolix/torrent/types/infohash" ) -type TrackerStatus struct { - Url string `json:"url"` - Ok bool `json:"ok"` - Err error `json:"err"` -} - -type AnnounceStatus struct { - TrackerStatus - Event string `json:"event"` - InfoHash string `json:"info_hash"` -} - -type TrackerObserver struct { - ConnStatus chan TrackerStatus - AnnounceStatus chan AnnounceStatus -} - type TrackerClientStats struct { Dials int64 ConvertedInboundConns int64 @@ -50,7 +33,6 @@ type TrackerClient struct { OnConn onDataChannelOpen Logger log.Logger Dialer *websocket.Dialer - Observers *TrackerObserver mu sync.Mutex cond sync.Cond diff --git a/wstracker.go b/wstracker.go index a8e1d8603e..ed5526db15 100644 --- a/wstracker.go +++ b/wstracker.go @@ -46,7 +46,6 @@ type websocketTrackers struct { OnConn func(webtorrent.DataChannelConn, webtorrent.DataChannelContext) mu sync.Mutex clients map[string]*refCountedWebtorrentTrackerClient - obs *webtorrent.TrackerObserver Proxy httpTracker.ProxyFunc DialContext func(ctx context.Context, network, addr string) (net.Conn, error) WebsocketTrackerHttpHeader func() netHttp.Header @@ -66,8 +65,6 @@ func (me *websocketTrackers) Get(url string, infoHash [20]byte) (*webtorrent.Tra } value = &refCountedWebtorrentTrackerClient{ TrackerClient: webtorrent.TrackerClient{ - // TODO pass in callbacks rather than observers - Observers: me.obs, Dialer: dialer, Url: url, GetAnnounceRequest: me.GetAnnounceRequest,