chore: remove session reuse and pin proxy to 7898 for lark notifier
This commit is contained in:
1 parent
77d084341c
commit
ad84ee62c4
1 file changed
+8
-5
+8
-5
@@ -8,9 +8,12 @@ class LarkNotifier:
|
|||||||
self.url = "https://zhiyinzhe.xyz/sendMsg/api/send"
|
self.url = "https://zhiyinzhe.xyz/sendMsg/api/send"
|
||||||
self.bot_name = bot_name
|
self.bot_name = bot_name
|
||||||
self.receive_id = receive_id
|
self.receive_id = receive_id
|
||||||
|
|
||||||
# 使用 Session 可以复用底层 TCP 连接,提升发送效率
|
# 代理固定为本地 7898 端口
|
||||||
self.session = requests.Session()
|
self.proxies = {
|
||||||
|
"http": "socks5h://127.0.0.1:7898",
|
||||||
|
"https": "socks5h://127.0.0.1:7898"
|
||||||
|
}
|
||||||
|
|
||||||
def send_alert(self, title: str, content: str):
|
def send_alert(self, title: str, content: str):
|
||||||
"""
|
"""
|
||||||
@@ -26,8 +29,8 @@ class LarkNotifier:
|
|||||||
}
|
}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# 使用 data=payload 发送 Form Data
|
# 每次请求直接调用 requests.post,不复用 Session
|
||||||
response = self.session.post(self.url, data=payload, timeout=5)
|
response = requests.post(self.url, data=payload, timeout=5, proxies=self.proxies)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
print(f"告警发送成功: {title}")
|
print(f"告警发送成功: {title}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
Reference in new issue
Block a user