Skip to content

Commit 4fa5708

Browse files
committed
feat: 代理配置 & feat: fakeip优化
1 parent 6de45a8 commit 4fa5708

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

common/Httpx.py

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

common/config.py

+18-1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@ class ConfigReadException(Exception):
5656
"_debug_mode-desc": "是否开启调试模式",
5757
"log_length_limit": 500,
5858
"_log_length_limit-desc": "单条日志长度限制",
59+
"fakeip": "1.0.1.114",
60+
"_fakeip-desc": "服务器在海外时的IP伪装值",
61+
"proxy": {
62+
"enable": False,
63+
"http_addr": "http://127.0.0.1:7890",
64+
"https_addr": "https://127.0.0.1:7890",
65+
},
66+
"_proxy-desc": "代理配置,HTTP与HTTPS协议需分开配置",
5967
},
6068
"security": {
6169
"key": {
@@ -522,7 +530,16 @@ def initConfig():
522530
write_data('banList', [])
523531
write_data('requestTime', {})
524532
logger.info('数据库内容为空,已写入默认值')
525-
533+
534+
# 处理代理配置
535+
if (read_config('common.proxy.enable')):
536+
if (read_config('common.proxy.http_value')):
537+
os.environ['http_proxy'] = read_config('common.proxy.http_value')
538+
logger.info('HTTP协议代理地址: ' + read_config('common.proxy.http_value'))
539+
if (read_config('common.proxy.https_value')):
540+
os.environ['https_proxy'] = read_config('common.proxy.https_value')
541+
logger.info('HTTPS协议代理地址: ' + read_config('common.proxy.https_value'))
542+
logger.info('代理功能已开启,请确保代理地址正确,否则无法连接网络')
526543

527544
def ban_ip(ip_addr, ban_time=-1):
528545
if read_config('security.banlist.enable'):

0 commit comments

Comments
 (0)