Created
January 1, 2025 16:41
-
-
Save eyberg/aec645c5166e8945b94206d4bb46b859 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"net" | |
"golang.org/x/sys/unix" | |
) | |
func main() { | |
conn, err := net.ListenUDP("udp", nil) | |
if err != nil { | |
panic(err) | |
} | |
defer conn.Close() | |
rc, err := conn.SyscallConn() | |
if err != nil { | |
panic(err) | |
} | |
err = rc.Control(func(fd uintptr) { | |
err := unix.SetsockoptInt(int(fd), unix.IPPROTO_IP, unix.IP_MTU_DISCOVER, unix.IP_PMTUDISC_DO) | |
if err != nil { | |
panic(err) | |
} | |
}) | |
if err != nil { | |
panic(err) | |
} | |
bs := make([]byte, 7000) | |
fmt.Println(conn.WriteToUDP(bs, &net.UDPAddr{ | |
IP: net.IPv4(8, 8, 8, 8), | |
Port: 53, | |
})) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment