|
|
|
@@ -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;
|
|
|
|
@@ -434,6 +437,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 +1069,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 +1092,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);
|
|
|
|
@@ -2466,7 +2473,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 +3356,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 +3437,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 +3576,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 +3595,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 +3649,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 +3675,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 +3701,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 +3733,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 +3782,7 @@ DNS-over-HTTPS with IP:
|
|
|
|
|
],
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
return $data;
|
|
|
|
|
return [$data, $text];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function listPacChange($type, $action, $key)
|
|
|
|
@@ -4585,6 +4619,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",
|
|
|
|
@@ -4652,13 +4690,10 @@ DNS-over-HTTPS with IP:
|
|
|
|
|
return 'off';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function offWarp()
|
|
|
|
|
public function offWarp($inversion = true)
|
|
|
|
|
{
|
|
|
|
|
$p = $this->getPacConf();
|
|
|
|
|
if (empty($p['warpoff'])) {
|
|
|
|
|
$this->ssh('pkill warp-svc', 'wp');
|
|
|
|
|
$p['warpoff'] = 1;
|
|
|
|
|
} else {
|
|
|
|
|
if ($inversion && !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 +4705,19 @@ 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 {
|
|
|
|
|
if (empty($inversion)) {
|
|
|
|
|
$this->ssh('warp-cli --accept-tos registration delete 2>&1', 'wp');
|
|
|
|
|
} 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($inversion)) {
|
|
|
|
|
$this->warp();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function warp()
|
|
|
|
@@ -4680,7 +4725,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 +5374,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 +5403,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 +5450,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 +5553,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,
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|