Add default DHT servers when UTP disabled
Also ensures that UDP and TCP sockets are reserved, even if not used, and fixes tests. Fixes #289.
This commit is contained in:
parent
8a0f333bb9
commit
1a4950ad4a
|
@ -230,7 +230,7 @@ func NewClient(cfg *ClientConfig) (cl *Client, err error) {
|
|||
}
|
||||
}
|
||||
|
||||
cl.conns, err = listenAll(cl.enabledPeerNetworks(), cl.config.ListenHost, cl.config.ListenPort, cl.config.ProxyURL, cl.firewallCallback)
|
||||
cl.conns, err = listenAll(allPeerNetworks, cl.config.ListenHost, cl.config.ListenPort, cl.config.ProxyURL, cl.firewallCallback)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -873,37 +873,21 @@ func TestClientDynamicListenPortAllProtocols(t *testing.T) {
|
|||
func TestClientDynamicListenTCPOnly(t *testing.T) {
|
||||
cfg := TestingConfig()
|
||||
cfg.DisableUTP = true
|
||||
cfg.DisableTCP = false
|
||||
cl, err := NewClient(cfg)
|
||||
require.NoError(t, err)
|
||||
defer cl.Close()
|
||||
assert.NotEqual(t, 0, cl.LocalPort())
|
||||
cl.eachListener(func(s socket) bool {
|
||||
assert.True(t, isTcpNetwork(s.Addr().Network()))
|
||||
return true
|
||||
})
|
||||
}
|
||||
|
||||
func TestClientDynamicListenUTPOnly(t *testing.T) {
|
||||
cfg := TestingConfig()
|
||||
cfg.DisableTCP = true
|
||||
cfg.DisableUTP = false
|
||||
cl, err := NewClient(cfg)
|
||||
require.NoError(t, err)
|
||||
defer cl.Close()
|
||||
assert.NotEqual(t, 0, cl.LocalPort())
|
||||
cl.eachListener(func(s socket) bool {
|
||||
assert.True(t, isUtpNetwork(s.Addr().Network()))
|
||||
return true
|
||||
})
|
||||
}
|
||||
|
||||
func TestClientDynamicListenPortNoProtocols(t *testing.T) {
|
||||
cfg := TestingConfig()
|
||||
cfg.DisableTCP = true
|
||||
cfg.DisableUTP = true
|
||||
cl, err := NewClient(cfg)
|
||||
require.NoError(t, err)
|
||||
defer cl.Close()
|
||||
assert.Equal(t, 0, cl.LocalPort())
|
||||
}
|
||||
|
||||
func totalConns(tts []*Torrent) (ret int) {
|
||||
|
|
Loading…
Reference in New Issue