aboutsummaryrefslogtreecommitdiff
path: root/src/conn_linux.go
blob: e973b25eee91dea8f7dcb5c837c81ac547a5d455 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package main

import (
	"golang.org/x/sys/unix"
	"net"
)

func setMark(conn *net.UDPConn, value uint32) error {
	if conn == nil {
		return nil
	}

	file, err := conn.File()
	if err != nil {
		return err
	}

	return unix.SetsockoptInt(
		int(file.Fd()),
		unix.SOL_SOCKET,
		unix.SO_MARK,
		int(value),
	)
}