Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ddcaea751f | |||
| ce8cdac7c7 | |||
| 00aae6c2f7 | |||
| 89c0139ef6 | |||
| c57053c8a0 | |||
| 3cc16469ff | |||
| e06544b00f | |||
| c5b7e1ffdc | |||
| 7d21937f04 | |||
| 16138648ca | |||
| ced10f22fa | |||
| 18a4ee39fb | |||
| 4f4777b5ef | |||
| dee90b1f4f | |||
| 01571f50e6 |
+2
-1
@@ -20,4 +20,5 @@ update/*
|
||||
!update/update.sh
|
||||
|
||||
override.env
|
||||
override.html
|
||||
override.html
|
||||
override.php
|
||||
+67
-24
@@ -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;
|
||||
@@ -1063,17 +1066,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 +1089,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);
|
||||
@@ -1327,7 +1331,7 @@ class Bot
|
||||
];
|
||||
}
|
||||
|
||||
public function importFile($file = false, $autoupdate = false)
|
||||
public function importFile($file = false)
|
||||
{
|
||||
if (!empty($file)) {
|
||||
$json = json_decode(file_get_contents($file), true);
|
||||
@@ -1367,11 +1371,7 @@ class Bot
|
||||
$this->update($this->input['chat'], $this->input['message_id'], implode("\n", $out));
|
||||
$this->wg = 0;
|
||||
$this->saveClients($json['wg']['clients']);
|
||||
if (empty($autoupdate)) {
|
||||
$this->restartWG($this->createConfig($json['wg']['server']), $switch_amnezia);
|
||||
} else {
|
||||
file_put_contents('/config/wg0.conf', $this->createConfig($json['wg']['server']));
|
||||
}
|
||||
$this->restartWG($this->createConfig($json['wg']['server']), $switch_amnezia);
|
||||
$this->iptablesWG();
|
||||
}
|
||||
// wg1
|
||||
@@ -1380,11 +1380,7 @@ class Bot
|
||||
$this->update($this->input['chat'], $this->input['message_id'], implode("\n", $out));
|
||||
$this->wg = 1;
|
||||
$this->saveClients($json['wg1']['clients']);
|
||||
if (empty($autoupdate)) {
|
||||
$this->restartWG($this->createConfig($json['wg1']['server']), $switch_wg1amnezia);
|
||||
} else {
|
||||
file_put_contents('/config/wg1.conf', $this->createConfig($json['wg1']['server']));
|
||||
}
|
||||
$this->restartWG($this->createConfig($json['wg1']['server']), $switch_wg1amnezia);
|
||||
$this->iptablesWG();
|
||||
}
|
||||
// ad
|
||||
@@ -1811,8 +1807,9 @@ class Bot
|
||||
$ip = getenv('IP');
|
||||
$r = $this->send($c['admin'][0], "start $ip");
|
||||
|
||||
$this->input['chat'] = $c['admin'][0];
|
||||
$this->input['message_id'] = $r['result']['message_id'];
|
||||
$this->input['chat'] = $c['admin'][0];
|
||||
$this->input['message_id'] = $r['result']['message_id'];
|
||||
$this->input['callback_id'] = false;
|
||||
if (empty($p['domain'])) {
|
||||
$this->addDomain(str_replace('.', '-', $this->ip) . '.nip.io', 1);
|
||||
$this->setSSL('letsencrypt');
|
||||
@@ -4166,7 +4163,7 @@ DNS-over-HTTPS with IP:
|
||||
$expose = $m[1];
|
||||
$pass = htmlspecialchars($pac['ocserv']);
|
||||
$text[] = "Menu -> OpenConnect";
|
||||
if (!empty($m[1])) {
|
||||
if (!empty($cs)) {
|
||||
$text[] = "<code>https://oc.$domain/?$cs</code>";
|
||||
}
|
||||
$text[] = "password: <span class='tg-spoiler'>$pass</span>";
|
||||
@@ -4663,14 +4660,17 @@ DNS-over-HTTPS with IP:
|
||||
{
|
||||
$p = $this->getPacConf();
|
||||
if (empty($p['warpoff'])) {
|
||||
$this->ssh('warp-cli --accept-tos registration delete', 'wp');
|
||||
$this->ssh('pkill warp-svc', 'wp');
|
||||
$p['warpoff'] = 1;
|
||||
} else {
|
||||
$this->ssh('warp-svc > /dev/null 2>&1 &', 'wp');
|
||||
sleep(3);
|
||||
$this->send($this->input['chat'], 'Registration: ' . $this->ssh('warp-cli --accept-tos registration new 2>&1', 'wp'));
|
||||
if (!empty($p['warp'])) {
|
||||
$this->send($this->input['chat'], 'License: ' . $this->ssh("warp-cli --accept-tos registration license {$p['warp']} 2>&1", 'wp'));
|
||||
if (empty($this->ssh('[ -f "/var/lib/cloudflare-warp/conf.json" ] && echo 1', 'wp'))) {
|
||||
$this->send($this->input['chat'], 'Registration: ' . $this->ssh('warp-cli --accept-tos registration new 2>&1', 'wp'));
|
||||
if (!empty($p['warp'])) {
|
||||
$this->send($this->input['chat'], 'License: ' . $this->ssh("warp-cli --accept-tos registration license {$p['warp']} 2>&1", 'wp'));
|
||||
}
|
||||
}
|
||||
$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'));
|
||||
@@ -4685,7 +4685,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'),
|
||||
@@ -5334,6 +5334,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 = [
|
||||
[
|
||||
[
|
||||
@@ -5358,6 +5363,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'),
|
||||
@@ -5395,6 +5410,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 = [];
|
||||
@@ -5766,7 +5809,7 @@ DNS-over-HTTPS with IP:
|
||||
$r = $this->send($this->input['chat'], "import settings");
|
||||
$this->input['message_id'] = $r['result']['message_id'];
|
||||
$this->input['callback_id'] = $r['result']['message_id'];
|
||||
$this->importFile($this->update, 1);
|
||||
$this->importFile($this->update);
|
||||
unlink($this->update);
|
||||
}
|
||||
file_put_contents('/update/message', '');
|
||||
|
||||
@@ -11,6 +11,9 @@ if ('POST' == $_SERVER['REQUEST_METHOD'] && $_GET['k'] == $c['key']) {
|
||||
require __DIR__ . '/calc.php';
|
||||
require __DIR__ . '/bot.php';
|
||||
require __DIR__ . '/i18n.php';
|
||||
if (file_exists(__DIR__ . '/override.php')) {
|
||||
include __DIR__ . '/override.php';
|
||||
}
|
||||
$bot = new Bot($c['key'], $i);
|
||||
$bot->input();
|
||||
exit;
|
||||
|
||||
@@ -12,7 +12,6 @@ if ($c['debug']) {
|
||||
$bot = new Bot($c['key'], $i);
|
||||
$bot->cleanQueue();
|
||||
$bot->setwebhook();
|
||||
$bot->selfUpdate();
|
||||
$bot->adguardCheckPswd();
|
||||
$bot->adguardProtect();
|
||||
$bot->syncPortClients();
|
||||
|
||||
@@ -12,6 +12,7 @@ if ($c['debug']) {
|
||||
|
||||
$bot = new Bot($c['key'], $i);
|
||||
|
||||
$bot->selfUpdate();
|
||||
$bot->restartTG();
|
||||
$bot->dontshowcron = 1;
|
||||
$bot->sslip();
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -16,6 +16,7 @@ networks:
|
||||
- subnet: 10.10.1.0/24
|
||||
volumes:
|
||||
adguard:
|
||||
warp:
|
||||
|
||||
services:
|
||||
up:
|
||||
@@ -510,6 +511,7 @@ services:
|
||||
- ./config:/config
|
||||
- ./certs:/certs
|
||||
- ./scripts/start_wp.sh:/start_wp.sh
|
||||
- warp:/var/lib/cloudflare-warp
|
||||
hostname: warp
|
||||
container_name: warp-${VER}
|
||||
depends_on:
|
||||
|
||||
+6
-3
@@ -7,10 +7,13 @@ if [ "$off" == 'null' ]
|
||||
then
|
||||
warp-svc > /dev/null &
|
||||
sleep 3
|
||||
warp-cli --accept-tos registration new
|
||||
if [ ! -z "$key" ]
|
||||
if [ ! -f /var/lib/cloudflare-warp/conf.json ]
|
||||
then
|
||||
warp-cli --accept-tos registration license $key
|
||||
warp-cli --accept-tos registration new
|
||||
if [ ! -z "$key" ]
|
||||
then
|
||||
warp-cli --accept-tos registration license $key
|
||||
fi
|
||||
fi
|
||||
warp-cli --accept-tos mode proxy
|
||||
warp-cli --accept-tos connect
|
||||
|
||||
@@ -1,3 +1,16 @@
|
||||
25.10.2024 v1.86
|
||||
- фикс не срабатывания автобэкапа во время старта
|
||||
- adguard: вывод списка разрешенных клиентов
|
||||
- adguard: кнопка заполнения разрешенных клиентов - собирает все clientId со всех контейнеров
|
||||
- adguard: вывод статуса безопасного поиска
|
||||
- warp: при выключении удаляется регистрация deviceid
|
||||
24.10.2024 v1.85
|
||||
- фикс удаления состояния warp после рестарта
|
||||
- возможность перезаписать фразы меню бота через app/override.php
|
||||
24.10.2024 v1.84
|
||||
- фикс показа ссылки для openconnect
|
||||
24.10.2024 v1.83
|
||||
- фикс ошибок доступа контейнеров при автообновлении
|
||||
23.10.2024 v1.82
|
||||
- фикс автобэкапа
|
||||
23.10.2024 v1.81
|
||||
|
||||
Reference in New Issue
Block a user