优化代理获取和登录逻辑
- 每个账号独立获取代理,不再共用一个代理IP - 代理预检失败只标记该账号失败,不终止整个批次 - 代理验证改为并发:verify_proxies_concurrent 多IP同时验证 - resolve_working_proxy 多IP并发验证,找到可用即返回 - parse_proxy_response 改为返回列表,支持多行/逗号分隔 - 邮箱验证码匹配收件人地址,防止多账号并发取错验证码 - 修正 mail.bdhg.xyz 旧数据端口和SSL配置 - bdhg.xyz 默认配置改为 143端口非SSL Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
9f6b405571
commit
8fdf8d4b69
@@ -158,9 +158,10 @@ class EmailVerifier:
|
||||
|
||||
subject = self._decode_subject(msg.get('Subject', ''))
|
||||
from_addr = msg.get('From', '')
|
||||
to_addr = msg.get('To', '') or msg.get('Delivered-To', '') or ''
|
||||
body = self._get_email_body(msg)
|
||||
|
||||
if not self._is_douyu_email(subject, from_addr, body):
|
||||
if not self._is_douyu_email(subject, from_addr, body, to_addr=to_addr):
|
||||
continue
|
||||
|
||||
code = self._extract_verification_code(body)
|
||||
@@ -257,8 +258,20 @@ class EmailVerifier:
|
||||
except (TypeError, ValueError):
|
||||
return None
|
||||
|
||||
def _is_douyu_email(self, subject: str, from_addr: str, body: str = "") -> bool:
|
||||
"""判断是否是斗鱼的邮件"""
|
||||
def _is_douyu_email(self, subject: str, from_addr: str, body: str = "", to_addr: str = "") -> bool:
|
||||
"""判断是否是发给当前账号的斗鱼验证码邮件"""
|
||||
# 先检查收件人:多个账号共用同一个IMAP时,必须匹配收件人地址
|
||||
if to_addr and self.username:
|
||||
# to_addr 可能是 "name <email>" 格式,提取邮箱
|
||||
to_email = re.search(r'[\w.+-]+@[\w.-]+', to_addr)
|
||||
if to_email:
|
||||
to_lower = to_email.group(0).lower()
|
||||
my_lower = self.username.lower()
|
||||
# 精确匹配,或者 catch-all 前缀匹配
|
||||
if to_lower != my_lower and not my_lower.endswith('@' + to_lower.split('@')[-1]):
|
||||
logger.debug(f"跳过非当前账号邮件: 收件人={to_lower}, 当前={my_lower}")
|
||||
return False
|
||||
|
||||
douyu_keywords = ['斗鱼', 'douyu', 'douyutv']
|
||||
verify_keywords = ['验证码', '安全验证', '登录验证', '动态码', '校验码']
|
||||
combined = f"{subject}\n{from_addr}\n{body[:500]}".lower()
|
||||
@@ -354,4 +367,15 @@ def get_email_config_for_account(email_address: str) -> dict:
|
||||
}
|
||||
|
||||
domain = email_address.split('@')[-1].lower()
|
||||
return configs.get(domain, {'server': '111.229.206.54', 'port': 143, 'ssl': False})
|
||||
configs = {
|
||||
'qq.com': {'server': 'imap.qq.com', 'port': 993, 'ssl': True},
|
||||
'163.com': {'server': 'imap.163.com', 'port': 993, 'ssl': True},
|
||||
'126.com': {'server': 'imap.126.com', 'port': 993, 'ssl': True},
|
||||
'gmail.com': {'server': 'imap.gmail.com', 'port': 993, 'ssl': True},
|
||||
'outlook.com': {'server': 'outlook.office365.com', 'port': 993, 'ssl': True},
|
||||
'hotmail.com': {'server': 'outlook.office365.com', 'port': 993, 'ssl': True},
|
||||
'bdhg.xyz': {'server': 'mail.bdhg.xyz', 'port': 143, 'ssl': False},
|
||||
}
|
||||
|
||||
domain = email_address.split('@')[-1].lower()
|
||||
return configs.get(domain, {'server': domain, 'port': 143, 'ssl': False})
|
||||
|
||||
Reference in New Issue
Block a user