status-go/vendor/github.com/anacrolix/torrent/utp_libutp.go

24 lines
487 B
Go
Raw Permalink Normal View History

2022-03-10 09:44:48 +00:00
//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
}