From 489d7e8e45dbfae9a1ae0749aa595d45c50c6b17 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Thu, 22 Feb 2024 17:27:18 +1100 Subject: [PATCH] Add test case from issue #906 --- internal/cmd/issue-906/main.go | 39 ++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 internal/cmd/issue-906/main.go diff --git a/internal/cmd/issue-906/main.go b/internal/cmd/issue-906/main.go new file mode 100644 index 00000000..7c3bdc17 --- /dev/null +++ b/internal/cmd/issue-906/main.go @@ -0,0 +1,39 @@ +package main + +import ( + "log" + "net/http" + "os" + + _ "github.com/anacrolix/envpprof" + "github.com/anacrolix/torrent" +) + +func main() { + cfg := torrent.NewDefaultClientConfig() + cfg.Debug = true + cfg.DisablePEX = true + cfg.DisableTrackers = true + cfg.NoDHT = true + cfg.NoDefaultPortForwarding = true + + c, _ := torrent.NewClient(cfg) + defer c.Close() + http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + c.WriteStatus(w) + }) + torrentFile := os.Args[1] + peerAddr := os.Args[2] + t, _ := c.AddTorrentFromFile(torrentFile) + println(t.AddPeers([]torrent.PeerInfo{{Addr: addr(peerAddr)}})) + <-t.GotInfo() + t.DownloadAll() + c.WaitAll() + log.Print("ermahgerd, torrent downloaded") +} + +type addr string + +func (a addr) String() string { + return string(a) +} -- 2.48.1