Skip to content

Commit

Permalink
🔥 3.6.5: Remove executable file.
Browse files Browse the repository at this point in the history
  • Loading branch information
AirportR committed Dec 5, 2023
1 parent 7cf799c commit f43b75f
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 62 deletions.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,17 @@ apt install -y git && git clone https://github.com/AirportR/FullTclash.git && cd
# 如果是在中国大陆地区使用,则程序需要代理才能连接上Telegram服务器。写入如下信息:
proxy: 127.0.0.1:7890 #socks5 替换成自己的代理地址和端口
```
- 代理客户端路径配置
从3.6.5版本开始,不再默认提供代理客户端二进制文件,请自行前往以下网址获取:
https://github.com/AirportR/FullTCore/releases \
下载解压后可以放到 ./bin/ 目录下,比如文件名为 FullTCore ,下面的配置文件这样写:
```yaml
clash:
path: "./bin/FullTCore" #这里改成代理客户端文件路径
```
Windows系统名字后缀名.exe要加上,其他类Unix系统不需要加后缀名。
- 代理配置(可选)
如果是在中国大陆地区使用,可能部分订阅网址无法直接连接。可在config.yaml中写入如下信息:
Expand Down
Empty file added bin/.gitkeep
Empty file.
Binary file removed bin/fulltclash-linux-amd64
Binary file not shown.
Binary file removed bin/fulltclash-macos-amd64
Binary file not shown.
Binary file removed bin/fulltclash-windows-amd64.exe
Binary file not shown.
31 changes: 2 additions & 29 deletions botmodule/init_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
from subprocess import check_output

from loguru import logger

from utils.clash import check_port, start_fulltclash
from utils.cleaner import ConfigManager

config = ConfigManager() # 配置加载
Expand Down Expand Up @@ -143,8 +141,8 @@ def check_version() -> str:
api_id = botconfig.get('api_id', None)
api_hash = botconfig.get('api_hash', None)
bot_token = botconfig.get('bot_token', None)
clash_path = config.get_clash_path() # 为clash核心运行路径, Windows系统需要加后缀名.exe
clash_work_path = config.get_clash_work_path() # clash工作路径
clash_path = config.get_clash_path() # 为代理客户端运行路径
# clash_work_path = config.get_clash_work_path() # clash工作路径
corenum = min(config.config.get('clash', {}).get('core', 1), 128)

USER_TARGET = config.getuser() # 这是用户列表,从配置文件读取
Expand Down Expand Up @@ -203,31 +201,6 @@ def check_version() -> str:
logger.info("配置已加载, Telegram bot程序开始运行...")


def start_clash():
# 端口检查
global proxy_subprocess
loop = asyncio.get_event_loop()
start_port = config.config.get('clash', {}).get('startup', 11220)
port_list = [str(start_port + i * 2) for i in range(corenum)]
res2 = loop.run_until_complete(check_port(start_port - 1, start_port + 1 + corenum * 2))
if res2:
logger.warning("端口检查中发现已有其他进程占用了端口,请更换端口,否则测试可能会出现不可预知的错误。(亦或者是您分开启动?)")
return
# if config.config.get('clash', {}).get('auto-start', False):
print("开始启动clash core")
if sys.platform != "win32":
try:
status = os.system(f"chmod +x {clash_path}")
if status != 0:
raise OSError(f"Failed to execute command: chmod +x {clash_path}")
except OSError as o:
print(o)
proxy_subprocess = start_fulltclash(port_list)


# start_clash()


def reloadUser():
global USER_TARGET
config.reload(issave=False)
Expand Down
20 changes: 4 additions & 16 deletions utils/clash.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,21 +134,9 @@ def get_clash_path(self):
try:
return self.config['clash']['path']
except KeyError:
if sys.platform.startswith("linux"):
path = './bin/fulltclash-linux-amd64'
elif sys.platform.startswith("win32"):
path = r'.\bin\fulltclash-windows-amd64.exe'
elif 'darwin' in sys.platform:
path = './bin/fulltclash-macos-amd64'
else:
path = './bin/fulltclash-linux-amd64'
d = {'path': path}
try:
self.yaml['clash'].update(d)
except KeyError:
di = {'clash': d}
self.yaml.update(di)
return path
print("为减轻项目文件大小从3.6.5版本开始,不再默认提供的代理客户端二进制文件,请自行前往以下网址获取: \n"
"https://github.com/AirportR/FullTCore/releases")
raise ValueError("找不到代理客户端二进制文件")


config = ConfigManager()
Expand Down Expand Up @@ -202,7 +190,7 @@ def start_fulltclash(portlist: list):
if not portlist:
raise ValueError("空的端口列表")
port2 = "|".join(portlist)
control_port = int(portlist[0])-1
control_port = int(portlist[0]) - 1
_command = fr"{config.get_clash_path()} -c {control_port} -p {port2}"
p = subprocess.Popen(_command.split(), encoding="utf-8")
return p
Expand Down
19 changes: 3 additions & 16 deletions utils/cleaner.py
Original file line number Diff line number Diff line change
Expand Up @@ -943,22 +943,9 @@ def get_clash_path(self):
try:
return self.config['clash']['path']
except KeyError:
logger.warning("获取运行路径失败,将采用默认运行路径: ./bin\n自动识别windows,linux,macos系统。架构默认为amd64")
if sys.platform.startswith("linux"):
path = './bin/fulltclash-linux-amd64'
elif sys.platform.startswith("win32"):
path = r'.\bin\fulltclash-windows-amd64.exe'
elif 'darwin' in sys.platform:
path = './bin/fulltclash-macos-amd64'
else:
path = './bin/fulltclash-linux-amd64'
d = {'path': path}
try:
self.yaml['clash'].update(d)
except KeyError:
di = {'clash': d}
self.yaml.update(di)
return path
logger.warning("为减轻项目文件大小从3.6.5版本开始,不再默认提供代理客户端二进制文件,请自行前往以下网址获取: \n"
"https://github.com/AirportR/FullTCore/releases")
raise ValueError("找不到代理客户端二进制文件")

def get_sub(self, subname: str = None):
"""
Expand Down

0 comments on commit f43b75f

Please sign in to comment.