Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1dfb3da089 | |||
| 7358730864 | |||
| 57cd1019f5 | |||
| dfbcd67f83 | |||
| 5016c6bda3 | |||
| bc3914c3b9 | |||
| 4675371f19 | |||
| 6efe31d404 |
+2
-1
@@ -21,4 +21,5 @@ update/*
|
||||
|
||||
override.env
|
||||
override.html
|
||||
override.php
|
||||
override.php
|
||||
docker-compose.override.yml
|
||||
+133
-27
@@ -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;
|
||||
@@ -4462,7 +4471,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 +4725,7 @@ DNS-over-HTTPS with IP:
|
||||
$text[] = "Menu -> " . $this->i18n('xray') . ' -> routes';
|
||||
|
||||
$p = $this->getPacConf();
|
||||
$outbound = $p['outbound'] ?: 'proxy';
|
||||
|
||||
$data = [
|
||||
[[
|
||||
@@ -4731,19 +4741,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 +5122,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 +5153,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 +5166,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 +5204,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);
|
||||
|
||||
@@ -5675,6 +5696,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 +5837,10 @@ DNS-over-HTTPS with IP:
|
||||
'text' => $this->i18n('fake html'),
|
||||
'callback_data' => "/addOverrideHtml",
|
||||
],
|
||||
[
|
||||
'text' => $this->i18n('ports'),
|
||||
'callback_data' => "/ports",
|
||||
],
|
||||
];
|
||||
$data[] = [
|
||||
[
|
||||
@@ -5818,6 +5857,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 +5874,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);
|
||||
|
||||
@@ -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
@@ -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
@@ -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",
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
@@ -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 &
|
||||
|
||||
Reference in New Issue
Block a user