summaryrefslogtreecommitdiffhomepage
path: root/src/conn_linux.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/conn_linux.go')
-rw-r--r--src/conn_linux.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/conn_linux.go b/src/conn_linux.go
new file mode 100644
index 0000000..b04471c
--- /dev/null
+++ b/src/conn_linux.go
@@ -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,
+ )
+}