diff options
Diffstat (limited to 'ipv6test.go.new')
| -rw-r--r-- | ipv6test.go.new | 41 |
1 files changed, 0 insertions, 41 deletions
diff --git a/ipv6test.go.new b/ipv6test.go.new index c9d814e..7587650 100644 --- a/ipv6test.go.new +++ b/ipv6test.go.new @@ -12,44 +12,3 @@ const ( ipv6TestHost = "ipv6.google.com" testPort = "443" // HTTPS port ) - -func main() { - // --- Step 1: Fast DNS Lookup --- - // We'll use a separate, short timeout just for the DNS resolution. - // If DNS is broken, we'll know in a second or two. - dnsTimeout := 2 * time.Second - ctx, cancel := context.WithTimeout(context.Background(), dnsTimeout) - defer cancel() - - // net.DefaultResolver.LookupIPAddr forces the resolver to look up the host. - // We specify "ip6" to ensure we only get AAAA records. - addrs, err := net.DefaultResolver.LookupIPAddr(ctx, "ip6", ipv6TestHost) - if err != nil { - fmt.Printf("IPv6 DNS resolution failed: %v\n", err) - fmt.Println("This likely means your network cannot resolve IPv6 addresses.") - os.Exit(1) - } - - if len(addrs) == 0 { - fmt.Printf("No IPv6 addresses found for %s\n", ipv6TestHost) - os.Exit(1) - } - - // If we get here, DNS is working. Let's use the first address we found. - targetIP := addrs[0].IP.String() - fmt.Printf("Successfully resolved %s to IPv6 address: %s\n", ipv6TestHost, targetIP) - - // --- Step 2: Connection Attempt --- - // Now we try to connect to the IP we found. This tests routing and firewalls. - connectionTimeout := 3 * time.Second - conn, err := net.DialTimeout("tcp6", net.JoinHostPort(targetIP, testPort), connectionTimeout) - if err != nil { - fmt.Printf("IPv6 connection to %s failed: %v\n", targetIP, err) - fmt.Println("This likely means your network has an IPv6 routing or firewall issue.") - os.Exit(1) - } - defer conn.Close() - - fmt.Println("IPv6 connectivity test successful.") - os.Exit(0) -} |
