Closed JavanTang closed 2 years ago
2022-04-12 18:56:05,795 - functions.py[line:135] - [update_local_address] - INFO: Update local address to: https://XXXXX
2022-04-12 18:56:05,795 - parse_utils.py[line:113] - [parse_shadowsocksr_by_subscribe_url] - INFO: Start parse ssr subscribe url: https://XXXXXX
2022-04-12 18:56:12,094 - logger.py[line:53] - [main] - INFO: Func - update Total time: 6.3s
2022-04-12 18:56:12,094 - logger.py[line:75] - [judge] - ERROR: Shadowsocksr id error
Check the ssr_id
that in start method whether out of ssr_dict_list boundary, ssr_id
is the index of shadowsocksr nodes that in ssr_dict_list
I printed 'update_shadowsocksr.ssr_dict_list' in the above code and found that I did not cross the line
Please offer the detail of code you had changed.
Please offer the detail of code you had changed.
I didn't change the source code at first, but it didn't work either
Please see the following code:
from shadowsocksr_cli.functions import *
from shadowsocksr_cli.common import *
class SSR:
def __init__(self) -> None:
self.current_id = None
self.ssr_time_dict = {}
self.ssr_dict_list = []
# # 更新节点
self.ssr_dict_list = ParseShadowsocksr.parse_shadowsocksr_by_subscribe_url('xxxxxx')
self.ssr_dict_list = ShadowsocksrTest.connect_thread_pool(self.ssr_dict_list)
# # 建立ssr_id:启动时间的dict
for i, v in enumerate(self.ssr_dict_list):
if v['ping'] != '∞':
self.ssr_time_dict[i] = 0
# 启动ssr
self.choose_ssr_id()
def choose_ssr_id(self) -> None:
"""
"""
if self.current_id != None:
print('关闭', self.current_id)
HandleShadowsocksr.stop(ssr_id=self.current_id, local_port=1088)
# 节点
min_v = 0
min_i = 0
for k, v in self.ssr_time_dict.items():
if v <= min_v:
min_v = v
min_i = k
self.current_id = min_i
HandleShadowsocksr.start(ssr_id=self.current_id, local_port=1088)
print('开启ssr节点', self.current_id)
self.ssr_time_dict[min_i] = int(time.time())
if __name__ == "__main__":
ssr = SSR()
ssr.choose_ssr_id()
Business:crawler systems Version:shadowsocksr-cli == 2.1.9 Python version:3.8.8 Question:The following code cannot successfully switch ssr nodes, is there any solution?Thank you~