cmd/torrent: Add flags -disableTrackers and -seed

This commit is contained in:
Matt Joiner 2014-05-21 17:38:09 +10:00
parent 99b7ef4e42
commit 2e4629abbc
1 changed files with 9 additions and 3 deletions

View File

@ -19,7 +19,9 @@ var (
testPeer = flag.String("testPeer", "", "bootstrap peer address")
profAddr = flag.String("profAddr", "", "http serve address")
// TODO: Check the default torrent listen port.
listenAddr = flag.String("listenAddr", ":6882", "incoming connection address")
listenAddr = flag.String("listenAddr", ":6882", "incoming connection address")
disableTrackers = flag.Bool("disableTrackers", false, "disable trackers")
seed = flag.Bool("seed", false, "seed after downloading")
)
func init() {
@ -40,8 +42,9 @@ func main() {
go http.ListenAndServe(*profAddr, nil)
}
client := torrent.Client{
DataDir: *downloadDir,
Listener: makeListener(),
DataDir: *downloadDir,
Listener: makeListener(),
DisableTrackers: *disableTrackers,
}
client.Start()
defer client.Stop()
@ -76,6 +79,9 @@ func main() {
log.Fatal(err)
}
}
if *seed {
select {}
}
if client.WaitAll() {
log.Print("all torrents completed!")
} else {