Remove unused code
This commit is contained in:
parent
33006eeb20
commit
3ba991e38a
26
client.go
26
client.go
|
@ -308,15 +308,6 @@ func (cl *Client) newDhtServer(conn net.PacketConn) (s *dht.Server, err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func firstNonEmptyString(ss ...string) string {
|
|
||||||
for _, s := range ss {
|
|
||||||
if s != "" {
|
|
||||||
return s
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (cl *Client) Closed() <-chan struct{} {
|
func (cl *Client) Closed() <-chan struct{} {
|
||||||
cl.lock()
|
cl.lock()
|
||||||
defer cl.unlock()
|
defer cl.unlock()
|
||||||
|
@ -490,23 +481,6 @@ func (cl *Client) dopplegangerAddr(addr string) bool {
|
||||||
return ok
|
return ok
|
||||||
}
|
}
|
||||||
|
|
||||||
func ipNetworkSuffix(allowIpv4, allowIpv6 bool) string {
|
|
||||||
switch {
|
|
||||||
case allowIpv4 && allowIpv6:
|
|
||||||
return ""
|
|
||||||
case allowIpv4 && !allowIpv6:
|
|
||||||
return "4"
|
|
||||||
case !allowIpv4 && allowIpv6:
|
|
||||||
return "6"
|
|
||||||
default:
|
|
||||||
panic("unhandled ip network combination")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func dialUTP(ctx context.Context, addr string, sock utpSocket) (c net.Conn, err error) {
|
|
||||||
return sock.DialContext(ctx, "", addr)
|
|
||||||
}
|
|
||||||
|
|
||||||
var allPeerNetworks = []string{"tcp4", "tcp6", "udp4", "udp6"}
|
var allPeerNetworks = []string{"tcp4", "tcp6", "udp4", "udp6"}
|
||||||
|
|
||||||
func peerNetworkEnabled(network string, cfg *ClientConfig) bool {
|
func peerNetworkEnabled(network string, cfg *ClientConfig) bool {
|
||||||
|
|
4
file.go
4
file.go
|
@ -91,10 +91,6 @@ func byteRegionExclusivePieces(off, size, pieceSize int64) (begin, end int) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *File) exclusivePieces() (begin, end int) {
|
|
||||||
return byteRegionExclusivePieces(f.offset, f.length, int64(f.t.usualPieceSize()))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deprecated: Use File.SetPriority.
|
// Deprecated: Use File.SetPriority.
|
||||||
func (f *File) Cancel() {
|
func (f *File) Cancel() {
|
||||||
f.SetPriority(PiecePriorityNone)
|
f.SetPriority(PiecePriorityNone)
|
||||||
|
|
|
@ -34,7 +34,6 @@ var (
|
||||||
pieceHashedCorrect = expvar.NewInt("pieceHashedCorrect")
|
pieceHashedCorrect = expvar.NewInt("pieceHashedCorrect")
|
||||||
pieceHashedNotCorrect = expvar.NewInt("pieceHashedNotCorrect")
|
pieceHashedNotCorrect = expvar.NewInt("pieceHashedNotCorrect")
|
||||||
|
|
||||||
peerExtensions = expvar.NewMap("peerExtensions")
|
|
||||||
completedHandshakeConnectionFlags = expvar.NewMap("completedHandshakeConnectionFlags")
|
completedHandshakeConnectionFlags = expvar.NewMap("completedHandshakeConnectionFlags")
|
||||||
// Count of connections to peer with same client ID.
|
// Count of connections to peer with same client ID.
|
||||||
connsToSelf = expvar.NewInt("connsToSelf")
|
connsToSelf = expvar.NewInt("connsToSelf")
|
||||||
|
|
16
listen.go
16
listen.go
|
@ -2,22 +2,6 @@ package torrent
|
||||||
|
|
||||||
import "strings"
|
import "strings"
|
||||||
|
|
||||||
type peerNetworks struct {
|
|
||||||
tcp4, tcp6 bool
|
|
||||||
utp4, utp6 bool
|
|
||||||
}
|
|
||||||
|
|
||||||
func handleErr(h func(), fs ...func() error) error {
|
|
||||||
for _, f := range fs {
|
|
||||||
err := f()
|
|
||||||
if err != nil {
|
|
||||||
h()
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func LoopbackListenHost(network string) string {
|
func LoopbackListenHost(network string) string {
|
||||||
if strings.Contains(network, "4") {
|
if strings.Contains(network, "4") {
|
||||||
return "127.0.0.1"
|
return "127.0.0.1"
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
package torrent
|
package torrent
|
||||||
|
|
||||||
func strictCmp(same, less bool) cmper {
|
|
||||||
return func() (bool, bool) { return same, less }
|
|
||||||
}
|
|
||||||
|
|
||||||
type (
|
type (
|
||||||
cmper func() (same, less bool)
|
cmper func() (same, less bool)
|
||||||
multiLess struct {
|
multiLess struct {
|
||||||
|
|
|
@ -90,14 +90,6 @@ func (me tcpSocket) dial(ctx context.Context, addr string) (net.Conn, error) {
|
||||||
return me.d(ctx, addr)
|
return me.d(ctx, addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
func setPort(addr string, port int) string {
|
|
||||||
host, _, err := net.SplitHostPort(addr)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return net.JoinHostPort(host, strconv.FormatInt(int64(port), 10))
|
|
||||||
}
|
|
||||||
|
|
||||||
func listenAll(networks []string, getHost func(string) string, port int, proxyURL string, f firewallCallback) ([]socket, error) {
|
func listenAll(networks []string, getHost func(string) string, port int, proxyURL string, f firewallCallback) ([]socket, error) {
|
||||||
if len(networks) == 0 {
|
if len(networks) == 0 {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
|
29
torrent.go
29
torrent.go
|
@ -35,11 +35,6 @@ func (t *Torrent) chunkIndexSpec(chunkIndex pp.Integer, piece pieceIndex) chunkS
|
||||||
return chunkIndexSpec(chunkIndex, t.pieceLength(piece), t.chunkSize)
|
return chunkIndexSpec(chunkIndex, t.pieceLength(piece), t.chunkSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
type peersKey struct {
|
|
||||||
IPBytes string
|
|
||||||
Port int
|
|
||||||
}
|
|
||||||
|
|
||||||
// Maintains state of torrent within a Client.
|
// Maintains state of torrent within a Client.
|
||||||
type Torrent struct {
|
type Torrent struct {
|
||||||
// Torrent-level aggregate statistics. First in struct to ensure 64-bit
|
// Torrent-level aggregate statistics. First in struct to ensure 64-bit
|
||||||
|
@ -292,10 +287,6 @@ func (t *Torrent) haveMetadataPiece(piece int) bool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Torrent) metadataSizeKnown() bool {
|
|
||||||
return t.metadataBytes != nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t *Torrent) metadataSize() int {
|
func (t *Torrent) metadataSize() int {
|
||||||
return len(t.metadataBytes)
|
return len(t.metadataBytes)
|
||||||
}
|
}
|
||||||
|
@ -791,18 +782,6 @@ func chunkIndex(cs chunkSpec, chunkSize pp.Integer) int {
|
||||||
return int(cs.Begin / chunkSize)
|
return int(cs.Begin / chunkSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Torrent) wantPiece(r request) bool {
|
|
||||||
if !t.wantPieceIndex(pieceIndex(r.Index)) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if t.pieces[r.Index].pendingChunk(r.chunkSpec, t.chunkSize) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
// TODO: What about pieces that were wanted, but aren't now, and aren't
|
|
||||||
// completed either? That used to be done here.
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t *Torrent) wantPieceIndex(index pieceIndex) bool {
|
func (t *Torrent) wantPieceIndex(index pieceIndex) bool {
|
||||||
if !t.haveInfo() {
|
if !t.haveInfo() {
|
||||||
return false
|
return false
|
||||||
|
@ -1125,14 +1104,6 @@ func (t *Torrent) maybeCompleteMetadata() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Torrent) readerPieces() (ret bitmap.Bitmap) {
|
|
||||||
t.forReaderOffsetPieces(func(begin, end pieceIndex) bool {
|
|
||||||
ret.AddRange(bitmap.BitIndex(begin), bitmap.BitIndex(end))
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t *Torrent) readerPiecePriorities() (now, readahead bitmap.Bitmap) {
|
func (t *Torrent) readerPiecePriorities() (now, readahead bitmap.Bitmap) {
|
||||||
t.forReaderOffsetPieces(func(begin, end pieceIndex) bool {
|
t.forReaderOffsetPieces(func(begin, end pieceIndex) bool {
|
||||||
if end > begin {
|
if end > begin {
|
||||||
|
|
Loading…
Reference in New Issue