Skip to content

Commit

Permalink
Add metrics for the quick Argo tunnel.
Browse files Browse the repository at this point in the history
  • Loading branch information
fscarmen authored Apr 17, 2023
1 parent 2da1123 commit 3318305
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions argox.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ SERVER_DEFAULT='icook.hk'
UUID_DEFAULT='ffffffff-ffff-ffff-ffff-ffffffffffff'
WS_PATH_DEFAULT='argox'
WORK_DIR='/etc/argox'
CLOUDFLARED_PORT='54321'
TEMP_DIR='/tmp/argox'
IP_API=https://api.ip.sb/geoip; ISP=isp
#IP_API=http://ifconfig.co/json; ISP=asn_org
Expand Down Expand Up @@ -276,7 +277,7 @@ install_argox() {
elif [[ -n "${ARGO_TOKEN}" && -n "${ARGO_DOMAIN}" ]]; then
ARGO_RUNS="$WORK_DIR/cloudflared tunnel --edge-ip-version auto run --token ${ARGO_TOKEN}"
else
ARGO_RUNS="$WORK_DIR/cloudflared tunnel --edge-ip-version auto --no-autoupdate --url http://localhost:8080"
ARGO_RUNS="$WORK_DIR/cloudflared tunnel --edge-ip-version auto --no-autoupdate --metrics localhost:$CLOUDFLARED_PORT --url http://localhost:8080"
fi

cat > /etc/systemd/system/argo.service << EOF
Expand Down Expand Up @@ -514,7 +515,7 @@ export_list() {
check_install

if grep -q "^ExecStart.*8080$" /etc/systemd/system/argo.service; then
sleep 5 && local LOCALHOST=$(ss -nltp | grep '"cloudflared"' | awk '{print $4}') && ARGO_DOMAIN=$(wget -qO- http://$LOCALHOST/quicktunnel | cut -d\" -f4)
sleep 5 && ARGO_DOMAIN=$(wget -qO- http://localhost:$CLOUDFLARED_PORT/quicktunnel | cut -d\" -f4)
else
ARGO_DOMAIN=${ARGO_DOMAIN:-"$(grep '^vless' $WORK_DIR/list | head -n 1 | sed "s@.*host=\(.*\)&.*@\1@g")"}
fi
Expand Down Expand Up @@ -568,15 +569,15 @@ change_argo() {
case $(grep "ExecStart" /etc/systemd/system/argo.service) in
*--config* ) ARGO_TYPE='Json'; ARGO_DOMAIN="$(grep '^vless' $WORK_DIR/list | head -n 1 | sed "s@.*host=\(.*\)&.*@\1@g")" ;;
*--token* ) ARGO_TYPE='Token'; ARGO_DOMAIN="$(grep '^vless' $WORK_DIR/list | head -n 1 | sed "s@.*host=\(.*\)&.*@\1@g")" ;;
* ) ARGO_TYPE='Try'; local LOCALHOST=$(ss -nltp | grep '"cloudflared"' | awk '{print $4}') && ARGO_DOMAIN=$(wget -qO- http://$LOCALHOST/quicktunnel | cut -d\" -f4) ;;
* ) ARGO_TYPE='Try'; ARGO_DOMAIN=$(wget -qO- http://localhost:$CLOUDFLARED_PORT/quicktunnel | cut -d\" -f4) ;;
esac

hint "\n $(text_eval 40) \n"
unset ARGO_DOMAIN
hint " $(text 41) \n" && reading " $(text 24) " CHANGE_TO
case "$CHANGE_TO" in
1 ) systemctl disable --now argo
sed -i "s@ExecStart.*@ExecStart=$WORK_DIR/cloudflared tunnel --edge-ip-version auto --no-autoupdate --url http://localhost:8080@g" /etc/systemd/system/argo.service
sed -i "s@ExecStart.*@ExecStart=$WORK_DIR/cloudflared tunnel --edge-ip-version auto --no-autoupdate --metrics localhost:$CLOUDFLARED_PORT --url http://localhost:8080@g" /etc/systemd/system/argo.service
systemctl enable --now argo
;;
2 ) argo_variable
Expand Down Expand Up @@ -642,8 +643,7 @@ menu_setting() {
if [[ ${STATUS[*]} =~ $(text 27)|$(text 28) ]]; then
if [ -e $WORK_DIR/cloudflared ]; then
ARGO_VERSION=$($WORK_DIR/cloudflared -v | awk '{print $3}' | sed "s@^@Version: &@g")
local LOCALHOST=$(ss -nltp | grep '"cloudflared"' | awk '{print $4}')
[ -n "$LOCALHOST" ] && ARGO_CHECKHEALTH="$(text 46): $(wget -qO- http://$LOCALHOST/healthcheck | sed "s/OK/$(text 37)/")"
ss -nltp | grep -q "127\.0\.0\.1:$CLOUDFLARED_PORT.*cloudflared" && ARGO_CHECKHEALTH="$(text 46): $(wget -qO- http://localhost:$CLOUDFLARED_PORT/healthcheck | sed "s/OK/$(text 37)/")"
fi
[ -e $WORK_DIR/xray ] && XRAY_VERSION=$($WORK_DIR/xray version | awk 'NR==1 {print $2}' | sed "s@^@Version: &@g")
OPTION[1]="1. $(text 29)"
Expand Down

0 comments on commit 3318305

Please sign in to comment.