mirror of
https://github.com/hotyue/IP-Sentinel.git
synced 2026-09-05 23:49:56 +08:00
chore(legacy): 降级 Python 语法并抢修 Debian 9 APT 源,以兼容传家宝老旧系统
This commit is contained in:
@@ -115,7 +115,7 @@ class AgentHandler(http.server.BaseHTTPRequestHandler):
|
|||||||
return
|
return
|
||||||
|
|
||||||
# 校验 3:HMAC 数据完整性与身份合法性校验
|
# 校验 3:HMAC 数据完整性与身份合法性校验
|
||||||
msg = f"{req_path}:{req_t}".encode('utf-8')
|
msg = "{}:{}".format(req_path, req_t).encode('utf-8')
|
||||||
expected_sign = hmac.new(AUTH_TOKEN.encode('utf-8'), msg, hashlib.sha256).hexdigest()
|
expected_sign = hmac.new(AUTH_TOKEN.encode('utf-8'), msg, hashlib.sha256).hexdigest()
|
||||||
|
|
||||||
# 使用 compare_digest 防御时序攻击
|
# 使用 compare_digest 防御时序攻击
|
||||||
@@ -189,7 +189,7 @@ class AgentHandler(http.server.BaseHTTPRequestHandler):
|
|||||||
log_data = html.escape("".join(lines[-15:]))
|
log_data = html.escape("".join(lines[-15:]))
|
||||||
|
|
||||||
node_name = subprocess.check_output(['hostname']).decode('utf-8').strip()[:15]
|
node_name = subprocess.check_output(['hostname']).decode('utf-8').strip()[:15]
|
||||||
text_msg = f"📄 <b>[{node_name}] 实时运行日志:</b>\n<pre><code>{log_data}</code></pre>"
|
text_msg = "📄 <b>[{}] 实时运行日志:</b>\n<pre><code>{}</code></pre>".format(node_name, log_data)
|
||||||
|
|
||||||
data = urllib.parse.urlencode({
|
data = urllib.parse.urlencode({
|
||||||
'chat_id': config.get('CHAT_ID', ''),
|
'chat_id': config.get('CHAT_ID', ''),
|
||||||
@@ -205,7 +205,7 @@ class AgentHandler(http.server.BaseHTTPRequestHandler):
|
|||||||
urllib.request.urlopen(req, timeout=10)
|
urllib.request.urlopen(req, timeout=10)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Log transmission failed: {e}")
|
print("Log transmission failed: {}".format(e))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
self.send_response(404)
|
self.send_response(404)
|
||||||
|
|||||||
@@ -18,6 +18,17 @@ echo "========================================================"
|
|||||||
|
|
||||||
# 1. 依赖检查与安装 (新增 python3 用于轻量级 Webhook 服务)
|
# 1. 依赖检查与安装 (新增 python3 用于轻量级 Webhook 服务)
|
||||||
echo -e "\n[1/7] 正在安装必要环境依赖 (curl, jq, cron, procps, python3)..."
|
echo -e "\n[1/7] 正在安装必要环境依赖 (curl, jq, cron, procps, python3)..."
|
||||||
|
|
||||||
|
# ================== [Legacy: Debian 9 APT 源抢修补丁] ==================
|
||||||
|
if [ -f /etc/debian_version ] && grep -q -E "^9\." /etc/debian_version; then
|
||||||
|
echo -e "\033[33m⚠️ 检测到 Debian 9 (Stretch),正在抢修已停用的 APT 档案馆源...\033[0m"
|
||||||
|
echo "deb http://archive.debian.org/debian stretch main" > /etc/apt/sources.list
|
||||||
|
echo "deb http://archive.debian.org/debian-security stretch/updates main" >> /etc/apt/sources.list
|
||||||
|
sed -i '/stretch-updates/d' /etc/apt/sources.list
|
||||||
|
echo 'Acquire::Check-Valid-Until "false";' > /etc/apt/apt.conf.d/99no-check-valid-until
|
||||||
|
fi
|
||||||
|
# =======================================================================
|
||||||
|
|
||||||
if [ -f /etc/debian_version ]; then
|
if [ -f /etc/debian_version ]; then
|
||||||
apt-get update -y >/dev/null 2>&1
|
apt-get update -y >/dev/null 2>&1
|
||||||
apt-get install -y curl jq cron procps python3 >/dev/null 2>&1
|
apt-get install -y curl jq cron procps python3 >/dev/null 2>&1
|
||||||
|
|||||||
Reference in New Issue
Block a user