]> Sergey Matveev's repositories - btrtrc.git/commitdiff
fixup! [trackerscraper] Add custom DNS lookup function
authorafjoseph <7126721+afjoseph@users.noreply.github.com>
Fri, 29 Oct 2021 08:34:38 +0000 (10:34 +0200)
committerMatt Joiner <anacrolix@gmail.com>
Mon, 1 Nov 2021 00:26:58 +0000 (11:26 +1100)
config.go
torrent.go
tracker_scraper.go

index 50c46afa06f43da62124152224cc6c5f17692753..564149d31545cb2f2499d57690ed9f94f2769d85 100644 (file)
--- a/config.go
+++ b/config.go
@@ -92,7 +92,7 @@ type ClientConfig struct {
        HTTPProxy func(*http.Request) (*url.URL, error)
        // 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)
-       TrackerIpFetcher func(*url.URL) ([]net.IP, error)
+       LookupTrackerIp func(*url.URL) ([]net.IP, error)
        // HTTPUserAgent changes default UserAgent for HTTP requests
        HTTPUserAgent string
        // Updated occasionally to when there's been some changes to client
index 8fa4c7deee61052f35cbff494c681d5318cdd637..93d7d5f4a5795155adf548a71cc7dea7d634fd05 100644 (file)
@@ -1577,9 +1577,9 @@ func (t *Torrent) startScrapingTracker(_url string) {
                        }
                }
                newAnnouncer := &trackerScraper{
-                       u:         *u,
-                       t:         t,
-                       ipFetcher: t.cl.config.TrackerIpFetcher,
+                       u:               *u,
+                       t:               t,
+                       lookupTrackerIp: t.cl.config.LookupTrackerIp,
                }
                go newAnnouncer.Run()
                return newAnnouncer
index f9d37d86586eb5425601208b50aa39dcf851fd89..d4bce60a8552ff3d4ff5ef5ebd8bfca7fe2a3ff6 100644 (file)
@@ -18,10 +18,10 @@ import (
 // Announces a torrent to a tracker at regular intervals, when peers are
 // required.
 type trackerScraper struct {
-       u            url.URL
-       t            *Torrent
-       lastAnnounce trackerAnnounceResult
-       ipFetcher    func(*url.URL) ([]net.IP, error)
+       u               url.URL
+       t               *Torrent
+       lastAnnounce    trackerAnnounceResult
+       lookupTrackerIp func(*url.URL) ([]net.IP, error)
 }
 
 type torrentTrackerAnnouncer interface {
@@ -68,8 +68,8 @@ type trackerAnnounceResult struct {
 
 func (me *trackerScraper) getIp() (ip net.IP, err error) {
        var ips []net.IP
-       if me.ipFetcher != nil {
-               ips, err = me.ipFetcher(&me.u)
+       if me.lookupTrackerIp != nil {
+               ips, err = me.lookupTrackerIp(&me.u)
        } else {
                // Do a regular dns lookup
                ips, err = net.LookupIP(me.u.Hostname())