diff --git a/utils/send_msg.py b/utils/send_msg.py index 5cdeeb7..2e39f1f 100644 --- a/utils/send_msg.py +++ b/utils/send_msg.py @@ -8,9 +8,12 @@ class LarkNotifier: self.url = "https://zhiyinzhe.xyz/sendMsg/api/send" self.bot_name = bot_name self.receive_id = receive_id - - # 使用 Session 可以复用底层 TCP 连接,提升发送效率 - self.session = requests.Session() + + # 代理固定为本地 7898 端口 + self.proxies = { + "http": "socks5h://127.0.0.1:7898", + "https": "socks5h://127.0.0.1:7898" + } def send_alert(self, title: str, content: str): """ @@ -26,8 +29,8 @@ class LarkNotifier: } try: - # 使用 data=payload 发送 Form Data - response = self.session.post(self.url, data=payload, timeout=5) + # 每次请求直接调用 requests.post,不复用 Session + response = requests.post(self.url, data=payload, timeout=5, proxies=self.proxies) response.raise_for_status() print(f"告警发送成功: {title}") except Exception as e: