2020-02-20 10:57:24 +08:00
|
|
|
package torrent
|
|
|
|
|
|
|
|
import (
|
2021-02-22 11:30:09 +08:00
|
|
|
"testing"
|
2021-08-18 09:27:21 +08:00
|
|
|
"time"
|
2021-10-25 17:52:44 +08:00
|
|
|
|
|
|
|
pp "github.com/anacrolix/torrent/peer_protocol"
|
2020-02-20 10:57:24 +08:00
|
|
|
)
|
|
|
|
|
2021-02-22 11:30:09 +08:00
|
|
|
func TestingConfig(t testing.TB) *ClientConfig {
|
2020-02-20 10:57:24 +08:00
|
|
|
cfg := NewDefaultClientConfig()
|
|
|
|
cfg.ListenHost = LoopbackListenHost
|
|
|
|
cfg.NoDHT = true
|
2021-02-22 11:30:09 +08:00
|
|
|
cfg.DataDir = t.TempDir()
|
2020-02-20 10:57:24 +08:00
|
|
|
cfg.DisableTrackers = true
|
|
|
|
cfg.NoDefaultPortForwarding = true
|
|
|
|
cfg.DisableAcceptRateLimiting = true
|
|
|
|
cfg.ListenPort = 0
|
2021-08-18 14:23:51 +08:00
|
|
|
cfg.KeepAliveTimeout = time.Millisecond
|
2021-10-25 17:52:44 +08:00
|
|
|
cfg.MinPeerExtensions.SetBit(pp.ExtensionBitFast, true)
|
2020-02-20 10:57:24 +08: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
|
|
|
|
}
|