FedP2P/utp_libutp.go

24 lines
487 B
Go
Raw Normal View History

2021-07-14 12:35:52 +08:00
//go:build cgo && !disable_libutp
// +build cgo,!disable_libutp
2017-06-16 16:08:24 +08:00
package torrent
import (
utp "github.com/anacrolix/go-libutp"
"github.com/anacrolix/log"
2017-06-16 16:08:24 +08:00
)
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
2017-06-16 16:08:24 +08:00
}