Compare commits

...

6 Commits

Author SHA1 Message Date
mercury 4ef0de6e1c ability to download origin template 2024-10-30 23:16:17 +04:00
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
4 changed files with 64 additions and 13 deletions
+44 -10
View File
@@ -401,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;
@@ -452,6 +455,9 @@ class Bot
case preg_match('~^/delTemplate (\w+)(?: (.+))?$~', $this->input['callback'], $m):
$this->delTemplate($m[1], $m[2]);
break;
case preg_match('~^/downloadOrigin (\w+)$~', $this->input['callback'], $m):
$this->downloadOrigin($m[1]);
break;
case preg_match('~^/downloadTemplate (\w+)(?: (.+))?$~', $this->input['callback'], $m):
$this->downloadTemplate($m[1], $m[2]);
break;
@@ -1765,6 +1771,11 @@ class Bot
}
}
public function addNipdomain()
{
$this->addDomain(str_replace('.', '-', $this->ip) . '.nip.io');
}
public function addDomain($domain, $nomenu = false)
{
$domain = trim($domain);
@@ -4407,6 +4418,19 @@ DNS-over-HTTPS with IP:
$this->templates($type);
}
public function downloadOrigin($type)
{
switch ($type) {
case 'sing':
$f = new \CURLFile('/config/sing.json', 'application/json', 'origin.json');
break;
case 'v2ray':
$f = new \CURLFile('/config/v2ray.json', 'application/json', 'origin.json');
break;
}
$this->sendFile($this->input['chat'], $f);
}
public function downloadTemplate($type, $name)
{
$pac = $this->getPacConf();
@@ -4445,6 +4469,10 @@ DNS-over-HTTPS with IP:
'text' => "origin",
'web_app' => ['url' => "https://$domain/pac?h=$hash&t=te&ty=$type"],
],
[
'text' => $this->i18n('download'),
'callback_data' => "/downloadOrigin $type",
],
[
'text' => $this->i18n($pac["default{$type}template"] && !empty($pac["{$type}templates"][base64_decode($pac["default{$type}template"])]) ? 'off' : 'on'),
'callback_data' => "/defaultTemplate $type",
@@ -4453,7 +4481,7 @@ DNS-over-HTTPS with IP:
foreach ($templates as $k => $v) {
$data[] = [
[
'text' => "$k",
'text' => $k,
'web_app' => ['url' => "https://$domain/pac?h=$hash&t=te&ty=$type&te=" . urlencode($k)],
],
[
@@ -4690,10 +4718,15 @@ DNS-over-HTTPS with IP:
return 'off';
}
public function offWarp($inversion = true)
public function offWarp()
{
$p = $this->getPacConf();
if ($inversion && !empty($p['warpoff'])) {
$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'))) {
@@ -4706,16 +4739,12 @@ DNS-over-HTTPS with IP:
$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->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);
if (!empty($inversion)) {
if (empty($this->selfupdate)) {
$this->warp();
}
}
@@ -5597,6 +5626,10 @@ DNS-over-HTTPS with IP:
'text' => $this->i18n('+ subdomain'),
'callback_data' => '/addSubdomain',
],
[
'text' => $this->i18n('nip.io'),
'callback_data' => '/addNipdomain',
],
],
];
if ($conf['domain']) {
@@ -5843,6 +5876,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 -1
View File
@@ -14,7 +14,9 @@ $bot = new Bot($c['key'], $i);
$bot->selfUpdate();
$bot->restartTG();
$bot->offWarp(0);
if (!empty($bot->selfupdate)) {
$bot->offWarp();
}
$bot->dontshowcron = 1;
$bot->sslip();
$bot->cleanDocker();
+7
View File
@@ -1,3 +1,10 @@
30.10.2024 v1.92
- возможность скачать origin шаблон
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