Improve bind

This commit is contained in:
世界 2022-08-26 20:47:40 +08:00
parent 185d879182
commit d4ba8fdfac
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
5 changed files with 14 additions and 13 deletions

View file

@ -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)
}
}