mirror of
https://github.com/SagerNet/sing.git
synced 2025-04-04 20:37:40 +03:00
Add net control funcs
This commit is contained in:
parent
a784aec420
commit
ddfe73e899
7 changed files with 97 additions and 0 deletions
17
common/control/bind_linux.go
Normal file
17
common/control/bind_linux.go
Normal file
|
@ -0,0 +1,17 @@
|
|||
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)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue