mirror of
https://git.zx2c4.com/wireguard-go
synced 2024-11-15 01:05:15 +01:00
25 lines
313 B
Go
25 lines
313 B
Go
|
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,
|
||
|
)
|
||
|
}
|