cl.badPeerIPs = make(map[string]struct{})
}
cl.badPeerIPs[ip.String()] = struct{}{}
+ for _, t := range cl.torrents {
+ t.iterPeers(func(p *Peer) {
+ if p.remoteIp().Equal(ip) {
+ t.logger.Levelf(log.Warning, "dropping peer %v with banned ip %v", p, ip)
+ // Should this be a close?
+ p.drop()
+ }
+ })
+ }
}
func (cl *Client) newConnection(nc net.Conn, outgoing bool, remoteAddr PeerRemoteAddr, network, connString string) (c *PeerConn) {
EmptyAnnounceList bool `name:"n" help:"exclude default announce-list entries"`
Comment string `name:"t" help:"comment"`
CreatedBy string `name:"c" help:"created by"`
+ InfoName *string `name:"i" help:"override info name (defaults to ROOT)"`
+ Url []string `name:"u" help:"add webseed url"`
tagflag.StartPos
Root string
}
if len(args.CreatedBy) > 0 {
mi.CreatedBy = args.CreatedBy
}
+ mi.UrlList = args.Url
info := metainfo.Info{
PieceLength: 256 * 1024,
}
if err != nil {
log.Fatal(err)
}
+ if args.InfoName != nil {
+ info.Name = *args.InfoName
+ }
mi.InfoBytes, err = bencode.Marshal(info)
if err != nil {
log.Fatal(err)
github.com/anacrolix/envpprof v1.1.1
github.com/anacrolix/fuse v0.2.0
github.com/anacrolix/go-libutp v1.2.0
- github.com/anacrolix/log v0.10.1-0.20220123034749-3920702c17f8
+ github.com/anacrolix/log v0.13.1
github.com/anacrolix/missinggo v1.3.0
github.com/anacrolix/missinggo/perf v1.0.0
github.com/anacrolix/missinggo/v2 v2.5.2
github.com/anacrolix/log v0.8.0/go.mod h1:s5yBP/j046fm9odtUTbHOfDUq/zh1W8OkPpJtnX0oQI=
github.com/anacrolix/log v0.9.0/go.mod h1:s5yBP/j046fm9odtUTbHOfDUq/zh1W8OkPpJtnX0oQI=
github.com/anacrolix/log v0.10.0/go.mod h1:s5yBP/j046fm9odtUTbHOfDUq/zh1W8OkPpJtnX0oQI=
-github.com/anacrolix/log v0.10.1-0.20220123034749-3920702c17f8 h1:o1KNFCLJ6f5SRMVb70SUFiPnNiazVd0gpMxYfYCsvK4=
github.com/anacrolix/log v0.10.1-0.20220123034749-3920702c17f8/go.mod h1:GmnE2c0nvz8pOIPUSC9Rawgefy1sDXqposC2wgtBZE4=
+github.com/anacrolix/log v0.13.1 h1:BmVwTdxHd5VcNrLylgKwph4P4wf+5VvPgOK4yi91fTY=
+github.com/anacrolix/log v0.13.1/go.mod h1:D4+CvN8SnruK6zIFS/xPoRJmtvtnxs+CSfDQ+BFxZ68=
github.com/anacrolix/lsan v0.0.0-20211126052245-807000409a62 h1:P04VG6Td13FHMgS5ZBcJX23NPC/fiC4cp9bXwYujdYM=
github.com/anacrolix/lsan v0.0.0-20211126052245-807000409a62/go.mod h1:66cFKPCO7Sl4vbFnAaSq7e4OXtdMhRSBagJGWgmpJbM=
github.com/anacrolix/missinggo v0.0.0-20180522035225-b4a5853e62ff/go.mod h1:b0p+7cn+rWMIphK1gDH2hrDuwGOcbB6V4VXeSsEfHVk=
connectionFlags() string
onClose()
onGotInfo(*metainfo.Info)
+ // Drop connection. This may be a no-op if there is no connection.
drop()
+ // Rebuke the peer
+ ban()
String() string
connStatusString() string
cn.t.dropConnection(cn)
}
+func (cn *PeerConn) ban() {
+ cn.t.cl.banPeerIP(cn.remoteIp())
+}
+
func (cn *Peer) netGoodPiecesDirtied() int64 {
return cn._stats.PiecesDirtiedGood.Int64() - cn._stats.PiecesDirtiedBad.Int64()
}
if len(bannableTouchers) >= 1 {
c := bannableTouchers[0]
- t.cl.banPeerIP(c.remoteIp())
- c.drop()
+ c.ban()
}
}
t.onIncompletePiece(piece)
return &t.cl.config.Callbacks
}
+func (t *Torrent) AddWebSeeds(urls []string) {
+ t.cl.lock()
+ defer t.cl.unlock()
+ for _, u := range urls {
+ t.addWebSeed(u)
+ }
+}
+
func (t *Torrent) addWebSeed(url string) {
if t.cl.config.DisableWebseeds {
return
return "WS"
}
-// TODO: This is called when banning peers. Perhaps we want to be able to ban webseeds too. We could
-// return bool if this is even possible, and if it isn't, skip to the next drop candidate.
+// Maybe this should drop all existing connections, or something like that.
func (ws *webseedPeer) drop() {}
+func (cn *webseedPeer) ban() {
+ cn.peer.close()
+}
+
func (ws *webseedPeer) handleUpdateRequests() {
// Because this is synchronous, webseed peers seem to get first dibs on newly prioritized
// pieces.
"a_1-b_c2/d 3. (e, f).g",
)
}
+
+func TestTrailingPathForEmptyInfoName(t *testing.T) {
+ qt.Check(t, trailingPath("", []string{`ノ┬─┬ノ ︵ ( \o°o)\`}), qt.Equals, "%E3%83%8E%E2%94%AC%E2%94%80%E2%94%AC%E3%83%8E+%EF%B8%B5+%28+%5Co%C2%B0o%29%5C")
+ qt.Check(t, trailingPath("", []string{"hello", "world"}), qt.Equals, "hello/world")
+ qt.Check(t, trailingPath("war", []string{"and", "peace"}), qt.Equals, "war/and/peace")
+}