Compare commits

...

10 Commits

Author SHA1 Message Date
mercury e06544b00f update version 2024-10-24 23:45:25 +04:00
mercury c5b7e1ffdc warp registration fix 2024-10-24 23:15:44 +04:00
mercury 7d21937f04 ability to override i18n 2024-10-24 22:32:16 +04:00
mercury 16138648ca fix openconnect link 2024-10-24 21:54:37 +04:00
mercury ced10f22fa update version 2024-10-24 00:01:51 +04:00
mercury 18a4ee39fb improve selfupdate 2024-10-23 23:59:32 +04:00
mercury 4f4777b5ef improve selfupdate 2024-10-23 23:56:50 +04:00
mercury dee90b1f4f improve selfupdate 2024-10-23 23:53:58 +04:00
mercury 01571f50e6 improve selfupdate 2024-10-23 23:29:56 +04:00
mercury 4998893234 fix autobackup 2024-10-23 21:35:17 +04:00
8 changed files with 51 additions and 35 deletions
+2 -1
View File
@@ -20,4 +20,5 @@ update/*
!update/update.sh
override.env
override.html
override.html
override.php
+28 -30
View File
@@ -1076,23 +1076,27 @@ class Bot
public function checkBackup()
{
$c = $this->getPacConf();
$now = strtotime(date('Y-m-d H:i'));
if (!empty($c['backup'])) {
$now = strtotime(date('Y-m-d H:i:s'));
[$start, $period] = explode('/', $c['backup']);
$start = strtotime($start);
$period = strtotime($period, 0);
if (!empty($start) && !empty($period)) {
if ($now - $start >= $period && ($now - $start) % $period == 0) {
if (!empty($c['pinbackup'])) {
$this->pinAdmin($c['pinbackup'], 1);
}
$this->pinBackup();
$start = strtotime(trim($start));
$period = strtotime(trim($period), 0);
if (
!empty($start)
&& !empty($period)
&& empty($this->backup)
&& $now - $start >= $period
&& ($now - $start) % $period < 10
) {
if (!empty($c['pinbackup'])) {
$this->pinAdmin($c['pinbackup'], 1);
}
$this->pinBackup();
}
}
}
public function cleanQueue()
public function cleanQueue(): void
{
$r = $this->request('deleteWebhook', []);
$r = $this->request('getUpdates', ['offset' => -1]);
@@ -1112,9 +1116,8 @@ class Bot
{
require __DIR__ . '/config.php';
$conf = $this->getPacConf();
$bot = $this->request('getMyName', [])['result']['name'];
$bot = preg_replace('~[\W]~iu', '_', $this->request('getMyName', [])['result']['name']);
$conf['pinbackup'] = $this->upload("{$bot}_export_" . date('d_m_Y_H_i') . '.json', $this->export(), $c['admin'][0])['result']['message_id'];
$conf['backup'] = implode(' / ', [date('Y-m-d H:i'), trim(explode('/', $conf['backup'])[1])]);
$this->setPacConf($conf);
$this->pinAdmin($conf['pinbackup']);
}
@@ -1324,7 +1327,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);
@@ -1364,11 +1367,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
@@ -1377,11 +1376,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
@@ -1808,8 +1803,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');
@@ -4163,7 +4159,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>";
@@ -4665,9 +4661,11 @@ DNS-over-HTTPS with IP:
} 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'));
@@ -5763,7 +5761,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', '');
+3
View File
@@ -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;
-1
View File
@@ -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();
+1
View File
@@ -12,6 +12,7 @@ if ($c['debug']) {
$bot = new Bot($c['key'], $i);
$bot->selfUpdate();
$bot->restartTG();
$bot->dontshowcron = 1;
$bot->sslip();
+2
View File
@@ -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
View File
@@ -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
+9
View File
@@ -1,3 +1,12 @@
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
- фикс краша wireguard после апдейта
23.10.2024 v1.80