From a7884e2cabf23d0ef9b5fe2c2a0329033d2f9e81 Mon Sep 17 00:00:00 2001 From: Recolic Keghart <root@recolic.net> Date: Fri, 31 May 2019 21:01:53 +0800 Subject: [PATCH] better ping, add rocket, remove ddns-usa --- datafile_gen_daemon_conf.py | 2 +- do.bash | 53 ++++++++++++++++++++++++++----------- 2 files changed, 39 insertions(+), 16 deletions(-) diff --git a/datafile_gen_daemon_conf.py b/datafile_gen_daemon_conf.py index a00fb3c..bab6baa 100644 --- a/datafile_gen_daemon_conf.py +++ b/datafile_gen_daemon_conf.py @@ -16,7 +16,7 @@ tests = [ ('./do.bash mc', 'Minecraft Server'), ('./do.bash push-httpdb-agent', 'httpdb'), ('./do.bash ddns-wuhan', 'DDNS WuHan'), - ('./do.bash ddns-us', 'DDNS USA'), + ('./do.bash rocket', 'Recolic Rocket Chat'), ('./do.bash dl', 'Download Site'), ('./do.bash shortlink', 'Short Link'), ] diff --git a/do.bash b/do.bash index 656e778..fa34d59 100755 --- a/do.bash +++ b/do.bash @@ -1,14 +1,15 @@ #!/bin/bash -[[ $1 == '' ]] && echo -e 'Usage: '"$0 <operation> ...\n operation := rproxy | drive | ss-tw | ss-us1 | ss-us5 | ss-us6 | ovpn-tw | www | mail | tm | git | zhixiang | mc | push-httpdb-agent | ddns-wuhan | ddns-us | dl | shortlink | all" && exit 1 +[[ $1 == '' ]] && echo -e 'Usage: '"$0 <operation> ...\n operation := rproxy | drive | ss-tw | ss-us1 | ss-us5 | ss-us6 | ovpn-tw | www | mail | tm | git | zhixiang | mc | push-httpdb-agent | ddns-wuhan | rocket | dl | shortlink | all" && exit 1 function confirm_alive () { local host="$1" - timeout 4s ping "$host" -c 2 + timeout 4s ping "$host" -c 1 local ret="$?" - [[ $ret != 124 ]] && return $ret + [[ $ret != 124 ]] && [[ $ret != 2 ]] && return $ret for i in {1..4}; do - timeout 2s ping "$host" -c 1 && return 0 + timeout 3s ping "$host" -c 1 && return 0 + sleep 1 done return 124 } @@ -69,23 +70,36 @@ function do_test () { curl -s -L http://recolic.net/ | grep 'Follow me on github' || return $? ;; mail ) + confirm_alive smtp.recolic.net && + confirm_alive imap.recolic.net && + confirm_alive mail.recolic.net && + confirm_alive pop3.recolic.net || return $? + # Fucking DigitalOcean - # test_tcp smtp.recolic.net 25 | grep 220 || return $? - test_tcp smtp.recolic.net 587 | grep 220 || return $? - # test_tcp imap.recolic.net 143 | grep OK || return $? + if test_tcp smtp-mail.outlook.com 25 | grep 220; then + test_tcp smtp.recolic.net 25 | grep 220 || return $? + fi + test_tcp smtp.recolic.net 587 || return $? + if test_tcp imap-mail.outlook.com 143 | grep OK; then + test_tcp imap.recolic.net 143 | grep OK || return $? + fi test_tcp imap.recolic.net 993 || return $? - # test_tcp pop3.recolic.net 110 | grep OK || return $? + if test_tcp pop3.live.com 110 | grep OK; then + test_tcp pop3.recolic.net 110 | grep OK || return $? + fi test_tcp pop3.recolic.net 995 || return $? curl -s https://mail.recolic.net/mail/ | grep 'Welcome to Roundcube' || return $? curl http://mail.recolic.net/ -vv 2>&1 | grep 'https://mail.recolic.net/' || return $? ;; tm ) + confirm_alive tm.recolic.net && curl -s https://tm.recolic.net/ | grep inputButtonCss && curl -s http://tm.recolic.net/ -L | grep inputButtonCss || return $? curl -s 'https://tm.recolic.net/addtask?openid=23251fc131e118d07fc9932f3c3de92c&N=30.508914&E=114.40718&key=FUCKYOU' | grep 'invalid key' || return $? ;; git ) + confirm_alive git.recolic.net && curl -s https://git.recolic.net/ | grep 'users/sign_in' && curl -s http://git.recolic.net/ -L | grep 'users/sign_in' || return $? ;; @@ -95,30 +109,39 @@ function do_test () { curl -k -X POST -s 'https://api.anjie-elec.cn/api/usewater/Add?accessToken=FUCKYOU' | grep '104871845A503324' || return $? ;; mc ) + confirm_alive mc.recolic.net && test_tcp mc.recolic.net 25565 || return $? ;; push-httpdb-agent ) local r="$RANDOM" + confirm_alive git.recolic.net && curl -s "https://git.recolic.net/_r_testing/set/_status_test|$r" && local result=$(curl -s "https://git.recolic.net/_r_testing/get/_status_test") || return $? [[ $r = $result ]] return $? ;; ddns-wuhan ) + confirm_alive base.ddns1.recolic.net && test_tcp base.ddns1.recolic.net 22 || return $? ;; - ddns-us ) - test_tcp base.ddns2.recolic.net 22 | grep SSH && - test_tcp base.ddns2.recolic.net 80 && - test_tcp nohsts.ddns2.recolic.org 22 | grep SSH && - test_tcp nohsts.ddns2.recolic.org 80 || return $? - ;; + #ddns-us ) + # test_tcp base.ddns2.recolic.net 22 | grep SSH && + # test_tcp base.ddns2.recolic.net 80 && + # test_tcp nohsts.ddns2.recolic.org 22 | grep SSH && + # test_tcp nohsts.ddns2.recolic.org 80 || return $? + # ;; dl ) + confirm_alive dl.recolic.net && curl -s -L https://dl.recolic.net/ | grep 'Home page is not provided for this download site' || return $? ;; shortlink ) + confirm_alive recolic.net && curl -s 'https://recolic.net/go/index.php' --data 'target=https%3A%2F%2Fwww.google.com&name=google&super=' | grep Success || return $? ;; + rocket ) + confirm_alive rocket.recolic.net && + curl -s https://rocket.recolic.net/api/info | grep 'success":true' || return $? + ;; esac } @@ -143,7 +166,7 @@ if [[ "$1" = all ]]; then do_test_twice mc && do_test_twice push-httpdb-agent && do_test_twice ddns-wuhan && - do_test_twice ddns-us && + do_test_twice rocket && do_test_twice shortlink && do_test_twice dl exit $? -- GitLab