}
if !cfg.NoDHT {
dhtCfg := cfg.DHTConfig
- if dhtCfg == nil {
- dhtCfg = &dht.ServerConfig{}
- }
if dhtCfg.IPBlocklist == nil {
dhtCfg.IPBlocklist = cl.ipBlockList
}
if dhtCfg.Conn == nil && cl.utpSock != nil {
dhtCfg.Conn = cl.utpSock
}
- cl.dHT, err = dht.NewServer(dhtCfg)
+ cl.dHT, err = dht.NewServer(&dhtCfg)
if err != nil {
return
}
NoDefaultBlocklist: true,
DisableMetainfoCache: true,
DataDir: filepath.Join(os.TempDir(), "anacrolix"),
+ DHTConfig: dht.ServerConfig{
+ NoDefaultBootstrap: true,
+ },
}
func TestClientDefault(t *testing.T) {
func TestDHTInheritBlocklist(t *testing.T) {
ipl := iplist.New(nil)
require.NotNil(t, ipl)
- cl, err := NewClient(&Config{
- IPBlocklist: iplist.New(nil),
- DHTConfig: &dht.ServerConfig{},
- })
+ cfg := TestingConfig
+ cfg.IPBlocklist = ipl
+ cfg.NoDHT = false
+ cl, err := NewClient(&cfg)
require.NoError(t, err)
defer cl.Close()
require.Equal(t, ipl, cl.DHT().IPBlocklist())
// Don't create a DHT.
NoDHT bool `long:"disable-dht"`
// Overrides the default DHT configuration.
- DHTConfig *dht.ServerConfig
+ DHTConfig dht.ServerConfig
// Don't ever send chunks to peers.
NoUpload bool `long:"no-upload"`
// Upload even after there's nothing in it for us. By default uploading is
package torrent
import (
- "github.com/anacrolix/torrent/metainfo"
- "testing"
- "path/filepath"
- "os"
- "github.com/anacrolix/torrent/dht"
- "io"
"errors"
"fmt"
+ "io"
+ "os"
+ "path/filepath"
"runtime"
+ "testing"
+
+ "github.com/anacrolix/torrent/dht"
+ "github.com/anacrolix/torrent/metainfo"
)
var numclients int = 0
Seed: true,
DataDir: filepath.Join(os.TempDir(), "torrent-test/data"),
ConfigDir: filepath.Join(os.TempDir(), "torrent-test/config"),
- DHTConfig: &dht.ServerConfig{
- Passive: false,
- BootstrapNodes: []string{},
- NoSecurity: false,
+ DHTConfig: dht.ServerConfig{
+ Passive: false,
+ BootstrapNodes: []string{},
+ NoSecurity: false,
+ NoDefaultBootstrap: true,
},
- Debug: true,
+ Debug: true,
}
}
return nil
}
-func TestInfohash(t *testing.T){
+func TestInfohash(t *testing.T) {
os.RemoveAll(filepath.Join(os.TempDir(), "torrent-test"))
os.MkdirAll(filepath.Join(os.TempDir(), "torrent-test"), 0700)
var cl_one *Client