2021-07-14 04:35:52 +00:00
|
|
|
//go:build cgo && !disable_libutp
|
2017-06-16 08:08:24 +00:00
|
|
|
|
|
|
|
package torrent
|
|
|
|
|
|
|
|
import (
|
2021-10-06 07:36:25 +00:00
|
|
|
utp "github.com/anacrolix/go-libutp"
|
2017-06-16 08:08:24 +00:00
|
|
|
)
|
|
|
|
|
2018-07-25 07:11:09 +00:00
|
|
|
func NewUtpSocket(network, addr string, fc firewallCallback) (utpSocket, error) {
|
2017-09-13 14:25:29 +00:00
|
|
|
s, err := utp.NewSocket(network, addr)
|
|
|
|
if s == nil {
|
|
|
|
return nil, err
|
2018-07-25 07:11:09 +00:00
|
|
|
}
|
|
|
|
if err != nil {
|
2017-09-13 14:25:29 +00:00
|
|
|
return s, err
|
|
|
|
}
|
2018-07-25 07:11:09 +00:00
|
|
|
if fc != nil {
|
|
|
|
s.SetFirewallCallback(utp.FirewallCallback(fc))
|
|
|
|
}
|
|
|
|
return s, err
|
2017-06-16 08:08:24 +00:00
|
|
|
}
|