Added fwmark code
This commit is contained in:
24
src/conn_linux.go
Normal file
24
src/conn_linux.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"golang.org/x/sys/unix"
|
||||
"net"
|
||||
)
|
||||
|
||||
func setMark(conn *net.UDPConn, value int) error {
|
||||
if conn == nil || value == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
file, err := conn.File()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return unix.SetsockoptInt(
|
||||
int(file.Fd()),
|
||||
unix.SOL_SOCKET,
|
||||
unix.SO_MARK,
|
||||
value,
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user