diff --git a/app/bot.php b/app/bot.php index ca065be..702567e 100644 --- a/app/bot.php +++ b/app/bot.php @@ -1045,6 +1045,7 @@ class Bot $this->update($this->input['chat'], $this->input['message_id'], implode("\n", $out)); $this->saveClients($json['wg']['clients']); $this->restartWG($this->createConfig($json['wg']['server']), $switch_amnezia); + $this->iptablesWG(); } // ad if (!empty($json['ad'])) { @@ -1235,29 +1236,33 @@ class Bot $this->menu('wg', $page); } - public function switchTorrent($page) + public function switchTorrent($page = 0, $restart = false) { $c = $this->getPacConf(); $c['blocktorrent'] = $c['blocktorrent'] ? 0 : 1; $this->setPacConf($c); - if ($c['blocktorrent']) { - $this->ssh('bash /block_torrent.sh'); - } else { - $this->ssh('bash /unblock_torrent.sh'); - } + $this->iptablesWG(); $this->answer($this->input['callback_id'], 'доступ к торрентам ' . ($c['blocktorrent'] ? 'заблокирован' : 'разблокирован'), true); $this->menu('wg', $page); } + + public function iptablesWG() + { + $c = $this->getPacConf(); + $this->ssh('iptables -F'); + if ($c['exchange']) { + $this->ssh('bash /block_exchange.sh'); + } + if ($c['blocktorrent']) { + $this->ssh('bash /block_torrent.sh'); + } + } public function switchExchange($page) { $c = $this->getPacConf(); $c['exchange'] = $c['exchange'] ? 0 : 1; $this->setPacConf($c); - if ($c['exchange']) { - $this->ssh('bash /block_exchange.sh'); - } else { - $this->ssh('bash /unblock_exchange.sh'); - } + $this->iptablesWG(); $this->answer($this->input['callback_id'], 'обмен между пользователями ' . ($c['exchange'] ? 'заблокирован' : 'разблокирован'), true); $this->menu('wg', $page); } diff --git a/docker-compose.yml b/docker-compose.yml index 0473b91..ff19579 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -164,9 +164,7 @@ services: - ./scripts/start_wg.sh:/start_wg.sh - ./scripts/reset_wg.sh:/reset_wg.sh - ./scripts/block_torrent.sh:/block_torrent.sh - - ./scripts/unblock_torrent.sh:/unblock_torrent.sh - ./scripts/block_exchange.sh:/block_exchange.sh - - ./scripts/unblock_exchange.sh:/unblock_exchange.sh - ./ssh:/ssh - ./config/sshd_config:/etc/ssh/sshd_config hostname: wireguard @@ -180,6 +178,7 @@ services: TZ: ${TZ} WGPORT: ${WGPORT} ADDRESS: ${WGADDRESS} + ENV: /root/.ashrc cap_add: - NET_ADMIN devices: diff --git a/makefile b/makefile index 30b8301..f06756c 100644 --- a/makefile +++ b/makefile @@ -6,7 +6,7 @@ d: # остановка контейнеров docker compose down dv: # остановка контейнеров docker compose down -v -r: cleanf d u cleanf +r: d cleanf u cleanf ps: # список контейнеров docker compose ps l: # логи из контейнеров @@ -25,12 +25,14 @@ up: # консоль сервиса docker compose exec up /bin/sh ad: # консоль сервиса docker compose exec ad /bin/sh +wp: # консоль сервиса + docker compose exec wp bash proxy: # консоль сервиса docker compose exec proxy /bin/sh tg: # консоль сервиса docker compose exec tg /bin/sh xr: # консоль сервиса - docker compose exec xr /bin/shec tg /bin/sh + docker compose exec xr /bin/sh oc: # консоль сервиса docker compose exec oc /bin/sh clean: @@ -51,3 +53,5 @@ cn: docker compose exec ng nginx -t push: docker compose push +s: + git status -su