Improve cmd/tracker-announce output
This commit is contained in:
parent
e33d773391
commit
a1a715f362
|
@ -1,6 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
|
@ -8,8 +9,6 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
|
||||||
"github.com/davecgh/go-spew/spew"
|
|
||||||
|
|
||||||
"github.com/anacrolix/tagflag"
|
"github.com/anacrolix/tagflag"
|
||||||
|
|
||||||
"github.com/anacrolix/torrent"
|
"github.com/anacrolix/torrent"
|
||||||
|
@ -76,7 +75,7 @@ func doTracker(tURI string, ar tracker.AnnounceRequest) (hadError bool) {
|
||||||
log.Printf("error announcing to %q: %s", tURI, err)
|
log.Printf("error announcing to %q: %s", tURI, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
spew.Dump(resp)
|
fmt.Printf("response from %q: %+v\n", tURI, resp)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package tracker
|
package tracker
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
"github.com/anacrolix/dht/v2/krpc"
|
"github.com/anacrolix/dht/v2/krpc"
|
||||||
|
@ -12,6 +13,15 @@ type Peer struct {
|
||||||
ID []byte
|
ID []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p Peer) String() string {
|
||||||
|
loc := net.JoinHostPort(p.IP.String(), fmt.Sprintf("%d", p.Port))
|
||||||
|
if len(p.ID) != 0 {
|
||||||
|
return fmt.Sprintf("%x at %s", p.ID, loc)
|
||||||
|
} else {
|
||||||
|
return loc
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Set from the non-compact form in BEP 3.
|
// Set from the non-compact form in BEP 3.
|
||||||
func (p *Peer) FromDictInterface(d map[string]interface{}) {
|
func (p *Peer) FromDictInterface(d map[string]interface{}) {
|
||||||
p.IP = net.ParseIP(d["ip"].(string))
|
p.IP = net.ParseIP(d["ip"].(string))
|
||||||
|
|
Loading…
Reference in New Issue