Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e06544b00f | |||
| c5b7e1ffdc | |||
| 7d21937f04 | |||
| 16138648ca | |||
| ced10f22fa | |||
| 18a4ee39fb | |||
| 4f4777b5ef | |||
| dee90b1f4f | |||
| 01571f50e6 | |||
| 4998893234 | |||
| 95f92791b1 | |||
| cedfb66ca0 | |||
| 6215836926 | |||
| 842d76261a | |||
| 4c63ae669a | |||
| bba1ec9e17 | |||
| a798df0fd3 |
+2
-1
@@ -20,4 +20,5 @@ update/*
|
||||
!update/update.sh
|
||||
|
||||
override.env
|
||||
override.html
|
||||
override.html
|
||||
override.php
|
||||
+57
-48
@@ -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']);
|
||||
}
|
||||
@@ -1456,8 +1459,10 @@ class Bot
|
||||
$this->update($this->input['chat'], $this->input['message_id'], implode("\n", $out));
|
||||
$this->language = $this->getPacConf()['language'] ?: 'en';
|
||||
$this->limit = $this->getPacConf()['limitpage'] ?: 5;
|
||||
sleep(3);
|
||||
$this->menu();
|
||||
if (empty($file)) {
|
||||
sleep(3);
|
||||
$this->menu();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1798,13 +1803,14 @@ 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');
|
||||
}
|
||||
$this->menu(dontshowcron: 1);
|
||||
$this->menu();
|
||||
}
|
||||
|
||||
public function comment($text, $tag)
|
||||
@@ -3855,13 +3861,13 @@ DNS-over-HTTPS with IP:
|
||||
$this->menu('wg', 0);
|
||||
}
|
||||
|
||||
public function menu($type = false, $arg = false, $return = false, $dontshowcron = false)
|
||||
public function menu($type = false, $arg = false, $return = false)
|
||||
{
|
||||
$domain = $this->getPacConf()['domain'] ?: $this->ip;
|
||||
$cron = exec('pgrep -f cron.php');
|
||||
$menu = [
|
||||
'main' => [
|
||||
'text' => 'v' . getenv('VER') . ($dontshowcron ? '' : "\ncron: " . $this->i18n($cron ? 'on' : 'off') . ($cron ? '' : ' show <code>logs/php_error</code>')),
|
||||
'text' => 'v' . getenv('VER') . ($this->dontshowcron ? '' : "\ncron: " . $this->i18n($cron ? 'on' : 'off') . ($cron ? '' : ' show <code>logs/php_error</code>')),
|
||||
'data' => [
|
||||
[
|
||||
[
|
||||
@@ -4153,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>";
|
||||
@@ -4655,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'));
|
||||
@@ -5041,6 +5049,14 @@ DNS-over-HTTPS with IP:
|
||||
}
|
||||
$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);
|
||||
}
|
||||
|
||||
@@ -5732,28 +5748,21 @@ DNS-over-HTTPS with IP:
|
||||
|
||||
public function selfUpdate()
|
||||
{
|
||||
require __DIR__ . '/config.php';
|
||||
if (!empty($c['admin'])) {
|
||||
$ip = getenv('IP');
|
||||
$rm = explode(':', trim(file_get_contents('/update/reload_message')));
|
||||
$m = file_get_contents('/update/message');
|
||||
if (file_exists($this->update)) {
|
||||
$r = $this->send($c['admin'][0], "start update");
|
||||
$this->input['chat'] = $c['admin'][0];
|
||||
$this->input['message_id'] = $r['result']['message_id'];
|
||||
if (!empty($m)) {
|
||||
$this->send($c['admin'][0], "<pre>$m</pre>", $rm[1]);
|
||||
}
|
||||
$r = $this->send($c['admin'][0], "import settings");
|
||||
$this->input['chat'] = $c['admin'][0];
|
||||
$this->input['message_id'] = $r['result']['message_id'];
|
||||
$this->input['callback_id'] = $r['result']['message_id'];
|
||||
if (empty($flag)) {
|
||||
$this->importFile($this->update);
|
||||
unlink($this->update);
|
||||
$flag = true;
|
||||
}
|
||||
$ip = getenv('IP');
|
||||
$rm = explode(':', trim(file_get_contents('/update/reload_message')));
|
||||
$m = file_get_contents('/update/message');
|
||||
$this->input['chat'] = $rm[0];
|
||||
$this->input['message_id'] = $rm[1];
|
||||
$this->input['callback_id'] = $rm[1];
|
||||
if (file_exists($this->update)) {
|
||||
if (!empty($m)) {
|
||||
$this->send($this->input['chat'], "<pre>$m</pre>", $rm[1]);
|
||||
}
|
||||
$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);
|
||||
unlink($this->update);
|
||||
}
|
||||
file_put_contents('/update/message', '');
|
||||
file_put_contents('/update/reload_message', '');
|
||||
@@ -6013,25 +6022,25 @@ DNS-over-HTTPS with IP:
|
||||
|
||||
public function createConfig($data)
|
||||
{
|
||||
$pac = $this->getPacConf();
|
||||
$conf[] = "[Interface]";
|
||||
if (empty($data['interface']['ListenPort'])) {
|
||||
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'])) {
|
||||
$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) {
|
||||
$conf[] = "$k = $v";
|
||||
}
|
||||
$pac = $this->getPacConf();
|
||||
if (!empty($data['peers'])) {
|
||||
foreach ($data['peers'] as $peer) {
|
||||
$conf[] = '';
|
||||
$conf[] = $peer['# PublicKey'] ? '# [Peer]' : '[Peer]';
|
||||
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) {
|
||||
$conf[] = "$k = $v";
|
||||
|
||||
@@ -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,8 @@ if ($c['debug']) {
|
||||
|
||||
$bot = new Bot($c['key'], $i);
|
||||
|
||||
$bot->selfUpdate();
|
||||
$bot->restartTG();
|
||||
$bot->dontshowcron = 1;
|
||||
$bot->sslip();
|
||||
$bot->cleanDocker();
|
||||
|
||||
@@ -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,18 @@
|
||||
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
|
||||
- фикс пустых правил для singbox
|
||||
23.10.2024 v1.79
|
||||
- улучшение процесса обновления
|
||||
23.10.2024 v1.78
|
||||
- фикс двойного импорта при обновлении, когда админов больше одного
|
||||
- рестарт бота сбрасывает очередь сообщений от телеграма
|
||||
|
||||
Reference in New Issue
Block a user