2020-11-08 17:19:25 +00:00
|
|
|
package torrent
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/anacrolix/log"
|
|
|
|
"github.com/anacrolix/torrent"
|
|
|
|
"github.com/anacrolix/torrent/storage"
|
2021-04-04 17:24:58 +00:00
|
|
|
"github.com/distribyted/distribyted/config"
|
2020-11-08 17:19:25 +00:00
|
|
|
)
|
|
|
|
|
2021-04-04 17:24:58 +00:00
|
|
|
func NewClient(st storage.ClientImpl, cfg *config.TorrentGlobal) (*torrent.Client, error) {
|
2020-11-08 17:19:25 +00:00
|
|
|
// TODO download and upload limits
|
|
|
|
torrentCfg := torrent.NewDefaultClientConfig()
|
|
|
|
torrentCfg.Logger = log.Discard
|
|
|
|
torrentCfg.Seed = true
|
|
|
|
torrentCfg.DefaultStorage = st
|
|
|
|
|
2021-04-04 17:24:58 +00:00
|
|
|
torrentCfg.DisableIPv6 = cfg.DisableIPv6
|
2020-11-08 17:19:25 +00:00
|
|
|
|
2021-04-04 17:24:58 +00:00
|
|
|
return torrent.NewClient(torrentCfg)
|
2020-11-08 17:19:25 +00:00
|
|
|
}
|