diff --git a/common/control/bind_darwin.go b/common/control/bind_darwin.go index 40a5a2d..5836563 100644 --- a/common/control/bind_darwin.go +++ b/common/control/bind_darwin.go @@ -22,9 +22,9 @@ func BindToInterface(manager BindManager, interfaceName string) Func { } } -func BindToInterfaceFunc(manager BindManager, interfaceNameFunc func() string) Func { +func BindToInterfaceFunc(manager BindManager, interfaceNameFunc func(network, address string) string) Func { return func(network, address string, conn syscall.RawConn) error { - interfaceName := interfaceNameFunc() + interfaceName := interfaceNameFunc(network, address) if interfaceName == "" { return nil } @@ -36,9 +36,9 @@ func BindToInterfaceFunc(manager BindManager, interfaceNameFunc func() string) F } } -func BindToInterfaceIndexFunc(interfaceIndexFunc func() int) Func { +func BindToInterfaceIndexFunc(interfaceIndexFunc func(network, address string) int) Func { return func(network, address string, conn syscall.RawConn) error { - index := interfaceIndexFunc() + index := interfaceIndexFunc(network, address) return bindToInterface(conn, network, index) } } diff --git a/common/control/bind_linux.go b/common/control/bind_linux.go index a12a578..91be667 100644 --- a/common/control/bind_linux.go +++ b/common/control/bind_linux.go @@ -16,9 +16,9 @@ func BindToInterface(manager BindManager, interfaceName string) Func { } } -func BindToInterfaceFunc(manager BindManager, interfaceNameFunc func() string) Func { +func BindToInterfaceFunc(manager BindManager, interfaceNameFunc func(network, address string) string) Func { return func(network, address string, conn syscall.RawConn) error { - interfaceName := interfaceNameFunc() + interfaceName := interfaceNameFunc(network, address) if interfaceName == "" { return nil } @@ -28,6 +28,6 @@ func BindToInterfaceFunc(manager BindManager, interfaceNameFunc func() string) F } } -func BindToInterfaceIndexFunc(interfaceIndexFunc func() int) Func { +func BindToInterfaceIndexFunc(interfaceIndexFunc func(network, address string) int) Func { return nil } diff --git a/common/control/bind_other.go b/common/control/bind_other.go index 6b89875..ad13c0c 100644 --- a/common/control/bind_other.go +++ b/common/control/bind_other.go @@ -10,10 +10,10 @@ func BindToInterface(manager BindManager, interfaceName string) Func { return nil } -func BindToInterfaceFunc(manager BindManager, interfaceNameFunc func() string) Func { +func BindToInterfaceFunc(manager BindManager, interfaceNameFunc func(network, address string) string) Func { return nil } -func BindToInterfaceIndexFunc(interfaceIndexFunc func() int) Func { +func BindToInterfaceIndexFunc(interfaceIndexFunc func(network, address string) int) Func { return nil } diff --git a/common/control/bind_windows.go b/common/control/bind_windows.go index 5aea4fa..7a3c9e0 100644 --- a/common/control/bind_windows.go +++ b/common/control/bind_windows.go @@ -68,9 +68,9 @@ func BindToInterface(manager BindManager, interfaceName string) Func { } } -func BindToInterfaceFunc(manager BindManager, interfaceNameFunc func() string) Func { +func BindToInterfaceFunc(manager BindManager, interfaceNameFunc func(network, address string) string) Func { return func(network, address string, conn syscall.RawConn) error { - interfaceName := interfaceNameFunc() + interfaceName := interfaceNameFunc(network, address) if interfaceName == "" { return nil } @@ -82,9 +82,9 @@ func BindToInterfaceFunc(manager BindManager, interfaceNameFunc func() string) F } } -func BindToInterfaceIndexFunc(interfaceIndexFunc func() int) Func { +func BindToInterfaceIndexFunc(interfaceIndexFunc func(network, address string) int) Func { return func(network, address string, conn syscall.RawConn) error { - index := interfaceIndexFunc() + index := interfaceIndexFunc(network, address) if index == -1 { return nil } diff --git a/protocol/http/handshake.go b/protocol/http/handshake.go index f079499..f04efe9 100644 --- a/protocol/http/handshake.go +++ b/protocol/http/handshake.go @@ -7,6 +7,7 @@ import ( "net" "net/http" "strings" + "github.com/sagernet/sing/common" "github.com/sagernet/sing/common/auth" "github.com/sagernet/sing/common/buf"