3 # To test a local moat server, simply do:
7 # To test the production server, run the externalize-pt-client.sh script like so:
9 # ./externalize-pt-client.orig.sh /path/to/meek-client \
10 # -url https://tor-bridges-hyphae-channel.appspot.com/ -front www.google.com
12 # and then call this script with:
14 # TEST_PRODUCTION_MOAT=1 test-moat fetch
23 if test -n "$TEST_PRODUCTION_MOAT" ; then
25 SERVER
=bridges.torproject.org
28 PROXY
='--proxy socks4a://127.0.0.1:10000/'
32 printf "Usage: %s [fetch] [check [challenge solution]]\n" "$(basename $0)"
35 if test "$#" -lt 1 ; then
43 -H 'Content-Type: application/vnd.api+json' \
44 -H 'Accept: application/vnd.api+json' \
45 -H 'X-Forwarded-For: 1.2.3.4' \
46 --data '{"data": [{"supported": ["obfs4"], "version": "0.1.0", "type": "client-transports"}]}' \
47 $METHOD://${SERVER:=127.0.0.1}:${PORT:=6790}$URL_PREFIX/fetch
54 -H 'Content-Type: application/vnd.api+json' \
55 -H 'Accept: application/vnd.api+json' \
56 -H 'X-Forwarded-For: 1.2.3.4' \
57 --data '{"data": [{"challenge": "'${CHALLENGE:=foo}'", "solution": "'${SOLUTION:=bar}'", "version": "0.1.0", "qrcode": "false", "type": "moat-solution", "id": 2, "transport": "obfs4"}]}' \
58 $METHOD://${SERVER:=127.0.0.1}:${PORT:=6790}$URL_PREFIX/check
62 while test -n "$1" ; do
67 check) if [[ "$2" != "fetch" ]] ; then
69 if [[ "$3" != "fetch" ]] ; then
73 for var in "$CHALLENGE" "$SOLUTION" ; do
74 if test -n "$var"; then
75 OPTSHIFT=$(( OPTSHIFT + 1 ))