Compare commits

...

3 Commits

Author SHA1 Message Date
mercury 3b9b930b48 - autobackup check formate
- cron status
- fix with sending a backup when there are special characters in the bot name
2024-10-23 01:24:36 +04:00
mercury bd17e5cd14 improve ip detect on start 2024-10-22 23:55:05 +04:00
mercury c3975549db openconnect: isolate-workers = false 2024-10-22 22:42:20 +04:00
5 changed files with 30 additions and 15 deletions
+19 -8
View File
@@ -1081,11 +1081,13 @@ class Bot
[$start, $period] = explode('/', $c['backup']); [$start, $period] = explode('/', $c['backup']);
$start = strtotime($start); $start = strtotime($start);
$period = strtotime($period, 0); $period = strtotime($period, 0);
if ($now - $start >= $period && ($now - $start) % $period == 0) { if (!empty($start) && !empty($period)) {
if (!empty($c['pinbackup'])) { if ($now - $start >= $period && ($now - $start) % $period == 0) {
$this->pinAdmin($c['pinbackup'], 1); if (!empty($c['pinbackup'])) {
$this->pinAdmin($c['pinbackup'], 1);
}
$this->pinBackup();
} }
$this->pinBackup();
} }
} }
} }
@@ -1296,7 +1298,7 @@ class Bot
if (!empty($file)) { if (!empty($file)) {
file_put_contents($file, $json); file_put_contents($file, $json);
} }
$bot = $this->request('getMyName', [])['result']['name']; $bot = preg_replace('~[\W]~iu', '_', $this->request('getMyName', [])['result']['name']);
return $this->upload("{$bot}_export_" . date('d_m_Y_H_i') . '.json', $json); return $this->upload("{$bot}_export_" . date('d_m_Y_H_i') . '.json', $json);
} }
@@ -3843,9 +3845,10 @@ DNS-over-HTTPS with IP:
public function menu($type = false, $arg = false, $return = false) public function menu($type = false, $arg = false, $return = false)
{ {
$domain = $this->getPacConf()['domain'] ?: $this->ip; $domain = $this->getPacConf()['domain'] ?: $this->ip;
$cron = exec('pgrep -f cron.php');
$menu = [ $menu = [
'main' => [ 'main' => [
'text' => 'v' . getenv('VER'), 'text' => 'v' . getenv('VER') . "\ncron: " . $this->i18n($cron ? 'on' : 'off') . ($cron ? '' : ' show <code>logs/php_error</code>'),
'data' => [ 'data' => [
[ [
[ [
@@ -5565,7 +5568,11 @@ DNS-over-HTTPS with IP:
]; ];
$backup = array_filter(explode('/', $conf['backup'])); $backup = array_filter(explode('/', $conf['backup']));
if (!empty($backup)) { if (!empty($backup)) {
$backup = "{$backup[0]} start / {$backup[1]} period"; if (!empty(strtotime($backup[0])) && !empty(strtotime($backup[1]))) {
$backup = "{$backup[0]} start / {$backup[1]} period";
} else {
$backup = $this->i18n('off') . " {$conf['backup']} - wrong format";
}
} }
$data[] = [ $data[] = [
[ [
@@ -5875,7 +5882,11 @@ DNS-over-HTTPS with IP:
$c['backup'] = ''; $c['backup'] = '';
} else { } else {
[$start, $period] = explode('/', $text); [$start, $period] = explode('/', $text);
$c['backup'] = implode(' / ', [date('Y-m-d H:i', strtotime($start)), trim($period)]); if (!empty(strtotime($start)) && !empty(strtotime($period))) {
$c['backup'] = implode(' / ', [date('Y-m-d H:i', strtotime($start)), trim($period)]);
} else {
$this->send($this->input['from'], $this->input['message'] . ' - wrong format');
}
} }
if ($c['pinbackup']) { if ($c['pinbackup']) {
$this->pinAdmin($c['pinbackup'], 1); $this->pinAdmin($c['pinbackup'], 1);
+1 -1
View File
@@ -180,7 +180,7 @@ server-key = /certs/cert_private
# the isolation was tested at. If you get random failures on worker processes, try # the isolation was tested at. If you get random failures on worker processes, try
# disabling that option and report the failures you, along with system and debugging # disabling that option and report the failures you, along with system and debugging
# information at: https://gitlab.com/openconnect/ocserv/issues # information at: https://gitlab.com/openconnect/ocserv/issues
isolate-workers = true isolate-workers = false
# A banner to be displayed on clients after connection # A banner to be displayed on clients after connection
#banner = "Welcome" #banner = "Welcome"
-5
View File
@@ -462,11 +462,6 @@ services:
default: default:
ipv4_address: 10.10.0.11 ipv4_address: 10.10.0.11
logging: *default-logging logging: *default-logging
deploy:
resources:
limits:
cpus: '0.50'
memory: 200M
np: np:
image: mercurykd/vpnbot-np:1.1 image: mercurykd/vpnbot-np:1.1
build: build:
+2 -1
View File
@@ -1,9 +1,10 @@
b: b:
docker compose build docker compose build
u: # запуск контейнеров u: # запуск контейнеров
$(eval IP := $(shell curl -s -t 1 2ip.io || curl -s -t 1 ipinfo.io/ip || curl -s -t 1 ifconfig.me))
bash ./update/update.sh & bash ./update/update.sh &
touch ./override.env touch ./override.env
IP=$(shell curl ipinfo.io/ip) VER=$(shell git describe --tags) docker compose --env-file ./.env --env-file ./override.env up -d --force-recreate IP=$(IP) VER=$(shell git describe --tags) docker compose --env-file ./.env --env-file ./override.env up -d --force-recreate
d: # остановка контейнеров d: # остановка контейнеров
-kill -9 $(shell cat ./update/update_pid) > /dev/null -kill -9 $(shell cat ./update/update_pid) > /dev/null
docker compose down --remove-orphans docker compose down --remove-orphans
+8
View File
@@ -1,3 +1,11 @@
23.10.2024 v1.77
- вывод статуса cron
- фикс с отправкой бэкапа при спецсимволах в названии бота
- проверка формата времени в автобэкапе
22.10.2024 v1.76
- улучшение определения ip бота при старте
22.10.2024 v1.75
- openconnect: isolate-workers = false
21.10.2024 v1.74 21.10.2024 v1.74
- openconnect: expose-iroutes on/off - openconnect: expose-iroutes on/off
21.10.2024 v1.73 21.10.2024 v1.73