peer-to-peer exchange lock button
This commit is contained in:
@@ -13,3 +13,4 @@
|
||||
/todo.todo
|
||||
/app/zapretlists/*
|
||||
!/app/zapretlists/.gitkeep
|
||||
.vscode/sftp.json
|
||||
|
||||
+35
-13
@@ -221,6 +221,9 @@ class Bot
|
||||
case preg_match('~^/switchTorrent (\d+)$~', $this->input['callback'], $m):
|
||||
$this->switchTorrent($m[1]);
|
||||
break;
|
||||
case preg_match('~^/switchExchange (\d+)$~', $this->input['callback'], $m):
|
||||
$this->switchExchange($m[1]);
|
||||
break;
|
||||
case preg_match('~^/blinkmenuswitch$~', $this->input['callback'], $m):
|
||||
$this->blinkmenuswitch();
|
||||
break;
|
||||
@@ -938,6 +941,18 @@ class Bot
|
||||
}
|
||||
$this->menu('wg', $page);
|
||||
}
|
||||
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->menu('wg', $page);
|
||||
}
|
||||
|
||||
public function blinkmenuswitch()
|
||||
{
|
||||
@@ -1765,22 +1780,17 @@ DNS-over-HTTPS with IP:
|
||||
$status = $this->readStatus();
|
||||
$clients = $this->getClients($page);
|
||||
$bt = $this->getPacConf()['blocktorrent'];
|
||||
$ex = $this->getPacConf()['exchange'];
|
||||
$dns = $this->getPacConf()['dns'];
|
||||
$data = [
|
||||
[
|
||||
[
|
||||
'text' => $this->i18n('update status'),
|
||||
'callback_data' => "/menu wg $page",
|
||||
],
|
||||
[
|
||||
'text' => $this->i18n(($bt ? 'block' : 'unblock') . 'torrent'),
|
||||
'text' => "{$this->i18n('torrent')} " . $this->i18n(!$bt ? 'on' : 'off'),
|
||||
'callback_data' => "/switchTorrent $page",
|
||||
],
|
||||
],
|
||||
[
|
||||
[
|
||||
'text' => $this->i18n('add peer'),
|
||||
'callback_data' => "/menu addpeer $page",
|
||||
'text' => "{$this->i18n('exchange')} " . $this->i18n(!$ex ? 'on' : 'off'),
|
||||
'callback_data' => "/switchExchange $page",
|
||||
],
|
||||
[
|
||||
'text' => $this->i18n('listSubnet'),
|
||||
@@ -1793,6 +1803,12 @@ DNS-over-HTTPS with IP:
|
||||
'callback_data' => "/defaultDNS $page",
|
||||
],
|
||||
],
|
||||
[
|
||||
[
|
||||
'text' => $this->i18n('add peer'),
|
||||
'callback_data' => "/menu addpeer $page",
|
||||
],
|
||||
],
|
||||
];
|
||||
if ($clients) {
|
||||
$data = array_merge($data, $clients);
|
||||
@@ -1841,10 +1857,16 @@ DNS-over-HTTPS with IP:
|
||||
}
|
||||
}
|
||||
$text = "Menu -> Wireguard\n\n<code>" . implode(PHP_EOL, $text ?: []) . '</code>';
|
||||
$data[] = [[
|
||||
'text' => $this->i18n('back'),
|
||||
'callback_data' => "/menu",
|
||||
]];
|
||||
$data[] = [
|
||||
[
|
||||
'text' => $this->i18n('update status'),
|
||||
'callback_data' => "/menu wg $page",
|
||||
],
|
||||
[
|
||||
'text' => $this->i18n('back'),
|
||||
'callback_data' => "/menu",
|
||||
]
|
||||
];
|
||||
return [
|
||||
'text' => $text,
|
||||
'data' => $data,
|
||||
|
||||
+11
-11
@@ -186,20 +186,16 @@ $i = [
|
||||
'ru' => 'удалить внутренний dns',
|
||||
],
|
||||
'on' => [
|
||||
'en' => 'on',
|
||||
'ru' => 'вкл',
|
||||
'en' => '🟢',
|
||||
'ru' => '🟢',
|
||||
],
|
||||
'off' => [
|
||||
'en' => 'off',
|
||||
'ru' => 'выкл',
|
||||
'en' => '🔴',
|
||||
'ru' => '🔴',
|
||||
],
|
||||
'blocktorrent' => [
|
||||
'en' => 'torrent off',
|
||||
'ru' => 'торренты выкл',
|
||||
],
|
||||
'unblocktorrent' => [
|
||||
'en' => 'torrent on',
|
||||
'ru' => 'торренты вкл',
|
||||
'torrent' => [
|
||||
'en' => 'torrents',
|
||||
'ru' => 'торренты',
|
||||
],
|
||||
'blinkmenuon' => [
|
||||
'en' => 'blinkmenu on',
|
||||
@@ -269,4 +265,8 @@ $i = [
|
||||
'en' => 'pagination',
|
||||
'ru' => 'пагинация',
|
||||
],
|
||||
'exchange' => [
|
||||
'en' => 'open ip',
|
||||
'ru' => 'откр айпи',
|
||||
],
|
||||
];
|
||||
|
||||
@@ -152,10 +152,13 @@ services:
|
||||
volumes:
|
||||
- ./config/.profile:/root/.ashrc:ro
|
||||
- ./config/wg0.conf:/etc/wireguard/wg0.conf
|
||||
- ./config/pac.json:/pac.json
|
||||
- ./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
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from alpine:3.18.2
|
||||
run apk add iproute2 linux-headers iptables xtables-addons wireguard-tools openssh \
|
||||
run apk add iproute2 linux-headers iptables xtables-addons wireguard-tools openssh jq \
|
||||
&& mkdir /root/.ssh
|
||||
env ENV="/root/.ashrc"
|
||||
env ENV="/root/.ashrc"
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
iptables -I FORWARD -i %i -o %i -j REJECT
|
||||
@@ -15,4 +15,12 @@ wg-quick up wg0
|
||||
cat /ssh/key.pub > /root/.ssh/authorized_keys
|
||||
ssh-keygen -A
|
||||
exec /usr/sbin/sshd -D -e "$@" &
|
||||
if [ $(cat /pac.json | jq .blocktorrent) -eq 1 ]
|
||||
then
|
||||
sh /block_torrent.sh
|
||||
fi
|
||||
if [ $(cat /pac.json | jq .exchange) -eq 1 ]
|
||||
then
|
||||
sh /block_exchange.sh
|
||||
fi
|
||||
tail -f /dev/null
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
iptables -D FORWARD -i %i -o %i -j REJECT
|
||||
Reference in New Issue
Block a user