Compare commits

...

11 Commits

Author SHA1 Message Date
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
mercury 4675371f19 update version 2024-11-04 11:50:10 +04:00
mercury 6efe31d404 you can change the position and name of the outbound, filled in by the bot 2024-11-04 01:14:55 +04:00
11 changed files with 187 additions and 56 deletions
+2 -1
View File
@@ -21,4 +21,5 @@ update/*
override.env
override.html
override.php
override.php
docker-compose.override.yml
+137 -29
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'];
@@ -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:
@@ -4716,6 +4727,7 @@ DNS-over-HTTPS with IP:
$text[] = "Menu -> " . $this->i18n('xray') . ' -> routes';
$p = $this->getPacConf();
$outbound = $p['outbound'] ?: 'proxy';
$data = [
[[
@@ -4731,19 +4743,19 @@ DNS-over-HTTPS with IP:
'callback_data' => "/xtlsrulesset",
]],
[[
'text' => 'domains: ' . ($p['domains_outbound'] ? 'direct' : 'proxy'),
'text' => 'domains: ' . ($p['domains_outbound'] ? 'direct' : $outbound),
'callback_data' => "/xtlsproxy",
]],
[[
'text' => 'process: ' . ($p['process_outbound'] ? 'direct' : 'proxy'),
'text' => 'process: ' . ($p['process_outbound'] ? 'direct' : $outbound),
'callback_data' => "/xtlsprocess",
]],
[[
'text' => 'package: ' . ($p['app_outbound'] ? 'direct' : 'proxy'),
'text' => 'package: ' . ($p['app_outbound'] ? 'direct' : $outbound),
'callback_data' => "/xtlsapp",
]],
[[
'text' => 'final: ' . ($p['final_outbound'] ? 'proxy' : 'direct'),
'text' => 'final: ' . ($p['final_outbound'] ? $outbound : 'direct'),
'callback_data' => "/finalOutbound",
]],
];
@@ -5112,15 +5124,26 @@ DNS-over-HTTPS with IP:
break;
}
$outbound = $pac['outbound'] ?: 'proxy';
$c = json_decode($this->replaceTags(json_encode($c), [
'~outbound~' => $outbound,
]), true);
foreach ($c['outbounds'] as $k => $v) {
if ($v['tag'] == $outbound) {
$index = $k;
break;
}
}
switch ($_GET['t']) {
case 's':
$c['outbounds'][0]['settings']['vnext'][0]['address'] = '~domain~';
$c['outbounds'][0]['settings']['vnext'][0]['users'][0] = [
$c['outbounds'][$index]['settings']['vnext'][0]['address'] = '~domain~';
$c['outbounds'][$index]['settings']['vnext'][0]['users'][0] = [
'id' => '~uid~',
'encryption' => 'none',
];
if ($pac['transport'] == 'Websocket') {
$c['outbounds'][0]['streamSettings'] = [
$c['outbounds'][$index]['streamSettings'] = [
"network" => "ws",
"security" => "tls",
"wsSettings" => [
@@ -5132,10 +5155,10 @@ DNS-over-HTTPS with IP:
"fingerprint" => "chrome"
]
];
unset($c['outbounds'][0]['mux']);
unset($c['outbounds'][$index]['mux']);
} else {
$c['outbounds'][0]['settings']['vnext'][0]['users'][0]["flow"] = "xtls-rprx-vision";
$c['outbounds'][0]['streamSettings'] = [
$c['outbounds'][$index]['settings']['vnext'][0]['users'][0]["flow"] = "xtls-rprx-vision";
$c['outbounds'][$index]['streamSettings'] = [
"network" => "tcp",
"security" => "reality",
"realitySettings" => [
@@ -5145,29 +5168,29 @@ DNS-over-HTTPS with IP:
"shortId" => '~short_id~',
]
];
$c['outbounds'][0]['mux'] = [
$c['outbounds'][$index]['mux'] = [
"enabled" => false,
"concurrency" => -1
];
}
break;
case 'si':
$c['outbounds'][0]['server'] = '~domain~';
$c['outbounds'][0]['uuid'] = '~uid~';
$c['outbounds'][$index]['server'] = '~domain~';
$c['outbounds'][$index]['uuid'] = '~uid~';
if ($pac['transport'] == 'Websocket') {
unset($c['outbounds'][0]['tls']['reality']);
unset($c['outbounds'][0]['flow']);
$c['outbounds'][0]["transport"] = [
unset($c['outbounds'][$index]['tls']['reality']);
unset($c['outbounds'][$index]['flow']);
$c['outbounds'][$index]["transport"] = [
"type" => "ws",
"path" => "/ws"
];
$c['outbounds'][0]['tls']['server_name'] = '~domain~';
$c['outbounds'][$index]['tls']['server_name'] = '~domain~';
} else {
unset($c['outbounds'][0]["transport"]);
$c['outbounds'][0]['flow'] = 'xtls-rprx-vision';
$c['outbounds'][0]['tls']['reality']['public_key'] = '~public_key~';
$c['outbounds'][0]['tls']['server_name'] = '~server_name~';
$c['outbounds'][0]['tls']['reality']['short_id'] = '~short_id~';
unset($c['outbounds'][$index]["transport"]);
$c['outbounds'][$index]['flow'] = 'xtls-rprx-vision';
$c['outbounds'][$index]['tls']['reality']['public_key'] = '~public_key~';
$c['outbounds'][$index]['tls']['server_name'] = '~server_name~';
$c['outbounds'][$index]['tls']['reality']['short_id'] = '~short_id~';
}
$c['route'] = $this->addRuleSet($c['route']);
@@ -5183,10 +5206,10 @@ DNS-over-HTTPS with IP:
'~short_id~' => $xr['inbounds'][0]['streamSettings']['realitySettings']['shortIds'][0],
'~public_key~' => $pac['xray'],
'~server_name~' => $xr['inbounds'][0]['streamSettings']['realitySettings']['serverNames'][0],
'~app_outbound~' => $pac['app_outbound'] ? 'direct' : 'proxy',
'~process_outbound~' => $pac['process_outbound'] ? 'direct' : 'proxy',
'~domains_outbound~' => $pac['domains_outbound'] ? 'direct' : 'proxy',
'~final_outbound~' => $pac['final_outbound'] ? 'proxy' : 'direct',
'~app_outbound~' => $pac['app_outbound'] ? 'direct' : $outbound,
'~process_outbound~' => $pac['process_outbound'] ? 'direct' : $outbound,
'~domains_outbound~' => $pac['domains_outbound'] ? 'direct' : $outbound,
'~final_outbound~' => $pac['final_outbound'] ? $outbound : 'direct',
]);
$json = $this->clearEmptyRules($json);
@@ -5468,7 +5491,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'];
@@ -5675,6 +5698,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');
@@ -5802,6 +5839,10 @@ DNS-over-HTTPS with IP:
'text' => $this->i18n('fake html'),
'callback_data' => "/addOverrideHtml",
],
[
'text' => $this->i18n('ports'),
'callback_data' => "/ports",
],
];
$data[] = [
[
@@ -5818,6 +5859,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[] = [
[
@@ -5831,6 +5876,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);
+20
View File
@@ -353,4 +353,24 @@ $i = [
'en' => 'delete allowed clients',
'ru' => 'очистить белый список клиентов',
],
'success' => [
'en' => 'success',
'ru' => 'сохранено',
],
'error' => [
'en' => 'error',
'ru' => 'ошибка',
],
'save' => [
'en' => 'save',
'ru' => 'сохранить',
],
'copy' => [
'en' => 'copy',
'ru' => 'копировать',
],
'restart' => [
'en' => 'restart',
'ru' => 'перезагрузка',
],
];
+2 -2
View File
@@ -87,7 +87,7 @@
"uuid": "~uid~",
"type": "vless",
"domain_strategy": "ipv4_only",
"tag": "proxy"
"tag": "~outbound~"
},
{
"type": "direct",
@@ -178,7 +178,7 @@
]
}
],
"outbound": "proxy"
"outbound": "~outbound~"
},
{
"outbound": "direct"
+2 -2
View File
@@ -36,7 +36,7 @@
}
}],
"outbounds": [{
"tag": "proxy",
"tag": "~outbound~",
"protocol": "vless",
"settings": {
"vnext": [{
@@ -84,7 +84,7 @@
"domainStrategy": "AsIs",
"rules": [{
"type": "field",
"outboundTag": "proxy",
"outboundTag": "~outbound~",
"domain": "~pac~"
}, {
"type": "field",
+1
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}
+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 &
+8
View File
@@ -1,3 +1,11 @@
06.11.2024 v1.96
- фикс пароля adguard
- таймаоут для проверки статуса adguard
04.11.2024 v1.95
- отключение портов контейнеров из меню
- перезагрузка из меню
04.11.2024 v1.94
- xray: возможность перемещать и переименовывать outbound заполняемый ботом
04.11.2024 v1.93
- adguardHome: сброс настроек
- adguardHome: статус работоспособности