}
func (cl *Client) WriteStatus(w io.Writer) {
- cl.mu.Lock()
+ cl.mu.LevelLock(1)
defer cl.mu.Unlock()
if cl.listener != nil {
fmt.Fprintf(w, "Listening on %s\n", cl.listener.Addr())
func (cl *Client) acceptConnections() {
for {
+ // We accept all connections immediately, because we don't what
+ // torrent they're for.
conn, err := cl.listener.Accept()
select {
case <-cl.quit:
log.Print(err)
return
}
- // log.Printf("accepted connection from %s", conn.RemoteAddr())
go func() {
if err := cl.runConnection(conn, nil, peerSourceIncoming); err != nil {
log.Print(err)
},
"v": "go.torrent dev 20140825", // Just the date
// No upload queue is implemented yet.
- "reqq": 1,
+ "reqq": func() int {
+ if me.noUpload {
+ // No need to look strange if it costs us nothing.
+ return 250
+ } else {
+ return 1
+ }
+ }(),
}
if torrent.metadataSizeKnown() {
d["metadata_size"] = torrent.metadataSize()
}
util.CopyExact(&ih, metaInfo.Info.Hash)
}
- client.PrioritizeDataRegion(ih, 0, 999999999)
+ // client.PrioritizeDataRegion(ih, 0, 999999999)
err := client.AddPeers(ih, func() []torrent.Peer {
if *testPeer == "" {
return nil
select {}
}
if client.WaitAll() {
- log.Print("all torrents completed!")
+ log.Print("downloaded ALL the torrents")
} else {
log.Fatal("y u no complete torrents?!")
}