Skip to content

Commit

Permalink
Merge pull request #133 from AirportR/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
AirportR authored Nov 18, 2023
2 parents be1f751 + b2ebf2f commit fd88f64
Show file tree
Hide file tree
Showing 28 changed files with 326 additions and 150 deletions.
33 changes: 0 additions & 33 deletions Dockerfile

This file was deleted.

8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ FullTClash bot 是承载其测试任务的Telegram 机器人(以下简称bot
2. 链路拓扑测试(节点出入口分析)。
3. 下行速度测试

## 具备特性
## 分支说明
* [master](https://github.com/AirportR/FullTclash/tree/master) 主分支,主打稳定。
* [backend](https://github.com/AirportR/FullTclash/tree/backend) 纯后端代码,无前端BOT,意味着需要额外的bot作主端。
* [dev](https://github.com/AirportR/FullTclash/tree/dev) 开发进度最前沿。
* [old](https://github.com/AirportR/FullTclash/tree/dev) 依靠调用原版Clash Restful API进行测试。可随意更换内核,但已停止新功能开发。

## 支持协议

Expand Down Expand Up @@ -180,8 +184,6 @@ bot:

等待初始化操作,出现“程序已启动!”字样就说明在运行了。
运行之后和bot私聊指令:
>/clash start 用于启动clash,否则测试结果会全部是N/A。

>/testurl <订阅地址>(clash配置格式)即可开始测试

>/help 可查看所有命令说明
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion botmodule/command/authority.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ async def get_url_from_invite(_, message2):
include_text = texts_li[1]
if len(texts_li) > 2:
exclude_text = texts_li[2]
url_li = geturl(text_li)
url_li = geturl(text_li, True)
if url_li:
await temp_queue.put((url_li, include_text, exclude_text))
else:
Expand Down
2 changes: 1 addition & 1 deletion botmodule/command/setting.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ async def select_sort_only(_: "Client", call: Union["CallbackQuery", "Message"],
IKB("⬇️平均速度降序", f"{api_route}arspeed")])
content_keyboard.append([IKB("⬆️最大速度升序", f"{api_route}mspeed"),
IKB("⬇️最大速度降序", f"{api_route}mrspeed")])
content_keyboard.append([dbtn['b_cancel']])
content_keyboard.append([dbtn['b_close']])
botmsg = await call.reply(f"请选择排序方式(你有{timeout}s的时间选择): ",
reply_markup=InlineKeyboardMarkup(content_keyboard), quote=True)
recvkey = gen_msg_key(botmsg)
Expand Down
2 changes: 1 addition & 1 deletion botmodule/command/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ async def process(app: Client, message: Message, **kwargs):
back_message = await message.reply("⏳任务接收成功,测试进行中...", quote=True)
tgtext = str(message.text)
tgargs = cleaner.ArgCleaner().getall(tgtext)
suburl = cleaner.geturl(tgtext) if kwargs.get('url', None) is None else kwargs.get('url', None)
suburl = cleaner.geturl(tgtext, True) if kwargs.get('url', None) is None else kwargs.get('url', None)
put_type = kwargs.pop('put_type', '') if kwargs.get('put_type', '') else tgargs[0].split("@")[0]
logger.info("测试指令: " + str(put_type))
if not put_type:
Expand Down
8 changes: 5 additions & 3 deletions botmodule/register.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import random
import urllib.parse
import aiohttp
from pyrogram.enums import ParseMode
from pyrogram.types import Message
from loguru import logger
from aiohttp.client_exceptions import ClientConnectorError
from utils.cleaner import geturl
Expand Down Expand Up @@ -60,16 +62,16 @@ async def getsub_async(url: str, username: str, pwd: str, proxy=None):
return str(e)


async def baipiao(_, message):
async def baipiao(_, message: "Message"):
back_message = await message.reply("正在尝试注册...") # 发送提示
regisurl = geturl(str(message.text))
if regisurl:
suburl = await getsub_async(regisurl, random_value(10), random_value(8), proxy=proxies)
else:
await back_message.edit_text("❌发生错误,请检查注册地址是否正确")
await back_message.edit_text("❌发生错误,请检查注册地址是否正确", parse_mode=ParseMode.DISABLED)
return
if suburl:
await back_message.edit_text(suburl)
await back_message.edit_text(suburl, parse_mode=ParseMode.DISABLED)
return
else:
await back_message.edit_text("❌发生错误,请检查注册地址是否正确")
Expand Down
43 changes: 43 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
FROM python:3.9.18-slim-bookworm AS compile-image

RUN apt-get update && \
apt-get install --no-install-recommends -y \
gcc g++ make ca-certificates

RUN python -m venv /opt/venv

ENV PATH="/opt/venv/bin:$PATH"
ADD https://raw.githubusercontent.com/AirportR/FullTclash/dev/requirements.txt .
RUN pip3 install --no-cache-dir -r requirements.txt && \
pip3 install --no-cache-dir supervisor

FROM python:3.9.18-slim-bookworm

WORKDIR /app

RUN apt-get update && \
apt-get install --no-install-recommends -y \
git tzdata curl wget jq bash nano cron && \
git clone -b dev --single-branch --depth=1 https://github.com/AirportR/FullTclash.git /app && \
cp resources/config.yaml.example resources/config.yaml && \
rm -f /etc/localtime && \
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
echo "Asia/Shanghai" > /etc/timezone && \
mkdir /etc/supervisord.d && \
mv /app/docker/supervisord.conf /etc/supervisord.conf && \
mv /app/docker/fulltclash.conf /etc/supervisord.d/fulltclash.conf && \
chmod +x /app/docker/fulltcore.sh && \
/app/docker/fulltcore.sh && \
cp /app/docker/crontab /etc/cron.d/crontab && \
chmod 0644 /etc/cron.d/crontab && \
/usr/bin/crontab /etc/cron.d/crontab && \
chmod +x /app/docker/update.sh && \
chmod +x /app/docker/docker-entrypoint.sh && \
rm -rf /var/lib/apt/lists/*

COPY --from=compile-image /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=compile-image /opt/venv /opt/venv

ENV PATH="/opt/venv/bin:$PATH"

ENTRYPOINT ["/app/docker/docker-entrypoint.sh"]
51 changes: 51 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# 使用Docker安装

> 这能让你在Windows、Mac、Linux、openwrt、Nas几乎任何支持Docker(目前仅Amd64和Arm64)的环境下使用此项目!
## 1.创建配置文件
新建配置文件保存目录`mkdir /etc/FullTclash`
下载并编辑配置文件
```
wget -O /etc/FullTclash/config.yaml https://raw.githubusercontent.com/AirportR/FullTclash/dev/resources/config.yaml.example
```
修改 config.yaml (path是必须修改的配置,不能使用默认的)
```
clash:
path: './bin/fulltclash-origin'
branch: origin
```
或者 [Meta内核](https://github.com/AirportR/FullTCore/tree/meta)
```
clash:
path: './bin/fulltclash-meta'
branch: meta
```

## 构建Docker镜像

### 下载Dockerfile
```
wget -N https://raw.githubusercontent.com/AirportR/FullTclash/dev/docker/Dockerfile
```

### 构建镜像
```
docker build -t fulltclash:dev .
```

启动
```
docker run -itd --name=fulltclash --restart=always -v /etc/FullTclash/config.yaml:/app/resources/config.yaml fulltclash:dev
```
查看日志
```
docker exec -it fulltclash tail -f /var/log/fulltclash.log
```
更新版本
```
docker exec -it fulltclash bash /app/docker/update.sh
```
重启程序
```
docker exec -it fulltclash supervisorctl restart fulltclash
```
1 change: 1 addition & 0 deletions docker/crontab
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00 6 * * * bash /app/docker/update.sh
5 changes: 5 additions & 0 deletions docker/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

supervisord -c /etc/supervisord.conf

cron -f > /dev/null 2>&1
4 changes: 4 additions & 0 deletions docker/fulltclash.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[program:fulltclash]
command=python3 /app/main.py
directory=/app
stdout_logfile=/var/log/fulltclash.log
33 changes: 33 additions & 0 deletions docker/fulltcore.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

rm -f /app/bin/*

ORIGIN_AMD64_URL=https://github.com/AirportR/FullTCore/releases/download/v1.0/FullTCore_1.0_linux_amd64.tar.gz
META_AMD64_URL=https://github.com/AirportR/FullTCore/releases/download/v1.1-meta/FullTCore_1.1-meta_linux_amd64.tar.gz
ORIGIN_ARM64_URL=https://github.com/AirportR/FullTCore/releases/download/v1.0/FullTCore_1.0_linux_arm64.tar.gz
META_ARM64_URL=https://github.com/AirportR/FullTCore/releases/download/v1.1-meta/FullTCore_1.1-meta_linux_arm64.tar.gz

arch=$(arch)

if [[ $arch == "x86_64" || $arch == "x64" || $arch == "amd64" ]]; then
arch="amd64"
wget -O /app/bin/FullTCore_origin.tar.gz ${ORIGIN_AMD64_URL} > /dev/null 2>&1
wget -O /app/bin/FullTCore_meta.tar.gz ${META_AMD64_URL} > /dev/null 2>&1
elif [[ $arch == "aarch64" || $arch == "arm64" ]]; then
arch="arm64"
wget -O /app/bin/FullTCore_origin.tar.gz ${ORIGIN_ARM64_URL} > /dev/null 2>&1
wget -O /app/bin/FullTCore_meta.tar.gz ${META_ARM64_URL} > /dev/null 2>&1
fi

tar -C /app/bin/ -xvzf /app/bin/FullTCore_origin.tar.gz
mv /app/bin/FullTCore /app/bin/fulltclash-origin

tar -C /app/bin/ -xvzf /app/bin/FullTCore_meta.tar.gz
mv /app/bin/FullTCore /app/bin/fulltclash-meta

find /app/bin/* | egrep -v "fulltclash-origin|fulltclash-meta" | xargs rm -f

chmod +x /app/bin/fulltclash-origin
chmod +x /app/bin/fulltclash-meta

echo "架构: ${arch}下载FullTCore完成"
22 changes: 22 additions & 0 deletions docker/supervisord.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[unix_http_server]
file=/tmp/supervisor.sock

[supervisord]
logfile=/tmp/supervisord.log
logfile_maxbytes=50MB
logfile_backups=10
loglevel=info
pidfile=/tmp/supervisord.pid
nodaemon=false
silent=false
minfds=1024
minprocs=200

[supervisorctl]
serverurl=unix:///tmp/supervisor.sock

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[include]
files = supervisord.d/*.conf
17 changes: 17 additions & 0 deletions docker/update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

git_version=$(git --git-dir='/app/.git' --work-tree='/app' rev-parse HEAD)
last_version=$(curl -Ls "https://api.github.com/repos/AirportR/FullTclash/commits/dev" | jq .sha | sed -E 's/.*"([^"]+)".*/\1/')

update() {
git --git-dir='/app/.git' --work-tree='/app' fetch --all
git --git-dir='/app/.git' --work-tree='/app' reset --hard origin/dev
git --git-dir='/app/.git' --work-tree='/app' pull
}

if [[ $last_version == "$git_version" ]]; then
echo -e "已是最新版本,无需更新"
else
echo -e "检查到新版本,正在更新"
update
fi
2 changes: 1 addition & 1 deletion glovar.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
BUILD_TOKEN = init_bot.config.getBuildToken()
userbot_config = bot_config.config.get('userbot', {})
# 项目版本号
__version__ = '3.6.2'
__version__ = '3.6.4'
# 客户端
app = Client("my_bot",
api_id=init_bot.api_id,
Expand Down
2 changes: 1 addition & 1 deletion resources/config.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ bot:
#如果要http代理要验证,配置格式为: proxy: "用户名:密码@host:端口" 比如: user1:112233@127.0.0.1:7890
#geoip-api: "ip-api.com" # GEOIP 测试api,取二级域名,目前支持 ip-api.com ip.sb ipleak.net ipdata.co ipapi.co 五种,其中 ipdata 需要配置下面的geoip-key
#geoip-key: xxxxxxx #ipdata 的 apikey,如果使用其他api则无需填写
#subconvertor: #订阅转换(此配置主要开发者已无心维护,能用但不稳定)
#subconverter: #订阅转换(此配置主要开发者已无心维护,能用但不稳定)
# enable: true #是否启用
# host: '127.0.0.1:25500' #域名或者ip加端口
# remoteconfig: "https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online.ini" #远程配置
Expand Down
Loading

0 comments on commit fd88f64

Please sign in to comment.