Compare commits

...

10 Commits

Author SHA1 Message Date
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
mercury 95f92791b1 update version 2024-10-23 10:08:32 +04:00
mercury cedfb66ca0 fix autoupdate wireguard crash 2024-10-23 10:05:06 +04:00
mercury 6215836926 fix empty route rules for singbox 2024-10-23 03:01:10 +04:00
4 changed files with 42 additions and 20 deletions
+31 -19
View File
@@ -1076,23 +1076,27 @@ class Bot
public function checkBackup() public function checkBackup()
{ {
$c = $this->getPacConf(); $c = $this->getPacConf();
$now = strtotime(date('Y-m-d H:i'));
if (!empty($c['backup'])) { if (!empty($c['backup'])) {
$now = strtotime(date('Y-m-d H:i:s'));
[$start, $period] = explode('/', $c['backup']); [$start, $period] = explode('/', $c['backup']);
$start = strtotime($start); $start = strtotime(trim($start));
$period = strtotime($period, 0); $period = strtotime(trim($period), 0);
if (!empty($start) && !empty($period)) { if (
if ($now - $start >= $period && ($now - $start) % $period == 0) { !empty($start)
if (!empty($c['pinbackup'])) { && !empty($period)
$this->pinAdmin($c['pinbackup'], 1); && empty($this->backup)
} && $now - $start >= $period
$this->pinBackup(); && ($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('deleteWebhook', []);
$r = $this->request('getUpdates', ['offset' => -1]); $r = $this->request('getUpdates', ['offset' => -1]);
@@ -1112,9 +1116,8 @@ class Bot
{ {
require __DIR__ . '/config.php'; require __DIR__ . '/config.php';
$conf = $this->getPacConf(); $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['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->setPacConf($conf);
$this->pinAdmin($conf['pinbackup']); $this->pinAdmin($conf['pinbackup']);
} }
@@ -1800,8 +1803,9 @@ class Bot
$ip = getenv('IP'); $ip = getenv('IP');
$r = $this->send($c['admin'][0], "start $ip"); $r = $this->send($c['admin'][0], "start $ip");
$this->input['chat'] = $c['admin'][0]; $this->input['chat'] = $c['admin'][0];
$this->input['message_id'] = $r['result']['message_id']; $this->input['message_id'] = $r['result']['message_id'];
$this->input['callback_id'] = false;
if (empty($p['domain'])) { if (empty($p['domain'])) {
$this->addDomain(str_replace('.', '-', $this->ip) . '.nip.io', 1); $this->addDomain(str_replace('.', '-', $this->ip) . '.nip.io', 1);
$this->setSSL('letsencrypt'); $this->setSSL('letsencrypt');
@@ -4155,7 +4159,7 @@ DNS-over-HTTPS with IP:
$expose = $m[1]; $expose = $m[1];
$pass = htmlspecialchars($pac['ocserv']); $pass = htmlspecialchars($pac['ocserv']);
$text[] = "Menu -> OpenConnect"; $text[] = "Menu -> OpenConnect";
if (!empty($m[1])) { if (!empty($cs)) {
$text[] = "<code>https://oc.$domain/?$cs</code>"; $text[] = "<code>https://oc.$domain/?$cs</code>";
} }
$text[] = "password: <span class='tg-spoiler'>$pass</span>"; $text[] = "password: <span class='tg-spoiler'>$pass</span>";
@@ -5043,6 +5047,14 @@ DNS-over-HTTPS with IP:
} }
$json['routing']['rules'] = array_values($json['routing']['rules']); $json['routing']['rules'] = array_values($json['routing']['rules']);
} }
if (!empty($json['route']['rules'])) {
foreach ($json['route']['rules'] as $k => $v) {
if (count($v) < 2) {
unset($json['route']['rules'][$k]);
}
}
$json['route']['rules'] = array_values($json['route']['rules']);
}
return json_encode($json); return json_encode($json);
} }
@@ -6008,25 +6020,25 @@ DNS-over-HTTPS with IP:
public function createConfig($data) public function createConfig($data)
{ {
$pac = $this->getPacConf();
$conf[] = "[Interface]"; $conf[] = "[Interface]";
if (empty($data['interface']['ListenPort'])) { if (empty($data['interface']['ListenPort'])) {
if (empty($data['interface']['DNS'])) { if (empty($data['interface']['DNS'])) {
$data['interface']['DNS'] = $this->getPacConf()[$this->getInstanceWG(1) . 'dns'] ?: $this->dns; $data['interface']['DNS'] = $pac[$this->getInstanceWG(1) . 'dns'] ?: $this->dns;
} }
if (empty($data['interface']['MTU'])) { if (empty($data['interface']['MTU'])) {
$data['interface']['MTU'] = $this->getPacConf()[$this->getInstanceWG(1) . 'mtu'] ?: $this->mtu; $data['interface']['MTU'] = $pac[$this->getInstanceWG(1) . 'mtu'] ?: $this->mtu;
} }
} }
foreach ($data['interface'] as $k => $v) { foreach ($data['interface'] as $k => $v) {
$conf[] = "$k = $v"; $conf[] = "$k = $v";
} }
$pac = $this->getPacConf();
if (!empty($data['peers'])) { if (!empty($data['peers'])) {
foreach ($data['peers'] as $peer) { foreach ($data['peers'] as $peer) {
$conf[] = ''; $conf[] = '';
$conf[] = $peer['# PublicKey'] ? '# [Peer]' : '[Peer]'; $conf[] = $peer['# PublicKey'] ? '# [Peer]' : '[Peer]';
if (!empty($peer['Endpoint'])) { if (!empty($peer['Endpoint'])) {
$peer['Endpoint'] = ($this->getPacConf()[$this->getInstanceWG(1) . 'endpoint'] ? $this->ip : $this->getDomain()) . ":" . getenv($this->getInstanceWG(1) ? 'WG1PORT' : 'WGPORT'); $peer['Endpoint'] = ($pac[$this->getInstanceWG(1) . 'endpoint'] ? $this->ip : $this->getDomain()) . ":" . getenv($this->getInstanceWG(1) ? 'WG1PORT' : 'WGPORT');
} }
foreach ($peer as $k => $v) { foreach ($peer as $k => $v) {
$conf[] = "$k = $v"; $conf[] = "$k = $v";
-1
View File
@@ -12,7 +12,6 @@ if ($c['debug']) {
$bot = new Bot($c['key'], $i); $bot = new Bot($c['key'], $i);
$bot->cleanQueue(); $bot->cleanQueue();
$bot->setwebhook(); $bot->setwebhook();
$bot->selfUpdate();
$bot->adguardCheckPswd(); $bot->adguardCheckPswd();
$bot->adguardProtect(); $bot->adguardProtect();
$bot->syncPortClients(); $bot->syncPortClients();
+1
View File
@@ -12,6 +12,7 @@ if ($c['debug']) {
$bot = new Bot($c['key'], $i); $bot = new Bot($c['key'], $i);
$bot->selfUpdate();
$bot->restartTG(); $bot->restartTG();
$bot->dontshowcron = 1; $bot->dontshowcron = 1;
$bot->sslip(); $bot->sslip();
+10
View File
@@ -1,3 +1,13 @@
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
- фикс пустых правил для singbox
23.10.2024 v1.79 23.10.2024 v1.79
- улучшение процесса обновления - улучшение процесса обновления
23.10.2024 v1.78 23.10.2024 v1.78