import (
"log"
- "math"
"net/url"
"strings"
"sync"
+ "github.com/davecgh/go-spew/spew"
+
"github.com/anacrolix/tagflag"
"github.com/anacrolix/torrent"
"github.com/anacrolix/torrent/metainfo"
"github.com/anacrolix/torrent/tracker"
- "github.com/davecgh/go-spew/spew"
)
func argSpec(arg string) (ts *torrent.TorrentSpec, err error) {
tagflag.Parse(&flags)
ar := tracker.AnnounceRequest{
NumWant: -1,
- Left: math.MaxUint64,
+ Left: -1,
Port: flags.Port,
}
var wg sync.WaitGroup
"errors"
"fmt"
"io"
- "math"
"math/rand"
"net/url"
"os"
"time"
"unsafe"
+ "github.com/davecgh/go-spew/spew"
+
"github.com/anacrolix/dht"
"github.com/anacrolix/log"
"github.com/anacrolix/missinggo"
pp "github.com/anacrolix/torrent/peer_protocol"
"github.com/anacrolix/torrent/storage"
"github.com/anacrolix/torrent/tracker"
- "github.com/davecgh/go-spew/spew"
)
func (t *Torrent) chunkIndexSpec(chunkIndex pp.Integer, piece pieceIndex) chunkSpec {
}
// Bytes left to give in tracker announces.
-func (t *Torrent) bytesLeftAnnounce() uint64 {
+func (t *Torrent) bytesLeftAnnounce() int64 {
if t.haveInfo() {
- return uint64(t.bytesLeft())
+ return t.bytesLeft()
} else {
- return math.MaxUint64
+ return -1
}
}
"crypto/tls"
"fmt"
"io"
+ "math"
"net"
"net/http"
"net/url"
q.Set("port", fmt.Sprintf("%d", ar.Port))
q.Set("uploaded", strconv.FormatInt(ar.Uploaded, 10))
q.Set("downloaded", strconv.FormatInt(ar.Downloaded, 10))
- q.Set("left", strconv.FormatUint(ar.Left, 10))
+
+ // The AWS S3 tracker returns "400 Bad Request: left(-1) was not in the valid range 0 -
+ // 9223372036854775807" if left is out of range, or "500 Internal Server Error: Internal Server
+ // Error" if omitted entirely.
+ left := ar.Left
+ if left < 0 {
+ left = math.MaxInt64
+ }
+ q.Set("left", strconv.FormatInt(left, 10))
+
if ar.Event != None {
q.Set("event", ar.Event.String())
}
InfoHash [20]byte
PeerId [20]byte
Downloaded int64
- Left uint64
+ Left int64 // If less than 0, math.MaxInt64 will be used for HTTP trackers instead.
Uploaded int64
// Apparently this is optional. None can be used for announces done at
// regular intervals.