Compare commits

...

21 Commits

Author SHA1 Message Date
mercury 068f2d0cc9 improve message update 2024-04-16 17:51:23 +04:00
mercury 759cf1973a update version 2024-04-16 17:45:55 +04:00
mercury a11b7e0664 improve update script 2024-04-16 17:43:07 +04:00
mercury d370b78815 refactoring subscription + v2ray templates 2024-04-16 15:20:44 +04:00
mercury 913f75b4a8 improve on/off on paclist 2024-04-15 13:49:14 +04:00
mercury c3e850b102 warp 2024-04-15 13:43:43 +04:00
mercury 3a89a1543b add block and warp list domains for xray 2024-04-15 12:08:43 +04:00
mercury 2a3e8e393c improve timer 2024-04-15 12:04:52 +04:00
mercury 332b74e366 winsw3 + update script for singbox windows 2024-04-14 13:05:55 +04:00
mercury dfa9efec7a fix singbox zip 2024-04-13 19:30:57 +04:00
mercury e1902827ce singbox for windows as service 2024-04-13 19:20:54 +04:00
mercury 95fea3bb7b improve xtls user menu 2024-04-13 04:22:09 +04:00
mercury 80a9f9f32d github btns 2024-04-12 21:38:54 +04:00
mercury 7fc1105728 update readme 2024-04-12 17:05:48 +04:00
mercury d46679caf6 log upstream 2024-04-12 15:47:58 +04:00
mercury 910186ff00 improve name for subscription 2024-04-12 02:22:39 +04:00
mercury 5e72452a8d improve template sign 2024-04-11 22:38:03 +04:00
mercury 668756f1c7 add https://community.antifilter.download/ in PAC 2024-04-11 21:05:41 +04:00
mercury 29e7be6cd8 improve xray config 2024-04-11 17:06:21 +04:00
mercury a5599118fc improve choice templae sing-box per user 2024-04-11 14:02:30 +04:00
mercury 040e8919f8 fix adguard 2024-04-11 13:09:44 +04:00
24 changed files with 575 additions and 389 deletions
+422 -257
View File
File diff suppressed because it is too large Load Diff
+6 -33
View File
@@ -22,50 +22,23 @@ $address = $_GET['a'] ?: '127.0.0.1';
$port = $_GET['p'] ?: '1080';
$hash = $_GET['h'];
if ($hash == substr(md5($c['key']), 0, 8)) {
require __DIR__ . '/bot.php';
require __DIR__ . '/i18n.php';
$bot = new Bot($c['key'], $i);
switch ($type) {
case 'mirror':
require __DIR__ . '/bot.php';
require __DIR__ . '/i18n.php';
$bot = new Bot($c['key'], $i);
$bot->getMirror();
break;
case 's':
require __DIR__ . '/bot.php';
require __DIR__ . '/i18n.php';
$bot = new Bot($c['key'], $i);
if (!empty($_GET['b'])) {
$fs = $bot->v2raySubscription($_GET['s'], 1);
header("Location: $fs");
exit;
} else {
header('Content-Type: application/json');
echo $bot->v2raySubscription($_GET['s']);
}
exit;
case 'si':
require __DIR__ . '/bot.php';
require __DIR__ . '/i18n.php';
$bot = new Bot($c['key'], $i);
if (!empty($_GET['b'])) {
$fs = $bot->singboxSubscription($_GET['s'], 1);
header("Location: $fs");
exit;
} else {
header('Content-Type: application/json');
echo $bot->singboxSubscription($_GET['s']);
}
$bot->subscription();
exit;
case 'te':
require __DIR__ . '/bot.php';
require __DIR__ . '/i18n.php';
$bot = new Bot($c['key'], $i);
if (!empty($_GET['te'])) {
$t = $bot->getPacConf()['singtemplates'][urldecode($_GET['te'])];
$t = $bot->getPacConf()["{$_GET['ty']}templates"][urldecode($_GET['te'])];
} else {
$t = json_decode(file_get_contents('/config/sing.json'), true);
$t = json_decode(file_get_contents("/config/{$_GET['ty']}.json"), true);
}
if ($t) {
header('Content-Type: application/json');
+1
View File
@@ -9,6 +9,7 @@ require __DIR__ . '/i18n.php';
$bot = new Bot($c['key'], $i);
$bot->adguardProtect();
$bot->adguardCheckPswd();
$bot->setcommands();
$bot->syncPortClients();
$bot->setwebhook();
+1 -89
View File
@@ -93,95 +93,7 @@ function start()
// check && exclude
$include = array_filter($conf['includelist'], fn($x) => $x == true);
if ($conf['zapret']) {
foreach ($source as $k => $v) {
$size = getSize($v['source']);
if ($size > 0) {
if (file_exists($v['dest'])) {
unlink($v['dest']);
}
touch($v['dest']);
$percent = 0;
$curr = 0;
exec("php updatepac.php download $k > /dev/null &");
$i = $j = 0;
while ($curr <= $size) {
$rotate = $curr != $size ? $load[$j % count($load)] : '';
$tail = <<<text
Downloading {$v['source']}
$curr/$size $percent% $rotate
text;
update($text . $tail);
if ($curr == $size || $i > 50) {
break;
}
usleep(50000);
clearstatcache();
if ($curr == filesize($v['dest'])) {
$i++;
}
$curr = filesize($v['dest']);
$percent = (int) ceil($curr * 100 / $size);
$j++;
}
if ($curr != $size) {
$text .= "\nError downloading {$v['source']}\nabort script";
endScript($text);
}
} else {
$text .= "\nError size {$v['source']}\nabort script";
endScript($text);
}
$text .= $tail ? "$tail\n" : '';
}
// prepare
$reg = '~^([^.*]+\.(?:(?:' . implode('|', $subzones) . ')\.)?[^.]+)$~';
foreach ($source as $k => $v) {
$size = filesize($v['dest']);
$curr = $j = 0;
$time = microtime(true);
$name = basename($v['dest']);
$f = fopen($v['dest'], 'r');
while (($s = fgets($f)) !== false) {
$curr += strlen($s);
$percent = (int) ceil($curr * 100 / $size);
$rotate = $curr != $size ? $load[$j % count($load)] : '';
$tail = <<<text
Prepare $name $percent% $rotate
text;
if (microtime(true) - $time > 0.1) {
update($text . $tail);
$time = microtime(true);
$j++;
}
if ($name == 'dump.csv') {
if (!preg_match('~;.*;~', $s)) {
continue;
}
$t = explode(';', iconv('CP1251', 'utf-8', $s));
if (empty($t[1])) {
continue;
}
if (preg_match($reg, idn_to_ascii(trim($t[1])), $m)) {
$domains[$m[1]] = 0;
}
} else {
if (preg_match($reg, idn_to_ascii(iconv('CP1251', 'utf-8', trim($s))), $m)) {
$domains[$m[1]] = 0;
}
}
}
fclose($f);
$text .= $tail ? "$tail\n" : '';
}
$exclude = array_keys(array_filter($conf['excludelist'], fn($x) => $x == true));
foreach ($include as $k => $v) {
$domains[$k] = 0;
}
} else {
$domains = $include;
}
$domains = $include;
if (empty($domains)) {
$text = "Empty domains. Delete pac files";
unlink(__DIR__ . '/zapretlists/mpac');
+1
View File
@@ -16,6 +16,7 @@
<div style="position:absolute;top:0;right:0;width:35%;text-align:center;background-color: #17212b;">
<img src="toncoin.png" width="100%" alt="">
<a href="javascript:;" id="copy" style="color:white;text-decoration:none" data-id="UQCDDkaX3fCAFBek28Hx4TfvDDRqeizOW74blVMVAM4_m4OW">copy</a>
<iframe src="https://ghbtns.com/github-btn.html?user=mercurykd&repo=vpnbot&type=star&count=true" frameborder="0" scrolling="0" width="150" height="20" title="GitHub"></iframe>
</div>
<a style="background-color: #8B3FFD;height: 46px;display:inline-block;padding:0 54px;color: white;border-radius: 12px;text-decoration: none;font-size: 20px;line-height: 46px;font-family: arial;" href="https://yoomoney.ru/to/410011827900450">
<svg style="width: 24px;fill: white;position: relative;top: 4px;" class="qa-fundraise-button-logo mui-m0okdh" viewBox="0 0 16 16"><path d="M4.638 8.5a5.67 5.67 0 015.681-5.68A5.693 5.693 0 0116 8.5a5.693 5.693 0 01-5.68 5.682A5.67 5.67 0 014.637 8.5zm3.56 0c0 1.151.97 2.122 2.121 2.122 1.15 0 2.085-.97 2.121-2.121 0-1.15-.97-2.121-2.12-2.121-1.151 0-2.122.97-2.122 2.12zm-3.596 4.243v-8.27H0l2.589 8.27h2.013z" clip-rule="evenodd"></path></svg>
+1 -1
View File
@@ -3,7 +3,7 @@ worker_processes auto;
load_module /usr/lib/nginx/modules/ngx_stream_module.so;
error_log /logs/nginx_error;
error_log /logs/upstream_error;
pid /var/run/nginx.pid;
events {
+1 -1
View File
@@ -85,7 +85,7 @@
"rules": [{
"type": "field",
"outboundTag": "proxy",
"domain": []
"domain": "~pac~"
}, {
"type": "field",
"port": "0-65535",
-5
View File
@@ -5,11 +5,6 @@
"protocol": "vless",
"settings": {
"clients": [
{
"email": "user1@myserver",
"flow": "xtls-rprx-vision",
"id": ""
}
],
"decryption": "none"
},
+32 -3
View File
@@ -1,5 +1,3 @@
version: "3.7"
x-logging:
&default-logging
driver: "json-file"
@@ -95,7 +93,7 @@ services:
ipv4_address: 10.10.1.2
logging: *default-logging
php:
image: mercurykd/vpnbot-php:1.3
image: mercurykd/vpnbot-php:1.4
build:
dockerfile: dockerfile/php.dockerfile
args:
@@ -117,6 +115,7 @@ services:
- ./.env:/mirror/.env
- ./update:/update
- ./.git:/.git
- ./singbox_windows:/singbox
environment:
IP: ${IP}
VER: ${VER}
@@ -491,3 +490,33 @@ services:
default:
ipv4_address: 10.10.0.12
logging: *default-logging
wp:
image: mercurykd/vpnbot-wp:1
build:
dockerfile: dockerfile/warp.dockerfile
args:
image: ${IMAGE}
cap_add:
- NET_ADMIN
devices:
- /dev/net/tun:/dev/net/tun
volumes:
- ./config/.profile:/root/.bashrc:ro
- ./ssh:/ssh
- ./config/sshd_config:/etc/ssh/sshd_config
- ./config:/config
- ./certs:/certs
- ./scripts/start_wp.sh:/start_wp.sh
hostname: warp
container_name: warp-${VER}
depends_on:
php:
condition: service_healthy
environment:
TZ: ${TZ}
stop_grace_period: 1s
command: ["/bin/sh", "/start_wp.sh"]
networks:
default:
ipv4_address: 10.10.0.13
logging: *default-logging
+1
View File
@@ -4,6 +4,7 @@ RUN apk add --no-cache --update php81 \
php81-mbstring \
php81-session \
php81-phar \
php81-zip \
php81-curl \
php81-opcache \
php81-openssl \
+5
View File
@@ -0,0 +1,5 @@
FROM ubuntu:22.04
RUN apt update && apt install -y curl gpg socat lsb-release \
&& curl -fsSL https://pkg.cloudflareclient.com/pubkey.gpg | gpg --yes --dearmor --output /usr/share/keyrings/cloudflare-warp-archive-keyring.gpg \
&& echo "deb [signed-by=/usr/share/keyrings/cloudflare-warp-archive-keyring.gpg] https://pkg.cloudflareclient.com/ $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/cloudflare-client.list \
&& apt update && apt install -y cloudflare-warp
+4
View File
@@ -6,6 +6,10 @@ telegram bot to manage servers (inside the bot)
- change secret
- qr/config
- change fake domain
- multiple users
- subscriptions with routing
- routing templates per user
- steal from yourself
<img src="https://github.com/mercurykd/vpnbot/assets/30900414/39bdf4e0-96a6-4257-b61e-30a14122e236" width="200">
### NaiveProxy
+6
View File
@@ -0,0 +1,6 @@
warp-svc > /dev/null &
sleep 3
warp-cli --accept-tos registration new
warp-cli --accept-tos mode proxy
warp-cli --accept-tos connect
socat TCP-LISTEN:4000,fork TCP:127.0.0.1:40000
+2
View File
@@ -0,0 +1,2 @@
winsw3.exe install
pause
Binary file not shown.
+1
View File
@@ -0,0 +1 @@
winsw3.exe start
+2
View File
@@ -0,0 +1,2 @@
winsw3.exe status
pause
+1
View File
@@ -0,0 +1 @@
winsw3.exe stop
+2
View File
@@ -0,0 +1,2 @@
winsw3.exe uninstall
pause
+35
View File
@@ -0,0 +1,35 @@
@echo off
setlocal
set "exe_path=sing-box.exe"
set "URL=~url~"
set "FileName=config.json"
set "PreviousHash="
taskkill /IM "%exe_path%" /F
powershell -command "(New-Object System.Net.WebClient).DownloadFile('%URL%', '%FileName%')"
for /F "skip=1 delims=" %%H in ('2^>nul CertUtil -hashfile "%FileName%" SHA256') do (
if not defined PreviousHash set "PreviousHash=%%H"
)
start "" /B "%CD%\%exe_path%" run -c "%FileName%"
echo "%PreviousHash%"
:loop
powershell -command "(New-Object System.Net.WebClient).DownloadFile('%URL%', '%FileName%')"
for /F "skip=1 delims=" %%H in ('2^>nul CertUtil -hashfile "%FileName%" SHA256') do (
if not defined HASH set "HASH=%%H"
)
set "CurrentHash=%HASH%"
set "HASH="
echo "%CurrentHash%"
if "%CurrentHash%" NEQ "%PreviousHash%" (
echo "change"
set "PreviousHash=%CurrentHash%"
taskkill /IM "%exe_path%" /F
start "" /B "%CD%\%exe_path%" run -c "%FileName%"
) else (
echo "not change"
)
timeout /t 15 /nobreak
goto :loop
Binary file not shown.
+15
View File
@@ -0,0 +1,15 @@
<service>
<id>singbox</id>
<name>singbox</name>
<description>singbox</description>
<executable>%BASE%\update.cmd</executable>
<logmode>rotate</logmode>
<onfailure action="restart" delay="10 sec" />
<onfailure action="restart" delay="20 sec" />
<onfailure action="restart" delay="30 sec" />
<onfailure action="none" />
<onexit action="restart" />
<onexit action="restart" />
<onexit action="restart" />
<onexit action="none" />
</service>
+9
View File
@@ -9,16 +9,25 @@ do
branch=$(cat $pwd/update/branch 2>/dev/null)
if [[ -n "$cmd" ]]
then
key=$(cat $pwd/update/key)
curl -H "Content-Type: application/json" -X POST https://api.telegram.org/bot$key/editMessageText -d "$(cat $pwd/update/curl | sed 's/"text":"~t~"/"text": "останавливаю бота"/')"
docker compose down --remove-orphans
curl -H "Content-Type: application/json" -X POST https://api.telegram.org/bot$key/editMessageText -d "$(cat $pwd/update/curl | sed 's/"text":"~t~"/"text": "очищаю директорию"/')"
git reset --hard && git clean -fd
curl -H "Content-Type: application/json" -X POST https://api.telegram.org/bot$key/editMessageText -d "$(cat $pwd/update/curl | sed 's/"text":"~t~"/"text": "скачиваю обновление"/')"
git fetch
if [[ -n "$branch" ]]
then
curl -H "Content-Type: application/json" -X POST https://api.telegram.org/bot$key/editMessageText -d "$(cat $pwd/update/curl | sed 's/"text":"~t~"/"text": "меняю ветку"/')"
git checkout -t origin/$branch || git checkout $branch
fi
curl -H "Content-Type: application/json" -X POST https://api.telegram.org/bot$key/editMessageText -d "$(cat $pwd/update/curl | sed 's/"text":"~t~"/"text": "применяю обновления"/')"
git pull > ./update/message
curl -H "Content-Type: application/json" -X POST https://api.telegram.org/bot$key/editMessageText -d "$(cat $pwd/update/curl | sed 's/"text":"~t~"/"text": "запускаю бота"/')"
IP=$(curl https://ipinfo.io/ip) VER=$(git describe --tags) docker compose up -d --force-recreate
bash $pwd/update/update.sh &
> $pwd/update/key
> $pwd/update/curl
exit 0
fi
sleep 1
+27
View File
@@ -1,3 +1,30 @@
16.04.2024 v1.30.1
- улучшение сообщения об обновлениях
16.04.2024 v1.30
- улучшение скрипта обновления
16.04.2024 v1.29
- рефакторинг подписок
- кнопки импорта для различных клиентов
- шаблоны для v2ray
15.04.2024 v1.28
- xtls: список блокировки, список warp
- улучшение отображения таймера
14.04.2024 v1.27.1
- singbox windows: замена winsw на winsw3, + скрипт обновления подписки
13.04.2024 v1.27
- архив сингбокса для windows, работает как служба
12.04.2024 v1.26
- имя клиента xtls подтягивается по подписке из бота
11.04.2024 v1.25
- подпись дефолтного шаблона в разделе пользователя xtls
11.04.2024 v1.24
- обновлен раздел PAC, добавлена возможность добавить домены из https://community.antifilter.download/
11.04.2024 v1.23
- фикс совместимости старого конфига xray из бэкапа
11.04.2024 v1.22
- улучшение гибкости выбора шаблона sing-box
11.04.2024 v1.21
- фикс доступности адгвард панели при первом запуске
10.04.2024 v1.20
- выбор дефолтного шаблона sing-box
10.04.2024 v1.19