sing/common/control/bind_linux.go
2022-06-30 17:39:41 +08:00

17 lines
365 B
Go

package control
import (
"syscall"
"github.com/sagernet/sing/common"
)
func BindToInterface(interfaceName string) Func {
return func(network, address string, conn syscall.RawConn) error {
var innerErr error
err := conn.Control(func(fd uintptr) {
innerErr = syscall.BindToDevice(int(fd), interfaceName)
})
return common.AnyError(innerErr, err)
}
}