feat: 优化代理

This commit is contained in:
helloplhm-qwq 2023-11-26 12:08:50 +08:00 committed by Folltoshe
parent 6de45a86e5
commit 73f65b941d
2 changed files with 19 additions and 2 deletions

View File

@ -176,7 +176,7 @@ def checkcn():
body = utils.jsobject(req.json())
variable.iscn = bool(body.flag)
if (not variable.iscn):
variable.fakeip = "1.0.2.114"
variable.fakeip = config.read_config('common.fakeip')
logger.info("您在非中国大陆服务器上启动了项目已自动开启ip伪装")
logger.warning("此方式无法解决咪咕音乐的链接获取问题,您可以配置代理,服务器地址可在下方链接中找到\nhttps://hidemy.io/cn/proxy-list/?country=CN#list")
except Exception as e:

View File

@ -56,6 +56,14 @@ default = {
"_debug_mode-desc": "是否开启调试模式",
"log_length_limit": 500,
"_log_length_limit-desc": "单条日志长度限制",
"fakeip": "1.0.1.114",
"_fakeip-desc": "服务器在海外时的IP伪装值",
"proxy": {
"enable": False,
"http_addr": "http://127.0.0.1:7890",
"https_addr": "https://127.0.0.1:7890",
},
"_proxy-desc": "代理配置HTTP与HTTPS协议需分开配置",
},
"security": {
"key": {
@ -522,7 +530,16 @@ value TEXT)''')
write_data('banList', [])
write_data('requestTime', {})
logger.info('数据库内容为空,已写入默认值')
# 处理代理配置
if (read_config('common.proxy.enable')):
if (read_config('common.proxy.http_value')):
os.environ['http_proxy'] = read_config('common.proxy.http_value')
logger.info('HTTP协议代理地址: ' + read_config('common.proxy.http_value'))
if (read_config('common.proxy.https_value')):
os.environ['https_proxy'] = read_config('common.proxy.https_value')
logger.info('HTTPS协议代理地址: ' + read_config('common.proxy.https_value'))
logger.info('代理功能已开启,请确保代理地址正确,否则无法连接网络')
def ban_ip(ip_addr, ban_time=-1):
if read_config('security.banlist.enable'):