feat: 更新版本号到8.0.1
This commit is contained in:
68
config.py
68
config.py
@@ -13,6 +13,16 @@ urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
||||
|
||||
class Config:
|
||||
def __init__(self):
|
||||
# 默认配置
|
||||
self.default_config = {
|
||||
"TEMP_MAIL": "demo",
|
||||
"TEMP_MAIL_EXT": "@mailto.plus",
|
||||
"TEMP_MAIL_EPIN": "",
|
||||
"DOMAIN": "mailto.plus",
|
||||
"BROWSER_USER_AGENT": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
|
||||
"MAIL_SERVER": "https://tempmail.plus"
|
||||
}
|
||||
|
||||
# 获取应用程序的根目录路径
|
||||
if getattr(sys, "frozen", False):
|
||||
# 如果是打包后的可执行文件
|
||||
@@ -23,8 +33,8 @@ class Config:
|
||||
|
||||
# 配置重试策略
|
||||
retry_strategy = Retry(
|
||||
total=3,
|
||||
backoff_factor=1,
|
||||
total=2, # 减少重试次数
|
||||
backoff_factor=0.5, # 减少等待时间
|
||||
status_forcelist=[429, 500, 502, 503, 504],
|
||||
)
|
||||
|
||||
@@ -41,39 +51,43 @@ class Config:
|
||||
|
||||
# 从API获取配置
|
||||
try:
|
||||
# 使用session发送请求
|
||||
# 使用session发送请求,减少超时时间
|
||||
response = self.session.get(
|
||||
"https://cursorapi.nosqli.com/admin/api.mail/getRandom",
|
||||
timeout=30,
|
||||
timeout=10,
|
||||
allow_redirects=True
|
||||
)
|
||||
data = response.json()
|
||||
|
||||
if data['code'] != 0:
|
||||
raise Exception(data['msg'])
|
||||
if data['code'] == 0:
|
||||
config = data['data']['env']
|
||||
else:
|
||||
logging.warning(f"API返回错误: {data.get('msg', '未知错误')}")
|
||||
logging.info("使用默认配置继续运行...")
|
||||
config = self.default_config
|
||||
|
||||
config = data['data']['env']
|
||||
|
||||
# 设置配置项
|
||||
self.imap = False
|
||||
self.temp_mail = config.get("TEMP_MAIL", "").strip()
|
||||
self.temp_mail_ext = config.get("TEMP_MAIL_EXT", "").strip()
|
||||
self.temp_mail_epin = config.get("TEMP_MAIL_EPIN", "").strip()
|
||||
self.domain = config.get("DOMAIN", "").strip()
|
||||
self.browser_user_agent = config.get("BROWSER_USER_AGENT", "").strip()
|
||||
self.mail_server = config.get("MAIL_SERVER", "").strip()
|
||||
|
||||
# 如果临时邮箱为null则加载IMAP
|
||||
if self.temp_mail == "null":
|
||||
self.imap = True
|
||||
self.imap_server = config.get("IMAP_SERVER", "").strip()
|
||||
self.imap_port = config.get("IMAP_PORT", "").strip()
|
||||
self.imap_user = config.get("IMAP_USER", "").strip()
|
||||
self.imap_pass = config.get("IMAP_PASS", "").strip()
|
||||
self.imap_dir = config.get("IMAP_DIR", "inbox").strip()
|
||||
except Exception as e:
|
||||
logging.error(f"从API获取配置失败: {e}")
|
||||
raise e
|
||||
logging.warning(f"从API获取配置失败: {str(e)}")
|
||||
logging.info("使用默认配置继续运行...")
|
||||
config = self.default_config
|
||||
|
||||
# 设置配置项
|
||||
self.imap = False
|
||||
self.temp_mail = config.get("TEMP_MAIL", self.default_config["TEMP_MAIL"]).strip()
|
||||
self.temp_mail_ext = config.get("TEMP_MAIL_EXT", self.default_config["TEMP_MAIL_EXT"]).strip()
|
||||
self.temp_mail_epin = config.get("TEMP_MAIL_EPIN", self.default_config["TEMP_MAIL_EPIN"]).strip()
|
||||
self.domain = config.get("DOMAIN", self.default_config["DOMAIN"]).strip()
|
||||
self.browser_user_agent = config.get("BROWSER_USER_AGENT", self.default_config["BROWSER_USER_AGENT"]).strip()
|
||||
self.mail_server = config.get("MAIL_SERVER", self.default_config["MAIL_SERVER"]).strip()
|
||||
|
||||
# 如果临时邮箱为null则加载IMAP
|
||||
if self.temp_mail == "null":
|
||||
self.imap = True
|
||||
self.imap_server = config.get("IMAP_SERVER", "").strip()
|
||||
self.imap_port = config.get("IMAP_PORT", "").strip()
|
||||
self.imap_user = config.get("IMAP_USER", "").strip()
|
||||
self.imap_pass = config.get("IMAP_PASS", "").strip()
|
||||
self.imap_dir = config.get("IMAP_DIR", "inbox").strip()
|
||||
|
||||
self.check_config()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user