From 9687a4fd4f53957538557816a9bd47cd6e92fe4a Mon Sep 17 00:00:00 2001 From: sushen339 Date: Tue, 18 Nov 2025 02:52:39 +0800 Subject: [PATCH] --- README.md | 12 ++++++++++++ block-ip.sh | 8 ++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b20959c..b804e99 100644 --- a/README.md +++ b/README.md @@ -110,4 +110,16 @@ bash <(curl -fsSL "https://raw.githubusercontent.com/sushen339/tools/main/nft.sh bash <(curl -fsSL "https://gh-proxy.com/https://raw.githubusercontent.com/sushen339/tools/main/nft.sh") ``` +## 8. block-ip.sh —— 基于SSH登陆的IP 封禁脚本 +一键运行: + +```bash +bash <(curl -fsSL "https://raw.githubusercontent.com/sushen339/tools/main/block-ip.sh") +``` +代理加速: + +```bash +bash <(curl -fsSL "https://gh-proxy.com/https://raw.githubusercontent.com/sushen339/tools/main/block-ip.sh") +``` + > 建议所有脚本以 root 权限运行,详细参数和说明请阅读各脚本头部注释。 diff --git a/block-ip.sh b/block-ip.sh index 7edff0b..b6cb34a 100644 --- a/block-ip.sh +++ b/block-ip.sh @@ -326,13 +326,13 @@ $RAW_V6" if [ -f "$PERSIST_FILE" ] && [ -s "$PERSIST_FILE" ]; then # 从 PERSIST_FILE 提取国家代码并统计 - COUNTRY_DATA=$(grep '|' "$PERSIST_FILE" | cut -d'|' -f2) + COUNTRY_DATA=$(grep '|' "$PERSIST_FILE" 2>/dev/null | cut -d'|' -f2) if [ -n "$COUNTRY_DATA" ]; then echo "$COUNTRY_DATA" | sort | uniq -c | sort -rn | while read -r count code; do - [ -n "$count" ] && [ -n "$code" ] && { + if [ -n "$count" ] && [ -n "$code" ]; then COUNTRY_NAME=$(get_country_name "$code") - printf " - %-15s %b(%s 个)%b\n" "$COUNTRY_NAME" "$C_RED" "$count" "$C_RESET" - } + printf " - %-15s \033[31m(%s 个)\033[0m\n" "$COUNTRY_NAME" "$count" + fi done else echo "(暂无国家信息)"