diff --git a/app/bot.php b/app/bot.php index adc7a62..274b7f2 100644 --- a/app/bot.php +++ b/app/bot.php @@ -1031,22 +1031,17 @@ class Bot public function checkBackup() { - $c = time(); - $conf = $this->getPacConf(); - $time = $conf['backup']; - if ($time) { - preg_match('~(\d+\s\w+)(?:\s+)?/(?:\s+)?(\d{2}:\d{2})~', $time, $m); - $period = strtotime($m[1]) - $c; - $start = strtotime($m[2]); - $last = $conf['pinbackup']; - if ($last) { - [$pin, $time] = explode('/', $last); - if ($c - $time >= $period) { - $this->pinAdmin($pin, 1); - $this->pinBackup(); - return; + $c = $this->getPacConf(); + $now = strtotime(date('Y-m-d H:i')); + if (!empty($c['backup'])) { + [$start, $period] = explode('/', $c['backup']); + $start = strtotime($start); + $period = strtotime($period, 0); + (var_dump($now, $start, $period, ($now - $start) % $period)); + if ($now - $start >= $period && ($now - $start) % $period == 0) { + if (!empty($c['pinbackup'])) { + $this->pinAdmin($c['pinbackup'], 1); } - } elseif ($c - $start > 0 && $c - $start < 30) { $this->pinBackup(); } } @@ -1067,10 +1062,10 @@ class Bot require __DIR__ . '/config.php'; $conf = $this->getPacConf(); $bot = $this->request('getMyName', [])['result']['name']; - $pin = $this->upload("{$bot}_export_" . date('d_m_Y_H_i') . '.json', $this->export(), $c['admin'][0])['result']['message_id']; - $conf['pinbackup'] = "$pin/" . time(); + $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($pin); + $this->pinAdmin($conf['pinbackup']); } public function checkVersion() @@ -4857,15 +4852,17 @@ DNS-over-HTTPS with IP: 'text' => $this->i18n('export'), 'callback_data' => "/export", ], - [ - 'text' => $this->i18n('backup') . ': ' . (implode(' / ', explode('/', $conf['backup'])) ?: $this->i18n('off')), - 'callback_data' => "/backup", - ], [ 'text' => $this->i18n('import'), 'callback_data' => "/import", ], ]; + $data[] = [ + [ + 'text' => $this->i18n('backup') . ': ' . (implode(' / ', explode('/', $conf['backup'])) ?: $this->i18n('off')), + 'callback_data' => "/backup", + ], + ]; $data[] = [ [ 'text' => $this->i18n('logs'), @@ -5062,16 +5059,15 @@ DNS-over-HTTPS with IP: public function setBackup($text) { $text = trim($text); - $c = $this->getPacConf(); + $c = $this->getPacConf(); if (empty($text)) { $c['backup'] = ''; - } elseif (preg_match('~(\d+\s\w+)(?:\s+)?/(?:\s+)?(\d{2}:\d{2})~', $text, $m)) { - $period = $m[1]; - $start = $m[2]; - $c['backup'] = $text; + } else { + [$start, $period] = explode('/', $text); + $c['backup'] = implode(' / ', [date('Y-m-d H:i', strtotime($start)), trim($period)]); } - if ($pin = explode('/', $c['pinbackup'])[0]) { - $this->pinAdmin($pin, 1); + if ($c['pinbackup']) { + $this->pinAdmin($c['pinbackup'], 1); $c['pinbackup'] = ''; } $this->setPacConf($c); diff --git a/docker-compose.yml b/docker-compose.yml index 1a92975..12cf9e5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -183,7 +183,7 @@ services: - oc - np proxy: - image: mercurykd/vpnbot-ss:1.1 + image: mercurykd/vpnbot-ss:1.2 build: dockerfile: dockerfile/shadowsocks.dockerfile args: @@ -330,7 +330,7 @@ services: entrypoint: ["/bin/sh", "/start_ad.sh"] logging: *default-logging ss: - image: mercurykd/vpnbot-ss:1.1 + image: mercurykd/vpnbot-ss:1.2 build: dockerfile: dockerfile/shadowsocks.dockerfile args: diff --git a/dockerfile/shadowsocks.dockerfile b/dockerfile/shadowsocks.dockerfile index ed79010..23770c2 100644 --- a/dockerfile/shadowsocks.dockerfile +++ b/dockerfile/shadowsocks.dockerfile @@ -2,16 +2,16 @@ ARG image FROM $image RUN apk add openssh git xz \ && mkdir /root/.ssh \ - && wget https://github.com/shadowsocks/shadowsocks-rust/releases/download/v1.15.3/shadowsocks-v1.15.3.x86_64-unknown-linux-musl.tar.xz \ - && tar -xf shadowsocks-v1.15.3.x86_64-unknown-linux-musl.tar.xz \ - && wget https://github.com/teddysun/v2ray-plugin/releases/download/v5.7.0/v2ray-plugin-linux-amd64-v5.7.0.tar.gz \ - && tar -xf v2ray-plugin-linux-amd64-v5.7.0.tar.gz \ + && wget -O shadowsocks-rust.x86_64-unknown-linux-musl.tar.xz $(wget -q -O - https://api.github.com/repos/shadowsocks/shadowsocks-rust/releases/latest | grep browser_download_url | cut -d\" -f4 | egrep '.x86_64-unknown-linux-musl.tar.xz$') \ + && tar -xf shadowsocks-rust.x86_64-unknown-linux-musl.tar.xz \ + && wget -O v2ray-plugin-linux-amd64.tar.gz $(wget -q -O - https://api.github.com/repos/teddysun/v2ray-plugin/releases/latest | grep browser_download_url | cut -d\" -f4 | egrep 'v2ray-plugin-linux-amd64') \ + && tar -xf v2ray-plugin-linux-amd64.tar.gz \ && mv sslocal /usr/bin/ \ && mv ssserver /usr/bin/ \ && mv ssmanager /usr/bin/ \ && mv ssservice /usr/bin/ \ && mv ssurl /usr/bin/ \ && mv v2ray-plugin_linux_amd64 /usr/bin/v2ray-plugin \ - && rm v2ray-plugin-linux-amd64-v5.7.0.tar.gz\ - && rm shadowsocks-v1.15.3.x86_64-unknown-linux-musl.tar.xz + && rm v2ray-plugin-linux-amd64.tar.gz \ + && rm shadowsocks-rust.x86_64-unknown-linux-musl.tar.xz ENV ENV="/root/.ashrc" diff --git a/version b/version index 8caf0df..3ce715c 100644 --- a/version +++ b/version @@ -1,3 +1,5 @@ +18.05.2024 v1.39 +- изменен автобэкап 04.05.2024 v1.38 - changelog в сообщении новой версии 04.05.2024 v1.37.1