mirror of
https://github.com/net-byte/vtun
synced 2024-03-14 10:50:03 +08:00
set tos
This commit is contained in:
parent
5e21c80a47
commit
a3b13d51d6
@ -8,6 +8,7 @@ import (
|
|||||||
"github.com/net-byte/vtun/common/config"
|
"github.com/net-byte/vtun/common/config"
|
||||||
"github.com/net-byte/vtun/tun"
|
"github.com/net-byte/vtun/tun"
|
||||||
"github.com/songgao/water"
|
"github.com/songgao/water"
|
||||||
|
"golang.org/x/net/ipv4"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Start udp client
|
// Start udp client
|
||||||
@ -26,6 +27,10 @@ func StartClient(config config.Config) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalln("failed to listen on udp socket:", err)
|
log.Fatalln("failed to listen on udp socket:", err)
|
||||||
}
|
}
|
||||||
|
p := ipv4.NewPacketConn(conn)
|
||||||
|
if err := p.SetTOS(0xb8); err != nil { // DSCP EF
|
||||||
|
log.Fatalln("failed to set conn tos:", err)
|
||||||
|
}
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
c := &Client{config: config, iface: iface, localConn: conn, serverAddr: serverAddr}
|
c := &Client{config: config, iface: iface, localConn: conn, serverAddr: serverAddr}
|
||||||
go c.udpToTun()
|
go c.udpToTun()
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
"github.com/net-byte/vtun/tun"
|
"github.com/net-byte/vtun/tun"
|
||||||
"github.com/patrickmn/go-cache"
|
"github.com/patrickmn/go-cache"
|
||||||
"github.com/songgao/water"
|
"github.com/songgao/water"
|
||||||
|
"golang.org/x/net/ipv4"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Start udp server
|
// Start udp server
|
||||||
@ -25,6 +26,10 @@ func StartServer(config config.Config) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalln("failed to listen on udp socket:", err)
|
log.Fatalln("failed to listen on udp socket:", err)
|
||||||
}
|
}
|
||||||
|
p := ipv4.NewPacketConn(conn)
|
||||||
|
if err := p.SetTOS(0xb8); err != nil { // DSCP EF
|
||||||
|
log.Fatalln("failed to set conn tos:", err)
|
||||||
|
}
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
s := &Server{config: config, iface: iface, localConn: conn, connCache: cache.New(30*time.Minute, 10*time.Minute)}
|
s := &Server{config: config, iface: iface, localConn: conn, connCache: cache.New(30*time.Minute, 10*time.Minute)}
|
||||||
go s.tunToUdp()
|
go s.tunToUdp()
|
||||||
|
Loading…
Reference in New Issue
Block a user