"strings"
"time"
+ "github.com/davecgh/go-spew/spew"
+ "github.com/dustin/go-humanize"
+ gbtree "github.com/google/btree"
+ "github.com/pion/datachannel"
+ "golang.org/x/time/rate"
+
+ "github.com/anacrolix/chansync"
"github.com/anacrolix/chansync/events"
"github.com/anacrolix/dht/v2"
"github.com/anacrolix/dht/v2/krpc"
"github.com/anacrolix/generics"
+ . "github.com/anacrolix/generics"
"github.com/anacrolix/log"
"github.com/anacrolix/missinggo/perf"
"github.com/anacrolix/missinggo/v2"
"github.com/anacrolix/missinggo/v2/bitmap"
"github.com/anacrolix/missinggo/v2/pproffd"
"github.com/anacrolix/sync"
- request_strategy "github.com/anacrolix/torrent/request-strategy"
- "github.com/davecgh/go-spew/spew"
- "github.com/dustin/go-humanize"
- "github.com/google/btree"
- "github.com/pion/datachannel"
- "golang.org/x/time/rate"
-
- "github.com/anacrolix/chansync"
- . "github.com/anacrolix/generics"
"github.com/anacrolix/torrent/bencode"
"github.com/anacrolix/torrent/internal/limiter"
"github.com/anacrolix/torrent/metainfo"
"github.com/anacrolix/torrent/mse"
pp "github.com/anacrolix/torrent/peer_protocol"
+ request_strategy "github.com/anacrolix/torrent/request-strategy"
"github.com/anacrolix/torrent/storage"
"github.com/anacrolix/torrent/tracker"
"github.com/anacrolix/torrent/webtorrent"
w,
"%f%% of %d bytes (%s)",
100*(1-float64(t.bytesMissingLocked())/float64(t.info.TotalLength())),
- *t.length,
- humanize.Bytes(uint64(*t.length)))
+ t.length(),
+ humanize.Bytes(uint64(t.length())))
} else {
w.WriteString("<missing metainfo>")
}
cl.noLongerHalfOpen(t, addr.String())
if err != nil {
if cl.config.Debug {
- cl.logger.Printf("error establishing outgoing connection to %v: %v", addr, err)
+ cl.logger.Levelf(log.Debug, "error establishing outgoing connection to %v: %v", addr, err)
}
return
}
panic(p.updateRequestsTimer)
}
}
- p.updateRequestsTimer = time.AfterFunc(math.MaxInt64, p.updateRequestsTimerFunc)
+ if enableUpdateRequestsTimer {
+ p.updateRequestsTimer = time.AfterFunc(math.MaxInt64, p.updateRequestsTimerFunc)
+ }
}
const peerUpdateRequestsTimerReason = "updateRequestsTimer"
return false
}
+// Returns whether the IP address and port are considered "bad".
func (cl *Client) badPeerIPPort(ip net.IP, port int) bool {
- if port == 0 {
+ if port == 0 || ip == nil {
return true
}
if cl.dopplegangerAddr(net.JoinHostPort(ip.String(), strconv.FormatInt(int64(port), 10))) {
cl: cl,
infoHash: opts.InfoHash,
peers: prioritizedPeers{
- om: btree.New(32),
+ om: gbtree.New(32),
getPrio: func(p PeerInfo) peerPriority {
ipPort := p.addr()
return bep40PriorityIgnoreError(cl.publicAddr(ipPort.IP), ipPort)
defer cl.unlock()
t.initialPieceCheckDisabled = spec.DisableInitialPieceCheck
for _, url := range spec.Webseeds {
- t.addWebSeed(url, spec.DefaultWebseedEscapePath)
+ t.addWebSeed(url)
}
for _, peerAddr := range spec.PeerAddrs {
t.addPeer(PeerInfo{
connString: connString,
conn: nc,
}
+ c.initRequestState()
// TODO: Need to be much more explicit about this, including allowing non-IP bannable addresses.
if remoteAddr != nil {
netipAddrPort, err := netip.ParseAddrPort(remoteAddr.String())