forked from vercel-support/vercel-connect-debug
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvercel-debug.ps1
More file actions
116 lines (104 loc) · 3.59 KB
/
vercel-debug.ps1
File metadata and controls
116 lines (104 loc) · 3.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# Run these commands from the affected/problematic network
# Once completed, send the file to Vercel support
# Ask for domain and don't accept no domain
# Also, we need to ensure not to pass an URL (https://example.com/path)
# rather than only the domain name
while ((!$domain) -or ($domain -Match "`/")) {
$domain = Read-Host "Domain to test (e.g. example.com): "
}
# Lookup the DNS record to return the IP Ranges
echo "+---------------------------------------"
echo "+------- Fetching IP Addresses"
echo "|"
# Make curl request to the IP Range Lookup API
$ip_addresses = curl.exe -s -X POST "https://ip-ranges.vercel.support" -d "${domain}"
# Check if API call failed, returned empty, or returned special error responses
# If any of these conditions are true, exit immediately without running tests
if ($LASTEXITCODE -ne 0 -or [string]::IsNullOrEmpty($ip_addresses) -or $ip_addresses -eq "Not on Vercel" -or $ip_addresses -eq "DNS lookup failed" -or $ip_addresses -like "*Too Many Requests*") {
echo "| Range lookup failed - $(if ([string]::IsNullOrEmpty($ip_addresses)) { 'No response from API' } else { $ip_addresses })"
echo "+---------------------------------------"
echo ""
return
} else {
echo "| ${domain} IP range: $ip_addresses"
echo "+---------------------------------------"
echo ""
# Parse response and convert to array
$ip_range = ($ip_addresses -split ',').Trim()
}
# Measure time
$start = get-date
echo "+---------------------------------------"
echo "+------- STARTING"
echo "|"
# Show affected domain
echo "| Domain to test: ${domain} "
# Capture time/date
echo "| Timestamp (UTC): $((get-date).ToUniversalTime())"
echo "| Timestamp (Local): $(get-date)"
echo "+---------------------------------------"
echo ""
# Output the reporters IP address
echo "+---------------------------------------"
echo "+------- IP Information "
echo ""
curl.exe -s https://ipinfo.io/
echo ""
echo "+---------------------------------------"
echo ""
# Test reachability to Vercel CNAME records
ForEach ($i in $ip_range) {
echo "+---------------------------------------"
echo "+------- Testing $i "
echo "Checking headers via $i"
# Get the headers of the site, bypassing DNS resolution and querying domain via IP directly
curl.exe -svko NUL https://$domain --connect-to ::$i --max-time 3 --stderr -
# Ping the IP
echo ""
echo "Checking ping to $i"
ping -n 4 $i
# Skip traceroute if ping succeeds
if ($LASTEXITCODE -ne 0) {
echo ""
echo "Checking tracert to $i"
tracert -w 1 -h 30 $i
}
echo "+---------------------------------------"
echo ""
}
# Resolve affected domain
echo "+---------------------------------------"
echo "+------- nslookup debug ${domain} "
echo ""
nslookup -debug ${domain}
echo "+---------------------------------------"
echo ""
# Resolve affected domain via public DNS
echo "+---------------------------------------"
echo "+------- nslookup ${domain} via 8.8.8.8"
echo ""
nslookup ${domain} 8.8.8.8
echo "+---------------------------------------"
echo ""
# Output content of affected domain
echo "+---------------------------------------"
echo "+------- Output of ${domain}"
echo ""
curl.exe -svk https://${domain} --stderr -
echo ""
echo "+---------------------------------------"
echo ""
# Calculate duration
$end = get-date
$duration = ($end-$start)
echo ""
echo "+---------------------------------------"
echo "| Time elapsed: $([math]::Round($duration.TotalSeconds, 1)) seconds"
echo "|"
echo "+------- FINISHED"
echo "+---------------------------------------"
echo ""
echo ""
echo ""
echo "File can be found at $(Get-Location)\vercel-debug.txt"
echo ""