Fix go-libutp import when CGO is disabled

This commit is contained in:
Matt Joiner 2021-12-16 09:44:59 +11:00
parent 2b0ec5d762
commit 48fa9b59fd
2 changed files with 3 additions and 3 deletions

View File

@ -5,7 +5,6 @@ import (
"net"
"strconv"
utp "github.com/anacrolix/go-libutp"
"github.com/anacrolix/missinggo/perf"
"github.com/anacrolix/missinggo/v2"
"github.com/pkg/errors"
@ -101,7 +100,8 @@ func listenAllRetry(nahs []networkAndHost, port int, f firewallCallback) (ss []s
return
}
type firewallCallback = utp.FirewallCallback
// This isn't aliased from go-libutp since that assumes CGO.
type firewallCallback func(net.Addr) bool
func listenUtp(network, addr string, fc firewallCallback) (socket, error) {
us, err := NewUtpSocket(network, addr, fc)

View File

@ -16,7 +16,7 @@ func NewUtpSocket(network, addr string, fc firewallCallback) (utpSocket, error)
return s, err
}
if fc != nil {
s.SetSyncFirewallCallback(fc)
s.SetSyncFirewallCallback(utp.FirewallCallback(fc))
}
return s, err
}