mirror of
https://github.com/cmz0228/hysteria-dev.git
synced 2025-07-28 16:38:34 +00:00
feat: bind socket to a particular device
This commit is contained in:
16
pkg/sockopt/sockopt_linux.go
Normal file
16
pkg/sockopt/sockopt_linux.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package sockopt
|
||||
|
||||
import (
|
||||
"net"
|
||||
"syscall"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
func bindRawConn(network string, c syscall.RawConn, bindIface *net.Interface) error {
|
||||
return c.Control(func(fd uintptr) {
|
||||
if bindIface != nil {
|
||||
unix.BindToDevice(int(fd), bindIface.Name)
|
||||
}
|
||||
})
|
||||
}
|
Reference in New Issue
Block a user