Compare commits

..

20 Commits

Author SHA1 Message Date
mercury 1cf24407c0 nip.io button to quickly change domain 2024-10-30 22:39:55 +04:00
mercury d3470bd8ea update version 2024-10-27 01:53:55 +04:00
mercury 1fcddf49e3 fixup! fixup! fix warp update 2024-10-27 01:42:25 +04:00
mercury a0d9bada2b fixup! fix warp update 2024-10-27 01:32:13 +04:00
mercury 32109c4526 fix warp update 2024-10-27 01:12:29 +04:00
mercury ca37736cd5 fix menu rulesset with empty rules 2024-10-26 23:14:03 +04:00
mercury 1c4fff50d1 fix menu warp after update 2024-10-26 22:47:43 +04:00
mercury 6ffb4d0a79 update version 2024-10-26 22:41:07 +04:00
mercury 394062cbe0 fix warp off after update 2024-10-26 22:29:07 +04:00
mercury dd8897575f fix warp off after update 2024-10-26 22:18:36 +04:00
mercury 9ab05de320 fix update menu 2024-10-26 21:58:10 +04:00
legiz-ru 71f7db5bac update singbox 1.10.1 windows x64 (#26) 2024-10-26 19:47:15 +04:00
mercury 237da68f14 duplicate the rulesset list in the message 2024-10-26 14:44:06 +04:00
mercury 961ebf3423 xray->routes->proxy <=> Pac 2024-10-25 21:02:58 +04:00
mercury ddcaea751f update version 2024-10-25 18:43:32 +04:00
mercury ce8cdac7c7 Fix for auto-backup not triggering on the first tick 2024-10-25 18:36:54 +04:00
mercury 00aae6c2f7 adguard: list of allowed clients 2024-10-25 18:12:05 +04:00
mercury 89c0139ef6 show safe search status 2024-10-25 17:38:50 +04:00
mercury c57053c8a0 copyable warp key 2024-10-25 17:14:52 +04:00
mercury 3cc16469ff warp registration delete before off 2024-10-25 17:11:46 +04:00
6 changed files with 159 additions and 23 deletions
+123 -21
View File
@@ -142,6 +142,9 @@ class Bot
case preg_match('~^/autoupdate$~', $this->input['message'], $m):
$this->autoupdate();
break;
case preg_match('~^/adgFillAllowedClients(?: (\d+))?$~', $this->input['callback'], $m):
$this->adgFillAllowedClients($m[1] ?: false);
break;
case preg_match('~^/appOutbound$~', $this->input['callback'], $m):
$this->appOutbound();
break;
@@ -398,6 +401,9 @@ class Bot
case preg_match('~^/deldomain$~', $this->input['callback'], $m):
$this->delDomain();
break;
case preg_match('~^/addNipdomain$~', $this->input['callback'], $m):
$this->addNipdomain();
break;
case preg_match('~^/(?P<action>change|delete)(?P<typelist>\w+) (?P<arg>\d+)$~', $this->input['callback'], $m):
$this->listPacChange($m['typelist'], $m['action'], $m['arg']);
break;
@@ -434,6 +440,9 @@ class Bot
case preg_match('~^/xtlswarp(?: (\d+))?$~', $this->input['callback'], $m):
$this->xtlswarp($m[1] ?: 0);
break;
case preg_match('~^/xtlsproxy(?: (\d+))?$~', $this->input['callback'], $m):
$this->xtlsproxy($m[1] ?: 0);
break;
case preg_match('~^/xtlsapp(?: (\d+))?$~', $this->input['callback'], $m):
$this->xtlsapp($m[1] ?: 0);
break;
@@ -1063,17 +1072,18 @@ class Bot
public function cron()
{
$period = 10;
while (true) {
$this->shutdownClient();
$this->shutdownClientXr();
$this->checkVersion();
$this->checkBackup();
$this->checkBackup($period);
$this->checkCert();
sleep(10);
sleep($period);
}
}
public function checkBackup()
public function checkBackup($delta)
{
$c = $this->getPacConf();
if (!empty($c['backup'])) {
@@ -1085,8 +1095,8 @@ class Bot
!empty($start)
&& !empty($period)
&& empty($this->backup)
&& $now - $start >= $period
&& ($now - $start) % $period < 10
&& $now - $start >= 0
&& (($now - $start) % $period < $delta)
) {
if (!empty($c['pinbackup'])) {
$this->pinAdmin($c['pinbackup'], 1);
@@ -1758,6 +1768,11 @@ class Bot
}
}
public function addNipdomain()
{
$this->addDomain(str_replace('.', '-', $this->ip) . '.nip.io');
}
public function addDomain($domain, $nomenu = false)
{
$domain = trim($domain);
@@ -2466,7 +2481,10 @@ DNS-over-HTTPS with IP:
{
switch ($type) {
case 'includelist':
$this->pacUpdate();
$this->pacUpdate($_SESSION['proxylistentry']);
if (!empty($_SESSION['proxylistentry'])) {
$this->xtlsproxy();
}
break;
case 'blocklist':
$this->xrayUpdateRules();
@@ -3346,6 +3364,7 @@ DNS-over-HTTPS with IP:
public function pacMenu($page = 0)
{
unset($_SESSION['proxylistentry']);
$rmpac = stat(__DIR__ . '/zapretlists/rmpac');
$rpac = stat(__DIR__ . '/zapretlists/rpac');
$mpac = stat(__DIR__ . '/zapretlists/mpac');
@@ -3426,7 +3445,7 @@ DNS-over-HTTPS with IP:
'callback_data' => "/addCommunityFilter",
],
];
$data = array_merge($data, $this->listPac('includelist', $page, 'pacMenu'));
$data = array_merge($data, $this->listPac('includelist', $page, 'pacMenu')[0]);
$data[] = [
[
'text' => $this->i18n('back'),
@@ -3565,7 +3584,7 @@ DNS-over-HTTPS with IP:
{
$text[] = "Menu -> " . $this->i18n('xray') . ' -> ' . $this->i18n('routes') . ' -> block list';
$data = $this->listPac('blocklist', $page, 'xtlsblock');
[$data] = $this->listPac('blocklist', $page, 'xtlsblock');
$data[] = [
[
'text' => $this->i18n('back'),
@@ -3584,7 +3603,26 @@ DNS-over-HTTPS with IP:
{
$text[] = "Menu -> " . $this->i18n('xray') . ' -> ' . $this->i18n('routes') . ' -> warp list';
$data = $this->listPac('warplist', $page, 'xtlswarp');
[$data] = $this->listPac('warplist', $page, 'xtlswarp');
$data[] = [
[
'text' => $this->i18n('back'),
'callback_data' => "/routes",
],
];
$this->update(
$this->input['chat'],
$this->input['message_id'],
implode("\n", $text ?: ['...']),
$data ?: false,
);
}
public function xtlsproxy($page = 0)
{
$_SESSION['proxylistentry'] = 1;
$text[] = "Menu -> " . $this->i18n('xray') . ' -> ' . $this->i18n('routes') . ' -> proxy list';
[$data] = $this->listPac('includelist', $page, 'xtlsproxy');
$data[] = [
[
'text' => $this->i18n('back'),
@@ -3619,7 +3657,7 @@ DNS-over-HTTPS with IP:
{
$text[] = "Menu -> " . $this->i18n('xray') . ' -> ' . $this->i18n('routes') . ' -> package list';
$data = $this->listPac('packagelist', $page, 'xtlsapp');
[$data] = $this->listPac('packagelist', $page, 'xtlsapp');
$p = $this->getPacConf();
$data[] = [
[
@@ -3645,7 +3683,7 @@ DNS-over-HTTPS with IP:
{
$text[] = "Menu -> " . $this->i18n('xray') . ' -> ' . $this->i18n('routes') . ' -> process list';
$data = $this->listPac('processlist', $page, 'xtlsprocess');
[$data] = $this->listPac('processlist', $page, 'xtlsprocess');
$p = $this->getPacConf();
$data[] = [
[
@@ -3671,7 +3709,8 @@ DNS-over-HTTPS with IP:
{
$text[] = "Menu -> " . $this->i18n('xray') . ' -> ' . $this->i18n('routes') . ' -> rulesset list';
$data = $this->listPac('rulessetlist', $page, 'xtlsrulesset', 1);
[$data, $tmp] = $this->listPac('rulessetlist', $page, 'xtlsrulesset', 1);
$text = array_merge($text, $tmp ?: []);
$data[] = [
[
'text' => $this->i18n('back'),
@@ -3702,6 +3741,9 @@ DNS-over-HTTPS with IP:
$domains = array_slice($domains, $page * $this->limit, $this->limit, true);
$i = 0;
foreach ($domains as $k => $v) {
if ($type == 'rulessetlist') {
$text[] = "<blockquote><code>$k</code></blockquote>";
}
$data[] = [
[
'text' => $this->i18n($v ? 'on' : 'off') . ' ' . ($basename ? basename($k) . ' ' : '') . (in_array($type, ['rulessetlist', 'packagelist', 'processlist']) ? $k : idn_to_utf8($k)),
@@ -3748,7 +3790,7 @@ DNS-over-HTTPS with IP:
],
];
}
return $data;
return [$data, $text];
}
public function listPacChange($type, $action, $key)
@@ -4585,6 +4627,10 @@ DNS-over-HTTPS with IP:
'text' => $this->i18n('warp'),
'callback_data' => "/xtlswarp",
]],
[[
'text' => $this->i18n('proxy'),
'callback_data' => "/xtlsproxy",
]],
[[
'text' => $this->i18n('process'),
'callback_data' => "/xtlsprocess",
@@ -4654,11 +4700,13 @@ DNS-over-HTTPS with IP:
public function offWarp()
{
$p = $this->getPacConf();
if (empty($p['warpoff'])) {
$this->ssh('pkill warp-svc', 'wp');
$p['warpoff'] = 1;
} else {
$p = $this->getPacConf();
if (!empty($this->selfupdate)) {
if (!empty($p['warpoff'])) {
$this->ssh('warp-cli --accept-tos registration delete 2>&1', 'wp');
$this->ssh('pkill warp-svc', 'wp');
}
} elseif (!empty($p['warpoff'])) {
$this->ssh('warp-svc > /dev/null 2>&1 &', 'wp');
sleep(3);
if (empty($this->ssh('[ -f "/var/lib/cloudflare-warp/conf.json" ] && echo 1', 'wp'))) {
@@ -4670,9 +4718,15 @@ DNS-over-HTTPS with IP:
$this->send($this->input['chat'], 'Proxy mode: ' . $this->ssh('warp-cli --accept-tos mode proxy 2>&1', 'wp'));
$this->send($this->input['chat'], 'Connect: ' . $this->ssh('warp-cli --accept-tos connect 2>&1', 'wp'));
unset($p['warpoff']);
} else {
$this->send($this->input['chat'], 'Registration delete: ' . $this->ssh('warp-cli --accept-tos registration delete 2>&1', 'wp'));
$this->ssh('pkill warp-svc', 'wp');
$p['warpoff'] = 1;
}
$this->setPacConf($p);
$this->warp();
if (empty($this->selfupdate)) {
$this->warp();
}
}
public function warp()
@@ -4680,7 +4734,7 @@ DNS-over-HTTPS with IP:
$p = $this->getPacConf();
$text[] = "Menu -> " . $this->i18n('warp');
$text[] = "status: " . $this->warpStatus();
$text[] = "key: " . $this->getPacConf()['warp'];
$text[] = "key: <code>{$this->getPacConf()['warp']}</code>";
$data[] = [
[
'text' => $this->i18n($p['warpoff'] ? 'off' : 'on'),
@@ -5329,6 +5383,11 @@ 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>";
}
$safesearch = yaml_parse_file($this->adguard)['filtering']['safe_search']['enabled'];
$text .= "\n\nsafesearch: " . $this->i18n($safesearch ? 'on' : 'off');
$allowedClients = yaml_parse_file($this->adguard)['dns']['allowed_clients'];
$text .= $allowedClients ? "\n\nallowed clients: \n - " . implode("\n - ", $allowedClients) : '';
$data = [
[
[
@@ -5353,6 +5412,16 @@ DNS-over-HTTPS with IP:
],
],
];
$data[] = [
[
'text' => $this->i18n('fill allowed clients'),
'callback_data' => "/adgFillAllowedClients 0",
],
[
'text' => $this->i18n('delete allowed clients'),
'callback_data' => "/adgFillAllowedClients 1",
],
];
$data[] = [
[
'text' => $this->i18n('add upstream'),
@@ -5390,6 +5459,34 @@ DNS-over-HTTPS with IP:
];
}
public function adgFillAllowedClients($delete = false)
{
$pac = $this->getPacConf();
$out[] = 'Restart Adguard Home';
$this->update($this->input['chat'], $this->input['message_id'], implode("\n", $out));
$this->stopAd();
$c = yaml_parse_file($this->adguard);
if (!empty($delete)) {
unset($c['dns']['allowed_clients']);
} else {
$c['dns']['allowed_clients'] = [];
if (!empty($pac['adguardKey'])) {
$c['dns']['allowed_clients'][] = $pac['adguardKey'];
}
$c['dns']['allowed_clients'][] = getenv('WGADDRESS');
$c['dns']['allowed_clients'][] = getenv('WG1ADDRESS');
$c['dns']['allowed_clients'][] = '10.0.2.0/24'; // openconnect
if (!empty($xr = $this->getXray())) {
foreach ($xr['inbounds'][0]['settings']['clients'] as $v) {
$c['dns']['allowed_clients'][] = $v['id'];
}
}
}
yaml_emit_file($this->adguard, $c);
$this->startAd();
$this->menu('adguard');
}
public function menuLang()
{
$data = [];
@@ -5465,7 +5562,7 @@ DNS-over-HTTPS with IP:
];
exec("git -C / branch -vv", $mm);
return [
'text' => '<pre><code class="language-shell">' . implode("\n", $mm) . '</code></pre>',
'text' => '<pre><code class="language-shell">' . htmlentities(implode("\n", $mm)) . '</code></pre>',
'data' => $data,
];
}
@@ -5509,6 +5606,10 @@ DNS-over-HTTPS with IP:
'text' => $this->i18n('+ subdomain'),
'callback_data' => '/addSubdomain',
],
[
'text' => $this->i18n('nip.io'),
'callback_data' => '/addNipdomain',
],
],
];
if ($conf['domain']) {
@@ -5755,6 +5856,7 @@ DNS-over-HTTPS with IP:
$this->input['message_id'] = $rm[1];
$this->input['callback_id'] = $rm[1];
if (file_exists($this->update)) {
$this->selfupdate = true;
if (!empty($m)) {
$this->send($this->input['chat'], "<pre>$m</pre>", $rm[1]);
}
+10 -2
View File
@@ -282,8 +282,8 @@ $i = [
'ru' => 'пагинация',
],
'exchange' => [
'en' => 'open ip',
'ru' => 'откр айпи',
'en' => 'client isolation',
'ru' => 'изоляция клиентов',
],
'ocserv' => [
'en' => 'OpenConnect',
@@ -345,4 +345,12 @@ $i = [
'en' => 'expose-iroutes',
'ru' => 'изоляция клиентов',
],
'fill allowed clients' => [
'en' => 'fill allowed clients',
'ru' => 'заполнить белый список клиентов',
],
'delete allowed clients' => [
'en' => 'delete allowed clients',
'ru' => 'очистить белый список клиентов',
],
];
+3
View File
@@ -14,6 +14,9 @@ $bot = new Bot($c['key'], $i);
$bot->selfUpdate();
$bot->restartTG();
if (!empty($bot->selfupdate)) {
$bot->offWarp();
}
$bot->dontshowcron = 1;
$bot->sslip();
$bot->cleanDocker();
+3
View File
@@ -16,5 +16,8 @@ dns:
tls:
certificate_path: /certs/cert_public
private_key_path: /certs/cert_private
filtering:
safe_search:
enabled: false
log:
file: /logs/adguard
Binary file not shown.
+20
View File
@@ -1,3 +1,23 @@
30.10.2024 v1.91
- кнопка nip.io для быстрой смены домена
27.10.2024 v1.90
- очередной фикс запуска warp после апдейта
- правки фраз меню
26.10.2024 v1.89
- xray rulesset: фикс меню при отсутствующих правилах
26.10.2024 v1.88
- xray rulesset: дублирование кнопок текстом
- singbox 1.10.1 для windows x64
- фикс с включенным warp после апдейта
- фикс с нерабочей кнопкой апдейта, обновится можно через /autoupdate если поймали не рабочую кнопку апдейта
25.10.2024 v1.87
- xray: в routes добавлен раздел proxy - зеркало раздела Pac
25.10.2024 v1.86
- фикс не срабатывания автобэкапа во время старта
- adguard: вывод списка разрешенных клиентов
- adguard: кнопка заполнения разрешенных клиентов - собирает все clientId со всех контейнеров
- adguard: вывод статуса безопасного поиска
- warp: при выключении удаляется регистрация deviceid
24.10.2024 v1.85
- фикс удаления состояния warp после рестарта
- возможность перезаписать фразы меню бота через app/override.php