blob: acc523961579792dc6366cb37199a01084b6eec9 [file] [log] [blame]
Erik Kline871e63d2016-01-22 09:07:44 +09001#!/bin/bash
2
3nethandle=0
4
5readonly TEST_HOST="connectivitycheck.gstatic.com"
6readonly TEST_PATH="/generate_204"
7readonly PREFIX=">>>"
8
9function getUrls() {
10 if [ ! -z $(echo "$1" | sed -e 's/[^:]//g') ]; then
11 echo "http://[$1]$TEST_PATH"
12 echo "http://[$1]:80$TEST_PATH"
13 else
14 echo "http://$1$TEST_PATH"
15 echo "http://$1:80$TEST_PATH"
16 fi
17}
18
19function toHex() {
20 readonly local hexValue=$(bc -q 2>/dev/null << EOT
21obase=16
22$1
23EOT
24)
25 if [ ! -z "$hexValue" ]; then
26 echo "0x$hexValue"
27 fi
28}
29
30
31if [ ! -z "$1" ]; then
32 nethandle="$1"
33fi
34echo "$PREFIX Using nethandle $nethandle ($(toHex $nethandle))"
35echo ""
36
37readonly IPADDRESSES=$(
Dan Willemsen9f022b42018-05-09 16:26:42 -070038 adb shell /system/bin/dnschk --nethandle $nethandle $TEST_HOST |
Erik Kline871e63d2016-01-22 09:07:44 +090039 sed -e 's/#.*//' -e '/^$/d')
40
41
42for host in $TEST_HOST $IPADDRESSES; do
43 urls=$(getUrls $host)
44 for url in $urls; do
45 echo "$PREFIX Checking $url" >&2
Dan Willemsen9f022b42018-05-09 16:26:42 -070046 adb shell /system/bin/httpurl --nethandle $nethandle "$url"
Erik Kline871e63d2016-01-22 09:07:44 +090047 done
48done