hysteria/pkg/utils/df_linux.go
2021-04-19 20:52:50 -07:00

21 lines
393 B
Go

package utils
import (
"net"
"syscall"
)
func SetDontFragment(conn *net.UDPConn) error {
rawConn, err := conn.SyscallConn()
if err != nil {
return err
}
var err1, err2 error
err1 = rawConn.Control(func(fd uintptr) {
err2 = syscall.SetsockoptInt(int(fd), syscall.IPPROTO_IP, syscall.IP_MTU_DISCOVER, syscall.IP_PMTUDISC_PROBE)
})
if err1 != nil {
return err1
}
return err2
}