fix(douyu): 修复斗鱼链路 P0/P1 隐患并增强 P2 运维队列可观测性
This commit is contained in:
@@ -52,10 +52,11 @@ class XiequAdapter(BaseWhitelistAdapter):
|
||||
"""
|
||||
try:
|
||||
url = self._build_url(act="getjson")
|
||||
response = requests.get(url, timeout=10)
|
||||
response.raise_for_status()
|
||||
|
||||
text = response.text.strip()
|
||||
with requests.Session() as sess:
|
||||
sess.trust_env = False
|
||||
with sess.get(url, timeout=10) as response:
|
||||
response.raise_for_status()
|
||||
text = response.text.strip()
|
||||
if not text or text == "[]":
|
||||
return []
|
||||
|
||||
@@ -83,10 +84,11 @@ class XiequAdapter(BaseWhitelistAdapter):
|
||||
"""添加IP到白名单。"""
|
||||
try:
|
||||
url = self._build_url(act="add", ip=ip, meno=self.memo)
|
||||
response = requests.get(url, timeout=10)
|
||||
response.raise_for_status()
|
||||
|
||||
text = response.text.strip()
|
||||
with requests.Session() as sess:
|
||||
sess.trust_env = False
|
||||
with sess.get(url, timeout=10) as response:
|
||||
response.raise_for_status()
|
||||
text = response.text.strip()
|
||||
logger.debug(f"添加白名单响应: {text}")
|
||||
|
||||
if "ok" in text.lower() or "success" in text.lower() or "添加成功" in text:
|
||||
@@ -128,10 +130,11 @@ class XiequAdapter(BaseWhitelistAdapter):
|
||||
"""删除白名单IP。"""
|
||||
try:
|
||||
url = self._build_url(act="del", ip=ip)
|
||||
response = requests.get(url, timeout=10)
|
||||
response.raise_for_status()
|
||||
|
||||
text = response.text.strip()
|
||||
with requests.Session() as sess:
|
||||
sess.trust_env = False
|
||||
with sess.get(url, timeout=10) as response:
|
||||
response.raise_for_status()
|
||||
text = response.text.strip()
|
||||
logger.debug(f"删除白名单响应: {text}")
|
||||
|
||||
if "ok" in text.lower() or "success" in text.lower() or "删除成功" in text:
|
||||
|
||||
Reference in New Issue
Block a user