Initial commit: OpenWrt firewall management scripts

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-08 18:19:24 +08:00
commit 0359abb7dc
6 changed files with 560 additions and 0 deletions

34
test_connection.sh Executable file
View File

@@ -0,0 +1,34 @@
#!/bin/bash
# --- 這裡要改成你真正有開的 Port ---
TARGET_IP="125.229.110.50"
# PORTS=("51433")
PORTS=("51433" "31433")
echo "--- [第一步:身份確認] ---"
MY_INFO=$(curl -s https://ip.lotimmy.com/json)
MY_IP=$(echo $MY_INFO | jq -r '.ip')
MY_REGION=$(echo $MY_INFO | jq -r '.region_name')
MY_ASN=$(echo $MY_INFO | jq -r '.asn_org')
echo "目前位置:$MY_REGION ($MY_ASN)"
echo "對外 IP $MY_IP"
# 判斷是否為台灣 IP
SHOULD_PASS=false
if [[ "$MY_REGION" == *"Taipei"* ]] || [[ "$MY_ASN" == *"Data Communication"* ]]; then
SHOULD_PASS=true
fi
echo -e "\n--- [第二步:連線測試] ---"
for PORT in "${PORTS[@]}"
do
# 測試連線
nc -zv -w 5 $TARGET_IP $PORT > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo "[成功] Port $PORT 連線正常。"
else
echo -n "[攔截] Port $PORT 無法連線。"
[ "$SHOULD_PASS" = true ] && echo " (錯誤:你是台灣 IP 卻被擋掉!)" || echo ""
fi
done