mirror of
https://github.com/SagerNet/sing.git
synced 2025-04-04 20:37:40 +03:00
33 lines
832 B
Go
33 lines
832 B
Go
package control
|
|
|
|
import (
|
|
"syscall"
|
|
)
|
|
|
|
func NewBindManager() BindManager {
|
|
return nil
|
|
}
|
|
|
|
func BindToInterface(manager BindManager, interfaceName string) Func {
|
|
return func(network, address string, conn syscall.RawConn) error {
|
|
return Raw(conn, func(fd uintptr) error {
|
|
return syscall.BindToDevice(int(fd), interfaceName)
|
|
})
|
|
}
|
|
}
|
|
|
|
func BindToInterfaceFunc(manager BindManager, interfaceNameFunc func(network, address string) string) Func {
|
|
return func(network, address string, conn syscall.RawConn) error {
|
|
interfaceName := interfaceNameFunc(network, address)
|
|
if interfaceName == "" {
|
|
return nil
|
|
}
|
|
return Raw(conn, func(fd uintptr) error {
|
|
return syscall.BindToDevice(int(fd), interfaceName)
|
|
})
|
|
}
|
|
}
|
|
|
|
func BindToInterfaceIndexFunc(interfaceIndexFunc func(network, address string) int) Func {
|
|
return nil
|
|
}
|