diff --git a/script/test.sh b/script/test.sh index af92149..015c0bb 100755 --- a/script/test.sh +++ b/script/test.sh @@ -1,6 +1,6 @@ #!/bin/bash -OPTION="-p 8389 -k foobar -d" +OPTION="-p 8389 -k foobar" LOCAL_PORT="1090" SOCKS="127.0.0.1:$LOCAL_PORT" @@ -14,25 +14,21 @@ test_get() { code="200" fi - # get 5 times - for i in {1..2}; do - # -s silent to disable progress meter, but enable --show-error - # -i to include http header - # -L to follow redirect so we should always get HTTP 200 - cont=`curl --socks5 $SOCKS -s --show-error -i -L $url 2>&1` - ok=`echo $cont | grep -E -o "HTTP/1\.1 +$code"` - html=`echo $cont | grep -E -o -i "$target"` - if [[ -z $ok || -z $html ]] ; then - echo "==============================" - echo "GET $url FAILED!!!" - echo "$ok" - echo "$html" - echo $cont - echo "==============================" - return 1 - fi - sleep 0.3 - done + # -s silent to disable progress meter, but enable --show-error + # -i to include http header + # -L to follow redirect so we should always get HTTP 200 + cont=`curl --socks5 $SOCKS -s --show-error -i -L $url 2>&1` + ok=`echo $cont | grep -E -o "HTTP/1\.1 +$code"` + html=`echo $cont | grep -E -o -i "$target"` + if [[ -z $ok || -z $html ]] ; then + echo "==============================" + echo "GET $url FAILED!!!" + echo "$ok" + echo "$html" + echo $cont + echo "==============================" + return 1 + fi return 0 } @@ -44,21 +40,22 @@ test_shadowsocks() { url=$1 method=$2 - shadowsocks-server $OPTION -m "$method" & + $SERVER $OPTION -m "$method" & server_pid=$! - shadowsocks-local $OPTION -s 127.0.0.1 -l $LOCAL_PORT -m "$method" & + $LOCAL $OPTION -s 127.0.0.1 -l $LOCAL_PORT -m "$method" & local_pid=$! # wait server and client finish startup sleep 1 # get 5 times - for i in {1..5}; do + for i in {1..2}; do if ! test_get $url "