quick_test.sh 1005 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/bin/bash
  2. nethandle=0
  3. readonly TEST_HOST="connectivitycheck.gstatic.com"
  4. readonly TEST_PATH="/generate_204"
  5. readonly PREFIX=">>>"
  6. function getUrls() {
  7. if [ ! -z $(echo "$1" | sed -e 's/[^:]//g') ]; then
  8. echo "http://[$1]$TEST_PATH"
  9. echo "http://[$1]:80$TEST_PATH"
  10. else
  11. echo "http://$1$TEST_PATH"
  12. echo "http://$1:80$TEST_PATH"
  13. fi
  14. }
  15. function toHex() {
  16. readonly local hexValue=$(bc -q 2>/dev/null << EOT
  17. obase=16
  18. $1
  19. EOT
  20. )
  21. if [ ! -z "$hexValue" ]; then
  22. echo "0x$hexValue"
  23. fi
  24. }
  25. if [ ! -z "$1" ]; then
  26. nethandle="$1"
  27. fi
  28. echo "$PREFIX Using nethandle $nethandle ($(toHex $nethandle))"
  29. echo ""
  30. readonly IPADDRESSES=$(
  31. adb shell /system/bin/dnschk --nethandle $nethandle $TEST_HOST |
  32. sed -e 's/#.*//' -e '/^$/d')
  33. for host in $TEST_HOST $IPADDRESSES; do
  34. urls=$(getUrls $host)
  35. for url in $urls; do
  36. echo "$PREFIX Checking $url" >&2
  37. adb shell /system/bin/httpurl --nethandle $nethandle "$url"
  38. done
  39. done