Created
January 19, 2020 22:14
-
-
Save tab1293/7c1abeec7dd09b7ccac8ed70d45bdde5 to your computer and use it in GitHub Desktop.
Anacrolix torrent panic with SOCKS 5 proxy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "log" | |
| "github.com/anacrolix/torrent" | |
| ) | |
| func main() { | |
| cfg := torrent.NewDefaultClientConfig() | |
| cfg.Debug = true | |
| // Bump these two values to be some high value | |
| cfg.EstablishedConnsPerTorrent = 500 | |
| cfg.HalfOpenConnsPerTorrent = 500 | |
| // Set your proxy URL | |
| cfg.ProxyURL = "socks5://localhost:1080" | |
| c, err := torrent.NewClient(cfg) | |
| defer c.Close() | |
| if err != nil { | |
| log.Fatalf("error creating torrent client: %s", err) | |
| } | |
| // Add Big Buck Bunny magnet link | |
| t, _ := c.AddMagnet("magnet:?xt=urn:btih:dd8255ecdc7ca55fb0bbf81323d87062db1f6d1c&dn=Big+Buck+Bunny&tr=udp%3A%2F%2Fexplodie.org%3A6969&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.empire-js.us%3A1337&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&ws=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2F&xs=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2Fbig-buck-bunny.torrent") | |
| log.Printf("fetching torrent info %s\n", t.InfoHash().String()) | |
| <-t.GotInfo() | |
| log.Printf("fetched torrent info hash: %s length: %d num pieces: %d piece length: %d", t.InfoHash().String(), t.Info().TotalLength(), t.Info().NumPieces(), t.Info().PieceLength) | |
| t.DownloadAll() | |
| c.WaitAll() | |
| log.Printf("torrent download complete") | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment