2
0
mirror of synced 2025-02-22 21:58:24 +00:00
torrent/utp_libutp.go
FIGBERT 7d41b9b21c
Pass client logger to anacrolix/go-libutp sockets (#722)
* Update anacrolix/go-libutp (v1.1.0 -> v1.2.0)

* Pass client logger to anacrolix/go-libutp

* Pass logger instead of option

The project now compiles properly when CGO is not enabled.

Additionally, the new argument (now log.Logger instead of
utp.NewSocketOpt) is now required. The tests have been updated to match
this change, and now pass logger.Default to NewUtpSocket.

* Correct function signature of NewUtpSocket
2022-02-15 16:18:32 +11:00

24 lines
487 B
Go

//go:build cgo && !disable_libutp
// +build cgo,!disable_libutp
package torrent
import (
utp "github.com/anacrolix/go-libutp"
"github.com/anacrolix/log"
)
func NewUtpSocket(network, addr string, fc firewallCallback, logger log.Logger) (utpSocket, error) {
s, err := utp.NewSocket(network, addr, utp.WithLogger(logger))
if s == nil {
return nil, err
}
if err != nil {
return s, err
}
if fc != nil {
s.SetSyncFirewallCallback(utp.FirewallCallback(fc))
}
return s, err
}