Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 51ecb815ba | |||
| 66cee61d41 | |||
| 66225917fe | |||
| be227f6a33 | |||
| 37d392a240 | |||
| 565573cfc2 | |||
| 3813f43b92 | |||
| f34427c13c |
+33
-23
@@ -600,7 +600,7 @@ class Bot
|
||||
$this->addOverrideHtml();
|
||||
break;
|
||||
case preg_match('~^/export$~', $this->input['callback'], $m):
|
||||
$this->exportManual();
|
||||
$this->pinBackup();
|
||||
break;
|
||||
case preg_match('~^/import$~', $this->input['callback'], $m):
|
||||
$this->import();
|
||||
@@ -1228,7 +1228,7 @@ class Bot
|
||||
|
||||
public function checkBackup($delta)
|
||||
{
|
||||
$c = $this->getPacConf();
|
||||
$c = $this->getPacConf();
|
||||
if (!empty($c['backup'])) {
|
||||
$now = strtotime(date('Y-m-d H:i:s'));
|
||||
[$start, $period] = explode('/', $c['backup']);
|
||||
@@ -1241,9 +1241,6 @@ class Bot
|
||||
&& $now - $start >= 0
|
||||
&& (($now - $start) % $period < $delta)
|
||||
) {
|
||||
if (!empty($c['pinbackup'])) {
|
||||
$this->pinAdmin($c['pinbackup'], 1);
|
||||
}
|
||||
$this->pinBackup();
|
||||
}
|
||||
}
|
||||
@@ -1265,12 +1262,19 @@ class Bot
|
||||
}
|
||||
}
|
||||
|
||||
public function pinBackup()
|
||||
public function pinBackup($file = false)
|
||||
{
|
||||
require __DIR__ . '/config.php';
|
||||
$conf = $this->getPacConf();
|
||||
$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 = $this->getPacConf();
|
||||
$bot = preg_replace('~[\W]~iu', '_', $this->request('getMyName', [])['result']['name']);
|
||||
$json = $this->export();
|
||||
if (!empty($file)) {
|
||||
file_put_contents($file, $json);
|
||||
}
|
||||
if (!empty($conf['pinbackup'])) {
|
||||
$this->pinAdmin($conf['pinbackup'], 1);
|
||||
}
|
||||
$conf['pinbackup'] = $this->upload("{$bot}_export_" . date('d_m_Y_H_i') . '.json', $json, $c['admin'][0])['result']['message_id'];
|
||||
$this->setPacConf($conf);
|
||||
$this->pinAdmin($conf['pinbackup']);
|
||||
}
|
||||
@@ -1293,9 +1297,13 @@ class Bot
|
||||
$this->send($v, implode("\n", $diff), 0, [
|
||||
[
|
||||
[
|
||||
'text' => 'changelog',
|
||||
'text' => 'changelog',
|
||||
'web_app' => ['url' => "https://raw.githubusercontent.com/mercurykd/vpnbot/$b/version"],
|
||||
]
|
||||
],
|
||||
[
|
||||
'text' => $this->i18n('update bot'),
|
||||
'callback_data' => "/applyupdatebot",
|
||||
],
|
||||
]
|
||||
]);
|
||||
}
|
||||
@@ -1454,16 +1462,6 @@ class Bot
|
||||
return json_encode($conf, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
}
|
||||
|
||||
public function exportManual($file = false)
|
||||
{
|
||||
$json = $this->export();
|
||||
if (!empty($file)) {
|
||||
file_put_contents($file, $json);
|
||||
}
|
||||
$bot = preg_replace('~[\W]~iu', '_', $this->request('getMyName', [])['result']['name']);
|
||||
return $this->upload("{$bot}_export_" . date('d_m_Y_H_i') . '.json', $json);
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
$r = $this->send(
|
||||
@@ -4547,7 +4545,7 @@ DNS-over-HTTPS with IP:
|
||||
|
||||
public function denyList($page = 0, $white = 0)
|
||||
{
|
||||
$text = 'Menu -> IP -> ' . ($white ? 'white' : 'deny') . ' list';
|
||||
$text = 'Menu -> IP -> ' . ($white ? 'ignore' : 'block') . 'list';
|
||||
$domains = $this->getPacConf()[$white ? 'white' : 'deny'] ?: [];
|
||||
$all = (int) ceil(count($domains) / $this->limit);
|
||||
$page = min($page, $all - 1);
|
||||
@@ -4689,6 +4687,18 @@ DNS-over-HTTPS with IP:
|
||||
public function syncDeny()
|
||||
{
|
||||
$pac = $this->getPacConf();
|
||||
if ($r = fopen('/logs/nginx_tlgrm_access', 'r')) {
|
||||
while (feof($r) === false) {
|
||||
$l = fgets($r);
|
||||
if (preg_match('~(\d+\.\d+\.\d+\.\d+)~', $l, $m)) {
|
||||
$xr[$m[1]] = true;
|
||||
}
|
||||
}
|
||||
fclose($r);
|
||||
}
|
||||
foreach (array_keys($xr) as $v) {
|
||||
$text .= "allow $v;\n";
|
||||
}
|
||||
if (!empty($pac['white'])) {
|
||||
$pac['white'] = array_unique($pac['white']);
|
||||
sort($pac['white']);
|
||||
@@ -6368,7 +6378,7 @@ DNS-over-HTTPS with IP:
|
||||
|
||||
public function applyupdatebot()
|
||||
{
|
||||
$this->exportManual($this->update);
|
||||
$this->pinBackup($this->update);
|
||||
$r = $this->send($this->input['from'], 'update...');
|
||||
file_put_contents('/update/reload_message', "{$this->input['from']}:{$r['result']['message_id']}");
|
||||
file_put_contents('/update/key', $this->key);
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ if (!empty($bot->selfupdate)) {
|
||||
$bot->offWarp();
|
||||
}
|
||||
$bot->dontshowcron = 1;
|
||||
$bot->adguardSync();
|
||||
$bot->sslip();
|
||||
$bot->adguardSync();
|
||||
$bot->syncDeny();
|
||||
$bot->cleanDocker();
|
||||
|
||||
@@ -160,7 +160,9 @@ services:
|
||||
- ./ssh:/ssh
|
||||
- ./app:/app
|
||||
- ./logs/:/logs/
|
||||
- ./version:/version
|
||||
- ./update:/update
|
||||
- ./.git:/.git
|
||||
- ./scripts/start_service.sh:/start_service.sh
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||
environment:
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
make d
|
||||
rm /etc/systemd/resolved.conf.d/adguardhome.conf
|
||||
mv /etc/resolv.conf.backup /etc/resolv.conf
|
||||
systemctl reload-or-restart systemd-resolved
|
||||
make u
|
||||
@@ -1,8 +0,0 @@
|
||||
mkdir /etc/systemd/resolved.conf.d
|
||||
echo "[Resolve]
|
||||
DNS=127.0.0.1
|
||||
DNSStubListener=no" > /etc/systemd/resolved.conf.d/adguardhome.conf
|
||||
mv /etc/resolv.conf /etc/resolv.conf.backup
|
||||
ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
|
||||
systemctl reload-or-restart systemd-resolved
|
||||
make d u
|
||||
@@ -1,3 +1,10 @@
|
||||
17.11.2024 v1.105
|
||||
- фикс установки домена при первом запуске
|
||||
16.11.2024 v1.104
|
||||
- единая механика закрепления бэкапа
|
||||
- фикс текста уведомления о новой версии
|
||||
16.11.2024 v1.103
|
||||
- фикс уведомления о новой версии
|
||||
16.11.2024 v1.102
|
||||
- переделан раздел списка ip под управление кнопками
|
||||
- возможность добавить свои айпи в blocklist/whitelist
|
||||
|
||||
Reference in New Issue
Block a user