From 48fa9b59fd8387d2497286943872dd917e0729a5 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Thu, 16 Dec 2021 09:44:59 +1100 Subject: [PATCH] Fix go-libutp import when CGO is disabled --- socket.go | 4 ++-- utp_libutp.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/socket.go b/socket.go index fbe8d9cb..4de2592a 100644 --- a/socket.go +++ b/socket.go @@ -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) diff --git a/utp_libutp.go b/utp_libutp.go index 3cbd01c0..76e530de 100644 --- a/utp_libutp.go +++ b/utp_libutp.go @@ -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 }