Skip to content

Commit 7db9b5f

Browse files
committed
Set DSCP marking for IPv6
1 parent 6cb6faf commit 7db9b5f

5 files changed

Lines changed: 10 additions & 0 deletions

File tree

dnscrypt-proxy/setsockopts_darwin.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ func (proxy *Proxy) udpListenerConfig() (*net.ListenConfig, error) {
1111
_ = c.Control(func(fd uintptr) {
1212
_ = syscall.SetsockoptInt(int(fd), syscall.IPPROTO_IP, syscall.IP_DF, 0)
1313
_ = syscall.SetsockoptInt(int(fd), syscall.IPPROTO_IP, syscall.IP_TOS, 0x70)
14+
_ = syscall.SetsockoptInt(int(fd), syscall.IPPROTO_IPV6, syscall.IPV6_TCLASS, 0x70)
1415
_ = syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_RCVBUF, 4096)
1516
_ = syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_SNDBUF, 4096)
1617
})
@@ -24,6 +25,7 @@ func (proxy *Proxy) tcpListenerConfig() (*net.ListenConfig, error) {
2425
Control: func(network, address string, c syscall.RawConn) error {
2526
_ = c.Control(func(fd uintptr) {
2627
_ = syscall.SetsockoptInt(int(fd), syscall.IPPROTO_IP, syscall.IP_TOS, 0x70)
28+
_ = syscall.SetsockoptInt(int(fd), syscall.IPPROTO_IPV6, syscall.IPV6_TCLASS, 0x70)
2729
})
2830
return nil
2931
},

dnscrypt-proxy/setsockopts_freebsd.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ func (proxy *Proxy) udpListenerConfig() (*net.ListenConfig, error) {
1313
_ = syscall.SetsockoptInt(int(fd), syscall.IPPROTO_IPV6, syscall.IPV6_BINDANY, 1)
1414
_ = syscall.SetsockoptInt(int(fd), syscall.IPPROTO_IP, syscall.IP_DF, 0)
1515
_ = syscall.SetsockoptInt(int(fd), syscall.IPPROTO_IP, syscall.IP_TOS, 0x70)
16+
_ = syscall.SetsockoptInt(int(fd), syscall.IPPROTO_IPV6, syscall.IPV6_TCLASS, 0x70)
1617
_ = syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_RCVBUF, 4096)
1718
_ = syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_SNDBUF, 4096)
1819
})
@@ -28,6 +29,7 @@ func (proxy *Proxy) tcpListenerConfig() (*net.ListenConfig, error) {
2829
_ = syscall.SetsockoptInt(int(fd), syscall.IPPROTO_IP, syscall.IP_BINDANY, 1)
2930
_ = syscall.SetsockoptInt(int(fd), syscall.IPPROTO_IPV6, syscall.IPV6_BINDANY, 1)
3031
_ = syscall.SetsockoptInt(int(fd), syscall.IPPROTO_IP, syscall.IP_TOS, 0x70)
32+
_ = syscall.SetsockoptInt(int(fd), syscall.IPPROTO_IPV6, syscall.IPV6_TCLASS, 0x70)
3133
})
3234
return nil
3335
},

dnscrypt-proxy/setsockopts_linux.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ func (proxy *Proxy) udpListenerConfig() (*net.ListenConfig, error) {
1212
_ = syscall.SetsockoptInt(int(fd), syscall.IPPROTO_IP, syscall.IP_FREEBIND, 1)
1313
_ = syscall.SetsockoptInt(int(fd), syscall.IPPROTO_IP, syscall.IP_DF, 0)
1414
_ = syscall.SetsockoptInt(int(fd), syscall.IPPROTO_IP, syscall.IP_TOS, 0x70)
15+
_ = syscall.SetsockoptInt(int(fd), syscall.IPPROTO_IPV6, syscall.IPV6_TCLASS, 0x70)
1516
_ = syscall.SetsockoptInt(
1617
int(fd),
1718
syscall.IPPROTO_IP,
@@ -32,6 +33,7 @@ func (proxy *Proxy) tcpListenerConfig() (*net.ListenConfig, error) {
3233
_ = c.Control(func(fd uintptr) {
3334
_ = syscall.SetsockoptInt(int(fd), syscall.IPPROTO_IP, syscall.IP_FREEBIND, 1)
3435
_ = syscall.SetsockoptInt(int(fd), syscall.IPPROTO_IP, syscall.IP_TOS, 0x70)
36+
_ = syscall.SetsockoptInt(int(fd), syscall.IPPROTO_IPV6, syscall.IPV6_TCLASS, 0x70)
3537
_ = syscall.SetsockoptInt(int(fd), syscall.IPPROTO_TCP, syscall.TCP_QUICKACK, 1)
3638
})
3739
return nil

dnscrypt-proxy/setsockopts_openbsd.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ func (proxy *Proxy) udpListenerConfig() (*net.ListenConfig, error) {
1212
_ = syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_BINDANY, 1)
1313
_ = syscall.SetsockoptInt(int(fd), syscall.IPPROTO_IP, syscall.IP_DF, 0)
1414
_ = syscall.SetsockoptInt(int(fd), syscall.IPPROTO_IP, syscall.IP_TOS, 0x70)
15+
_ = syscall.SetsockoptInt(int(fd), syscall.IPPROTO_IPV6, syscall.IPV6_TCLASS, 0x70)
1516
_ = syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_RCVBUF, 4096)
1617
_ = syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_SNDBUF, 4096)
1718
})
@@ -26,6 +27,7 @@ func (proxy *Proxy) tcpListenerConfig() (*net.ListenConfig, error) {
2627
_ = c.Control(func(fd uintptr) {
2728
_ = syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_BINDANY, 1)
2829
_ = syscall.SetsockoptInt(int(fd), syscall.IPPROTO_IP, syscall.IP_TOS, 0x70)
30+
_ = syscall.SetsockoptInt(int(fd), syscall.IPPROTO_IPV6, syscall.IPV6_TCLASS, 0x70)
2931
})
3032
return nil
3133
},

dnscrypt-proxy/setsockopts_windows.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ func (proxy *Proxy) udpListenerConfig() (*net.ListenConfig, error) {
1010
Control: func(network, address string, c syscall.RawConn) error {
1111
_ = c.Control(func(fd uintptr) {
1212
_ = syscall.SetsockoptInt(syscall.Handle(fd), syscall.IPPROTO_IP, syscall.IP_TOS, 0x70)
13+
_ = syscall.SetsockoptInt(syscall.Handle(fd), syscall.IPPROTO_IPV6, syscall.IPV6_TCLASS, 0x70)
1314
_ = syscall.SetsockoptInt(syscall.Handle(fd), syscall.SOL_SOCKET, syscall.SO_RCVBUF, 4096)
1415
_ = syscall.SetsockoptInt(syscall.Handle(fd), syscall.SOL_SOCKET, syscall.SO_SNDBUF, 4096)
1516
})
@@ -23,6 +24,7 @@ func (proxy *Proxy) tcpListenerConfig() (*net.ListenConfig, error) {
2324
Control: func(network, address string, c syscall.RawConn) error {
2425
_ = c.Control(func(fd uintptr) {
2526
_ = syscall.SetsockoptInt(syscall.Handle(fd), syscall.IPPROTO_IP, syscall.IP_TOS, 0x70)
27+
_ = syscall.SetsockoptInt(syscall.Handle(fd), syscall.IPPROTO_IPV6, syscall.IPV6_TCLASS, 0x70)
2628
})
2729
return nil
2830
},

0 commit comments

Comments
 (0)