Compare commits

...

15 Commits

Author SHA1 Message Date
mercury 3d53691106 update version 2024-11-11 16:21:18 +04:00
mercury 5f38e73d6b fix clientId accounting when filling out the white list 2024-11-11 16:18:29 +04:00
mercury bb3a807869 stream access log 2024-11-11 14:09:27 +04:00
mercury 3ed487cbce xray logs 2024-11-11 11:46:11 +04:00
mercury 1d69729bf1 update version 2024-11-09 21:35:43 +04:00
mercury 387f1618b1 ~ip~ tag for templates 2024-11-06 23:19:51 +04:00
mercury 9da11e2b35 fix adguard password 2024-11-06 23:06:06 +04:00
mercury 0b95c75005 timeout for check status adguard 2024-11-06 22:35:32 +04:00
mercury 62c4314beb docker installation 2024-11-05 18:35:31 +04:00
mercury 1dfb3da089 update version 2024-11-04 19:44:47 +04:00
mercury 7358730864 fix update script 2024-11-04 19:37:12 +04:00
mercury 57cd1019f5 fix restart 2024-11-04 19:34:41 +04:00
mercury dfbcd67f83 restart button 2024-11-04 19:23:15 +04:00
mercury 5016c6bda3 ability to enable/disable ports 2024-11-04 19:06:42 +04:00
mercury bc3914c3b9 json beautifier when saving template 2024-11-04 17:33:15 +04:00
11 changed files with 142 additions and 30 deletions
+2 -1
View File
@@ -21,4 +21,5 @@ update/*
override.env
override.html
override.php
override.php
docker-compose.override.yml
+103 -6
View File
@@ -142,6 +142,9 @@ class Bot
case preg_match('~^/autoupdate$~', $this->input['message'], $m):
$this->autoupdate();
break;
case preg_match('~^/ports$~', $this->input['callback'], $m):
$this->ports();
break;
case preg_match('~^/adgFillAllowedClients(?: (\d+))?$~', $this->input['callback'], $m):
$this->adgFillAllowedClients($m[1] ?: false);
break;
@@ -181,6 +184,9 @@ class Bot
case preg_match('~^/exportList (\w+)$~', $this->input['callback'], $m):
$this->exportList($m[1]);
break;
case preg_match('~^/hidePort (\w+)$~', $this->input['callback'], $m):
$this->hidePort($m[1]);
break;
case preg_match('~^/deleteYes (\w+)$~', $this->input['callback'], $m):
$this->deleteYes($m[1]);
break;
@@ -193,6 +199,9 @@ class Bot
case preg_match('~^/applyupdatebot$~', $this->input['callback'], $m):
$this->applyupdatebot();
break;
case preg_match('~^/restart$~', $this->input['callback'], $m):
$this->restart();
break;
case preg_match('~^/branches$~', $this->input['callback'], $m):
$this->branches();
break;
@@ -2079,10 +2088,12 @@ class Bot
public function adguardSync()
{
$pac = $this->getPacConf();
$pac['adpswd'] = $pac['adpswd'] ?: substr(hash('md5', time()), 0, 10);
$this->setPacConf($pac);
$ssl = $this->nginxGetTypeCert();
$c = yaml_parse_file($this->adguard);
$this->stopAd();
$c['users'][0]['password'] = $pac['adpswd'] ?: password_hash(substr(hash('md5', time()), 0, 10), PASSWORD_DEFAULT);
$c['users'][0]['password'] = password_hash($pac['adpswd'], PASSWORD_DEFAULT);
if (!empty($ssl) && !empty($pac['domain']) && empty($c['tls']['enabled'])) {
$c['tls']['enabled'] = true;
$c['tls']['server_name'] = $pac['domain'];
@@ -3998,7 +4009,7 @@ DNS-over-HTTPS with IP:
[
[
'text' => $this->i18n('chat'),
'url' => "https://t.me/+BYuWVd36cZYwNTMy",
'url' => "https://t.me/+Wfxg6-nrokBlMmYy",
],
[
'text' => $this->i18n('donate'),
@@ -4462,7 +4473,7 @@ DNS-over-HTTPS with IP:
$pac = $this->getPacConf();
switch ($name) {
case 'origin':
file_put_contents("/config/$type.json", $json);
file_put_contents("/config/$type.json", json_encode(json_decode($json, true), JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
break;
default:
@@ -5199,6 +5210,7 @@ DNS-over-HTTPS with IP:
'~process_outbound~' => $pac['process_outbound'] ? 'direct' : $outbound,
'~domains_outbound~' => $pac['domains_outbound'] ? 'direct' : $outbound,
'~final_outbound~' => $pac['final_outbound'] ? $outbound : 'direct',
'~ip~' => $this->ip,
]);
$json = $this->clearEmptyRules($json);
@@ -5480,7 +5492,7 @@ DNS-over-HTTPS with IP:
$text .= "DNS over HTTPS:\n<code>$ip</code>\n<code>$scheme://$domain/dns-query" . ($conf['adguardkey'] ? "/{$conf['adguardkey']}" : '') . "</code>\n\n";
$text .= "DNS over TLS:\n<code>tls://" . ($conf['adguardkey'] ? "{$conf['adguardkey']}." : '') . "$domain</code>";
}
$status = $this->i18n(exec("JSON=1 dnslookup google.com ad") ? 'on' : 'off');
$status = $this->i18n(exec("JSON=1 timeout 2 dnslookup google.com ad") ? 'on' : 'off');
$safesearch = yaml_parse_file($this->adguard)['filtering']['safe_search']['enabled'];
$text .= "\n\nstatus: $status\t\tsafesearch: " . $this->i18n($safesearch ? 'on' : 'off');
$allowedClients = yaml_parse_file($this->adguard)['dns']['allowed_clients'];
@@ -5575,8 +5587,8 @@ DNS-over-HTTPS with IP:
} else {
$c['dns']['allowed_clients'] = [];
$c['dns']['allowed_clients'][] = '10.10.0.0/24';
if (!empty($pac['adguardKey'])) {
$c['dns']['allowed_clients'][] = $pac['adguardKey'];
if (!empty($pac['adguardkey'])) {
$c['dns']['allowed_clients'][] = $pac['adguardkey'];
}
$c['dns']['allowed_clients'][] = getenv('WGADDRESS');
$c['dns']['allowed_clients'][] = getenv('WG1ADDRESS');
@@ -5687,6 +5699,20 @@ DNS-over-HTTPS with IP:
$this->delete($this->input['from'], $this->input['message_id']);
}
public function restart()
{
$r = $this->send($this->input['from'], 'restart...');
file_put_contents('/update/reload_message', "{$this->input['from']}:{$r['result']['message_id']}");
file_put_contents('/update/key', $this->key);
file_put_contents('/update/curl', json_encode([
'chat_id' => $this->input['chat'],
'message_id' => $r['result']['message_id'],
'text' => '~t~'
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
file_put_contents('/update/pipe', '2');
$this->delete($this->input['from'], $this->input['message_id']);
}
public function configMenu()
{
exec('git -C / fetch');
@@ -5814,6 +5840,10 @@ DNS-over-HTTPS with IP:
'text' => $this->i18n('fake html'),
'callback_data' => "/addOverrideHtml",
],
[
'text' => $this->i18n('ports'),
'callback_data' => "/ports",
],
];
$data[] = [
[
@@ -5830,6 +5860,10 @@ DNS-over-HTTPS with IP:
'text' => $this->i18n(exec('git -C / rev-list --count HEAD..@{u}') ? 'have updates' : 'no updates'),
'callback_data' => "/menu update",
],
[
'text' => $this->i18n('restart'),
'callback_data' => "/restart",
],
];
$data[] = [
[
@@ -5843,6 +5877,69 @@ DNS-over-HTTPS with IP:
];
}
public function ports()
{
$text[] = 'Settings -> Ports';
$f = '/docker/compose';
$c = yaml_parse_file($f)['services'];
$data = [
[[
'text' => 'Letsencrypt 80 ' . $this->i18n($c['ng'] ? 'off' : 'on'),
'callback_data' => "/hidePort ng",
]],
[[
'text' => 'Shadowsocks ' . getenv('SSPORT') . ' ' . $this->i18n($c['ss'] ? 'off' : 'on'),
'callback_data' => "/hidePort ss",
]],
[[
'text' => 'DoT 853 ' . $this->i18n($c['ad'] ? 'off' : 'on'),
'callback_data' => "/hidePort ad",
]],
[[
'text' => 'Wireguard-1 ' . getenv('WGPORT') . ' ' . $this->i18n($c['wg'] ? 'off' : 'on'),
'callback_data' => "/hidePort wg",
]],
[[
'text' => 'Wireguard-2 ' . getenv('WG1PORT') . ' ' . $this->i18n($c['wg1'] ? 'off' : 'on'),
'callback_data' => "/hidePort wg1",
]],
[[
'text' => 'MTProto ' . getenv('TGPORT') . ' ' . $this->i18n($c['tg'] ? 'off' : 'on'),
'callback_data' => "/hidePort tg",
]],
];
$data[] = [
[
'text' => $this->i18n('back'),
'callback_data' => "/menu config",
],
];
$this->update(
$this->input['chat'],
$this->input['message_id'],
implode("\n", $text ?: ['...']),
$data ?: false,
);
}
public function hidePort($container)
{
$f = '/docker/compose';
$c = yaml_parse_file($f);
if (!empty($c['services'][$container])) {
unset($c['services'][$container]);
} else {
$c['services'][$container]['ports'] = [];
}
if (empty($c['services'])) {
file_put_contents($f, '');
} else {
yaml_emit_file($f, $c);
file_put_contents($f, str_replace('ports:', 'ports: !override', file_get_contents($f)));
}
$this->ports();
}
public function branches()
{
exec('git -C / branch -r', $m);
+4
View File
@@ -369,4 +369,8 @@ $i = [
'en' => 'copy',
'ru' => 'копировать',
],
'restart' => [
'en' => 'restart',
'ru' => 'перезагрузка',
],
];
+4
View File
@@ -11,6 +11,10 @@ events {
}
stream {
log_format basic '$remote_addr [$time_local] '
'$protocol $status $bytes_sent $bytes_received';
access_log /logs/upstream_access basic;
upstream other {
server ng:443;
}
+2 -1
View File
@@ -42,7 +42,8 @@
}
],
"log": {
"loglevel": "info"
"loglevel": "info",
"access": "/logs/xray"
},
"outbounds": [
{
+2
View File
@@ -118,6 +118,7 @@ services:
- ./update:/update
- ./.git:/.git
- ./singbox_windows:/singbox
- ./docker-compose.override.yml:/docker/compose
- /var/run/docker.sock:/var/run/docker.sock:ro
environment:
IP: ${IP}
@@ -412,6 +413,7 @@ services:
- ./config/sshd_config:/etc/ssh/sshd_config
- ./config/xray.json:/xray.json
- ./scripts/start_xray.sh:/start_xray.sh
- ./logs:/logs
hostname: xray
container_name: xray-${VER}
depends_on:
+1 -1
View File
@@ -3,7 +3,7 @@ b:
u: # запуск контейнеров
$(eval IP := $(shell curl -s -t 1 2ip.io || curl -s -t 1 ipinfo.io/ip || curl -s -t 1 ifconfig.me))
bash ./update/update.sh &
touch ./override.env
touch ./override.env ./docker-compose.override.yml
IP=$(IP) VER=$(shell git describe --tags) docker compose --env-file ./.env --env-file ./override.env up -d --force-recreate
d: # остановка контейнеров
-kill -9 $(shell cat ./update/update_pid) > /dev/null
+1 -11
View File
@@ -10,17 +10,7 @@ apt install -y \
iproute2 \
xtables-addons-common \
xtables-addons-dkms
mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]')/gpg | gpg --dearmor --yes -o /etc/apt/keyrings/docker.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]') \
$(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
apt update
apt install -y docker-ce docker-ce-cli containerd.io
DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker}
mkdir -p $DOCKER_CONFIG/cli-plugins
curl -SL https://github.com/docker/compose/releases/download/v2.29.6/docker-compose-linux-x86_64 -o $DOCKER_CONFIG/cli-plugins/docker-compose
chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose
curl -fsSL https://get.docker.com -o get-docker.sh && sh get-docker.sh
git clone https://github.com/mercurykd/vpnbot.git
cd ./vpnbot
echo "<?php
+1 -1
View File
@@ -6,7 +6,7 @@ After=docker.service
Type=oneshot
RemainAfterExit=yes
WorkingDirectory=path
ExecStartPre=/bin/sh -c "touch ./override.env"
ExecStartPre=/bin/sh -c "touch ./override.env ./docker-compose.override.yml"
ExecStart=/bin/sh -c "IP=$(curl https://ipinfo.io/ip) VER=$(git describe --tags) docker compose --env-file ./.env --env-file ./override.env up -d --force-recreate"
ExecStartPost=/bin/sh -c "bash ./update/update.sh &"
ExecStop=/bin/sh -c "docker compose down --remove-orphans"
+12 -9
View File
@@ -12,17 +12,20 @@ do
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" ]]
if [[ "$cmd" == "1" ]]
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
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
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 ipinfo.io/ip) VER=$(git describe --tags) docker compose --env-file ./.env --env-file ./override.env up -d --force-recreate
bash $pwd/update/update.sh &
+10
View File
@@ -1,3 +1,13 @@
11.11.2024 v1.98
- фикс заполнения clientId при наполнении белого списка клиентов adg
09.11.2024 v1.97
- новая ссылка на чат поддержки. пожалуйста не размещайте ее на форумах и чатах во избежание набега leafers https://www.youtube.com/watch?v=9tlNJmjuKD4
06.11.2024 v1.96
- фикс пароля adguard
- таймаоут для проверки статуса adguard
04.11.2024 v1.95
- отключение портов контейнеров из меню
- перезагрузка из меню
04.11.2024 v1.94
- xray: возможность перемещать и переименовывать outbound заполняемый ботом
04.11.2024 v1.93