2020-02-20 02:57:24 +00:00
|
|
|
package torrent
|
|
|
|
|
|
|
|
import (
|
2021-02-22 03:30:09 +00:00
|
|
|
"testing"
|
2021-08-18 01:27:21 +00:00
|
|
|
"time"
|
2021-10-25 09:52:44 +00:00
|
|
|
|
|
|
|
pp "github.com/anacrolix/torrent/peer_protocol"
|
2020-02-20 02:57:24 +00:00
|
|
|
)
|
|
|
|
|
2021-02-22 03:30:09 +00:00
|
|
|
func TestingConfig(t testing.TB) *ClientConfig {
|
2020-02-20 02:57:24 +00:00
|
|
|
cfg := NewDefaultClientConfig()
|
|
|
|
cfg.ListenHost = LoopbackListenHost
|
|
|
|
cfg.NoDHT = true
|
2021-02-22 03:30:09 +00:00
|
|
|
cfg.DataDir = t.TempDir()
|
2020-02-20 02:57:24 +00:00
|
|
|
cfg.DisableTrackers = true
|
|
|
|
cfg.NoDefaultPortForwarding = true
|
|
|
|
cfg.DisableAcceptRateLimiting = true
|
|
|
|
cfg.ListenPort = 0
|
2021-08-18 06:23:51 +00:00
|
|
|
cfg.KeepAliveTimeout = time.Millisecond
|
2021-10-25 09:52:44 +00:00
|
|
|
cfg.MinPeerExtensions.SetBit(pp.ExtensionBitFast, true)
|
2020-02-20 02:57:24 +00:00
|
|
|
//cfg.Debug = true
|
|
|
|
//cfg.Logger = cfg.Logger.WithText(func(m log.Msg) string {
|
|
|
|
// t := m.Text()
|
|
|
|
// m.Values(func(i interface{}) bool {
|
|
|
|
// t += fmt.Sprintf("\n%[1]T: %[1]v", i)
|
|
|
|
// return true
|
|
|
|
// })
|
|
|
|
// return t
|
|
|
|
//})
|
|
|
|
return cfg
|
|
|
|
}
|