diff --git a/agent.go b/agent.go index 0364de70..1346771d 100644 --- a/agent.go +++ b/agent.go @@ -138,8 +138,8 @@ type Agent struct { udpMux UDPMux udpMuxSrflx UniversalUDPMux - interfaceFilter func(string) bool - ipFilter func(net.IP) bool + interfaceFilter func(string) (keep bool) + ipFilter func(net.IP) (keep bool) includeLoopback bool insecureSkipVerify bool diff --git a/agent_config.go b/agent_config.go index ad3dd497..8d3f2816 100644 --- a/agent_config.go +++ b/agent_config.go @@ -148,11 +148,11 @@ type AgentConfig struct { // InterfaceFilter is a function that you can use in order to whitelist or blacklist // the interfaces which are used to gather ICE candidates. - InterfaceFilter func(string) bool + InterfaceFilter func(string) (keep bool) // IPFilter is a function that you can use in order to whitelist or blacklist // the ips which are used to gather ICE candidates. - IPFilter func(net.IP) bool + IPFilter func(net.IP) (keep bool) // InsecureSkipVerify controls if self-signed certificates are accepted when connecting // to TURN servers via TLS or DTLS diff --git a/gather_vnet_test.go b/gather_vnet_test.go index 3babce39..f8754d3c 100644 --- a/gather_vnet_test.go +++ b/gather_vnet_test.go @@ -387,7 +387,7 @@ func TestVNetGatherWithInterfaceFilter(t *testing.T) { t.Run("InterfaceFilter should exclude the interface", func(t *testing.T) { a, err := NewAgent(&AgentConfig{ Net: nw, - InterfaceFilter: func(interfaceName string) bool { + InterfaceFilter: func(interfaceName string) (keep bool) { require.Equal(t, "eth0", interfaceName) return false }, @@ -408,7 +408,7 @@ func TestVNetGatherWithInterfaceFilter(t *testing.T) { t.Run("IPFilter should exclude the IP", func(t *testing.T) { a, err := NewAgent(&AgentConfig{ Net: nw, - IPFilter: func(ip net.IP) bool { + IPFilter: func(ip net.IP) (keep bool) { require.Equal(t, net.IP{1, 2, 3, 1}, ip) return false }, @@ -429,7 +429,7 @@ func TestVNetGatherWithInterfaceFilter(t *testing.T) { t.Run("InterfaceFilter should not exclude the interface", func(t *testing.T) { a, err := NewAgent(&AgentConfig{ Net: nw, - InterfaceFilter: func(interfaceName string) bool { + InterfaceFilter: func(interfaceName string) (keep bool) { require.Equal(t, "eth0", interfaceName) return true }, diff --git a/net.go b/net.go index 6e740a70..c4fc27bf 100644 --- a/net.go +++ b/net.go @@ -39,8 +39,8 @@ func isZeros(ip net.IP) bool { //nolint:gocognit func localInterfaces( n transport.Net, - interfaceFilter func(string) bool, - ipFilter func(net.IP) bool, + interfaceFilter func(string) (keep bool), + ipFilter func(net.IP) (keep bool), networkTypes []NetworkType, includeLoopback bool, ) ([]*transport.Interface, []netip.Addr, error) { diff --git a/net_test.go b/net_test.go index 12f0a9e2..cd7d2fb8 100644 --- a/net_test.go +++ b/net_test.go @@ -45,7 +45,7 @@ func TestCreateAddr(t *testing.T) { require.Equal(t, &net.TCPAddr{IP: ipv6.AsSlice(), Port: port}, createAddr(NetworkTypeTCP6, ipv6, port)) } -func problematicNetworkInterfaces(s string) bool { +func problematicNetworkInterfaces(s string) (keep bool) { defaultDockerBridgeNetwork := strings.Contains(s, "docker") customDockerBridgeNetwork := strings.Contains(s, "br-") diff --git a/udp_mux_multi.go b/udp_mux_multi.go index 2594cb02..f8b42852 100644 --- a/udp_mux_multi.go +++ b/udp_mux_multi.go @@ -141,8 +141,8 @@ type UDPMuxFromPortOption interface { } type multiUDPMuxFromPortParam struct { - ifFilter func(string) bool - ipFilter func(ip net.IP) bool + ifFilter func(string) (keep bool) + ipFilter func(ip net.IP) (keep bool) networks []NetworkType readBufferSize int writeBufferSize int @@ -160,7 +160,7 @@ func (o *udpMuxFromPortOption) apply(p *multiUDPMuxFromPortParam) { } // UDPMuxFromPortWithInterfaceFilter set the filter to filter out interfaces that should not be used -func UDPMuxFromPortWithInterfaceFilter(f func(string) bool) UDPMuxFromPortOption { +func UDPMuxFromPortWithInterfaceFilter(f func(string) (keep bool)) UDPMuxFromPortOption { return &udpMuxFromPortOption{ f: func(p *multiUDPMuxFromPortParam) { p.ifFilter = f @@ -169,7 +169,7 @@ func UDPMuxFromPortWithInterfaceFilter(f func(string) bool) UDPMuxFromPortOption } // UDPMuxFromPortWithIPFilter set the filter to filter out IP addresses that should not be used -func UDPMuxFromPortWithIPFilter(f func(ip net.IP) bool) UDPMuxFromPortOption { +func UDPMuxFromPortWithIPFilter(f func(ip net.IP) (keep bool)) UDPMuxFromPortOption { return &udpMuxFromPortOption{ f: func(p *multiUDPMuxFromPortParam) { p.ipFilter = f