From: afjoseph <7126721+afjoseph@users.noreply.github.com> Date: Fri, 29 Oct 2021 08:34:38 +0000 (+0200) Subject: fixup! [trackerscraper] Add custom DNS lookup function X-Git-Tag: v1.35.0~6 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=487352fa5bf3b3a404cac212bebb9d555dbe8c95;p=btrtrc.git fixup! [trackerscraper] Add custom DNS lookup function --- diff --git a/config.go b/config.go index 50c46afa..564149d3 100644 --- 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 diff --git a/torrent.go b/torrent.go index 8fa4c7de..93d7d5f4 100644 --- a/torrent.go +++ b/torrent.go @@ -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 diff --git a/tracker_scraper.go b/tracker_scraper.go index f9d37d86..d4bce60a 100644 --- a/tracker_scraper.go +++ b/tracker_scraper.go @@ -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())