2020-02-20 13:47:37 +08:00
|
|
|
package test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io"
|
|
|
|
"log"
|
|
|
|
"net"
|
|
|
|
"path/filepath"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/anacrolix/torrent"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestUnixConns(t *testing.T) {
|
|
|
|
var closers []io.Closer
|
|
|
|
defer func() {
|
|
|
|
for _, c := range closers {
|
|
|
|
c.Close()
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
configure := ConfigureClient{
|
|
|
|
Config: func(cfg *torrent.ClientConfig) {
|
|
|
|
cfg.DisableUTP = true
|
|
|
|
cfg.DisableTCP = true
|
|
|
|
cfg.Debug = true
|
|
|
|
},
|
|
|
|
Client: func(cl *torrent.Client) {
|
2021-06-21 11:29:26 +08:00
|
|
|
cl.AddDialer(torrent.NetworkDialer{Network: "unix", Dialer: torrent.DefaultNetDialer})
|
2021-02-22 11:30:09 +08:00
|
|
|
l, err := net.Listen("unix", filepath.Join(t.TempDir(), "socket"))
|
2020-02-20 13:47:37 +08:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
log.Printf("created listener %q", l)
|
|
|
|
closers = append(closers, l)
|
|
|
|
cl.AddListener(l)
|
|
|
|
},
|
|
|
|
}
|
|
|
|
testClientTransfer(t, testClientTransferParams{
|
|
|
|
ConfigureSeeder: configure,
|
|
|
|
ConfigureLeecher: configure,
|
|
|
|
})
|
|
|
|
}
|