]> Sergey Matveev's repositories - btrtrc.git/commitdiff
cmd/torrent: Make the addr flag a string
authorMatt Joiner <anacrolix@gmail.com>
Fri, 3 Jan 2020 03:51:18 +0000 (14:51 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Fri, 3 Jan 2020 03:51:26 +0000 (14:51 +1100)
This avoids tagflag trying to resolve it, and then passing a bad IP for different listen networks. There's also a patch to tagflag so it doesn't do this anymore.

cmd/torrent/main.go

index 03582ab6782fd502342b5018726bcde89d07e0c2..7cf6a2554cddd6c98682e393379b9978aa9720e0 100644 (file)
@@ -131,7 +131,7 @@ var flags = struct {
        Mmap            bool           `help:"memory-map torrent data"`
        TestPeer        []*net.TCPAddr `help:"addresses of some starting peers"`
        Seed            bool           `help:"seed after download is complete"`
-       Addr            *net.TCPAddr   `help:"network listen addr"`
+       Addr            string         `help:"network listen addr"`
        UploadRate      tagflag.Bytes  `help:"max piece bytes to send per second"`
        DownloadRate    tagflag.Bytes  `help:"max bytes per second down from peers"`
        Debug           bool
@@ -199,8 +199,8 @@ func mainErr() error {
        if flags.Mmap {
                clientConfig.DefaultStorage = storage.NewMMap("")
        }
-       if flags.Addr != nil {
-               clientConfig.SetListenAddr(flags.Addr.String())
+       if flags.Addr != "" {
+               clientConfig.SetListenAddr(flags.Addr)
        }
        if flags.UploadRate != -1 {
                clientConfig.UploadRateLimiter = rate.NewLimiter(rate.Limit(flags.UploadRate), 256<<10)