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.sh
More file actions
executable file
·129 lines (116 loc) · 5.3 KB
/
vercel-debug.sh
File metadata and controls
executable file
·129 lines (116 loc) · 5.3 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
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/bin/bash
# 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 [[ -z "$domain" || "$domain" =~ '/' ]]
do
echo "Domain to test (e.g. example.com): "
read domain </dev/tty
done
# 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 -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 [ $? -ne 0 ] || [ -z "$ip_addresses" ] || [ "$ip_addresses" = "Not on Vercel" ] || [ "$ip_addresses" = "DNS lookup failed" ] || [[ "$ip_addresses" == *"Too Many Requests"* ]]; then
echo "│ Range lookup failed - ${ip_addresses:-No response from API}"
echo "└───────────────────────────────────────"
echo ""
exit 0
else
echo "│ ${domain} IP range: $ip_addresses"
echo "└───────────────────────────────────────"
echo ""
# Parse response and convert to array
ip_range=($(echo "$ip_addresses" | tr ',' ' '))
fi
# Measure time
start=$(date +%s)
echo "┌───────────────────────────────────────"
echo "├─────── STARTING"
echo "│"
# Show affected domain
echo "│ Domain to test: ${domain} "
# Capture time/date
echo "│ Timestamp (UTC): $(date -u)"
echo "│ Timestamp (Local): $(date)"
echo "└───────────────────────────────────────"
echo ""
# Output the reporters IP address
echo "┌───────────────────────────────────────"
echo "├─────── IP Information "
echo ""
curl -s https://ipinfo.io/
echo ""
echo "└───────────────────────────────────────"
echo ""
# Test reachability to Vercel CNAME records
for i in "${ip_range[@]}"
do
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 -svko /dev/null https://${domain} --connect-to ::${i} --max-time 3 --stderr -
# Ping the IP
echo ""
echo "Checking ping to $i"
ping -c 4 $i
# Skip traceroute if ping succeeds
if [ $? -ne 0 ]
then
echo ""
echo "Checking tracert to $i"
traceroute -w 1 -m 30 -I $i
fi
echo "└───────────────────────────────────────"
echo ""
done
# Resolve affected domain
echo "┌───────────────────────────────────────"
echo "├─────── dig ${domain} "
echo ""
dig ${domain}
echo "└───────────────────────────────────────"
echo ""
# Resolve affected domain via public DNS
echo "┌───────────────────────────────────────"
echo "├─────── dig ${domain} via 8.8.8.8"
echo ""
dig ${domain} @8.8.8.8
echo "└───────────────────────────────────────"
echo ""
# Resolve affected domain directly
echo "┌───────────────────────────────────────"
echo "├─────── dig ${domain} via trace"
echo ""
dig ${domain} +trace
echo "└───────────────────────────────────────"
echo ""
# Output content of affected domain
echo "┌───────────────────────────────────────"
echo "├─────── Output of ${domain}"
echo ""
curl -svk https://${domain} --stderr -
echo ""
echo "└───────────────────────────────────────"
echo ""
# Calculate duration
end=$(date +%s)
duration=$((end-start))
echo ""
echo "┌───────────────────────────────────────"
echo "│ Time elapsed: ${duration} seconds"
echo "│"
echo "├─────── FINISHED"
echo "└───────────────────────────────────────"
echo ""
echo ""
echo ""
echo "File can be found at $(pwd)/vercel-debug.txt"
echo ""