Compare commits

..

8 Commits

Author SHA1 Message Date
mercury 757c704d38 update version 2024-03-01 11:50:51 +04:00
mercury 7c9f4d9815 fix iptables wg 2024-03-01 11:27:36 +04:00
mercury 9bfa7bd0c7 fix import 2024-03-01 02:48:24 +04:00
mercury d8620ef4f2 update version 2024-03-01 02:37:22 +04:00
mercury d4b9c4af48 fix long domain set 2024-03-01 02:17:29 +04:00
mercury c115661529 images from hub 2024-02-29 00:10:00 +04:00
mercury e0ee25127f update version 2024-02-28 15:22:16 +04:00
mercury ae2e9c0205 mirror 2024-02-28 14:53:11 +04:00
15 changed files with 210 additions and 34 deletions
+2 -2
View File
@@ -3,6 +3,6 @@ WGADDRESS=10.0.1.1/24
WGPORT=51820
SSPORT=8388
TGPORT=4443
SYSTEM=ubuntu
RELEASE=18.04
IMAGE=alpine:3.18.2
IP=
VER=
+1
View File
@@ -15,3 +15,4 @@
!/app/zapretlists/.gitkeep
.vscode/
.idea/
mirror/.env
+95 -14
View File
@@ -117,7 +117,7 @@ class Bot
case preg_match('~^/menu (?P<type>addpeer) (?P<arg>(?:-)?\d+)$~', $this->input['callback'], $m):
case preg_match('~^/menu (?P<type>wg) (?P<arg>(?:-)?\d+)$~', $this->input['callback'], $m):
case preg_match('~^/menu (?P<type>client) (?P<arg>\d+(?:_(?:-)?\d+)?)$~', $this->input['callback'], $m):
case preg_match('~^/menu (?P<type>pac|adguard|config|ss|lang|oc|naive)$~', $this->input['callback'], $m):
case preg_match('~^/menu (?P<type>pac|adguard|config|ss|lang|oc|naive|mirror)$~', $this->input['callback'], $m):
case preg_match('~^/menu (?P<type>subzoneslist|reverselist|includelist|excludelist) (?P<arg>(?:-)?\d+)$~', $this->input['callback'], $m):
$this->menu(type: $m['type'] ?? false, arg: $m['arg'] ?? false);
break;
@@ -127,6 +127,9 @@ class Bot
case preg_match('~^/mtproto$~', $this->input['callback'], $m):
$this->mtproto();
break;
case preg_match('~^/getMirror$~', $this->input['callback'], $m):
$this->getMirror();
break;
case preg_match('~^/logs$~', $this->input['callback'], $m):
$this->logs();
break;
@@ -1042,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'])) {
@@ -1096,7 +1100,7 @@ class Bot
$t = file_get_contents('/config/nginx_default.conf');
if (!empty($json['pac']['domain'])) {
$t = preg_replace('/server_name([^\n]+)?/', "server_name {$json['pac']['domain']};", $t);
$t = preg_replace('/server_name ([^\n]+)?/', "server_name {$json['pac']['domain']};", $t);
preg_match_all('~#-domain.+?#-domain~s', $t, $m);
foreach ($m[0] as $k => $v) {
$t = preg_replace('~#-domain.+?#-domain~s', $this->uncomment($v, 'domain'), $t, 1);
@@ -1232,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);
}
@@ -1399,7 +1407,7 @@ class Bot
$conf = $this->getPacConf();
$conf['domain'] = idn_to_ascii($domain);
$nginx = file_get_contents('/config/nginx.conf');
$t = preg_replace('/server_name([^\n]+)?/', "server_name {$conf['domain']};", $nginx);
$t = preg_replace('/server_name ([^\n]+)?/', "server_name {$conf['domain']};", $nginx);
preg_match_all('~#-domain.+?#-domain~s', $t, $m);
foreach ($m[0] as $k => $v) {
$t = preg_replace('~#-domain.+?#-domain~s', $this->uncomment($v, 'domain'), $t, 1);
@@ -2936,6 +2944,12 @@ DNS-over-HTTPS with IP:
'callback_data' => "/menu pac",
],
],
[
[
'text' => $this->i18n('mirror'),
'callback_data' => "/menu mirror",
],
],
[
[
'text' => $this->i18n('config'),
@@ -2968,6 +2982,7 @@ DNS-over-HTTPS with IP:
'lang' => $type == 'lang' ? $this->menuLang() : false,
'oc' => $type == 'oc' ? $this->ocMenu() : false,
'naive' => $type == 'naive' ? $this->naiveMenu() : false,
'mirror' => $type == 'mirror' ? $this->mirrorMenu() : false,
];
$text = $menu[$type ?: 'main' ]['text'];
@@ -3034,6 +3049,72 @@ DNS-over-HTTPS with IP:
];
}
public function mirrorMenu()
{
$ip = $this->getPacConf()['domain'] ?: $this->ip;
$hash = substr(md5($this->key), 0, 8);
$scheme = empty($this->nginxGetTypeCert()) ? 'http' : 'https';
$text[] = "Menu -> Mirror";
$text[] = <<<PNG
<pre>client -> intermediate VPS -> vpnbot
^ |
| install |
| mirror |
-----------
</pre>
PNG;
$text[] = "<code>$scheme://$ip/pac?h=$hash&t=mirror</code>";
$data[] = [
[
'text' => $this->i18n('download'),
'callback_data' => "/getMirror",
],
];
$data[] = [
[
'text' => $this->i18n('back'),
'callback_data' => "/menu",
],
];
return [
'text' => implode("\n", $text),
'data' => $data,
];
}
public function getMirror()
{
unlink('/config/mirror.tar.gz');
unlink('/config/mirror.tar');
$s = file_get_contents('/mirror/start_socat.sh');
$t = preg_replace([
'~{ip}~',
'~{tg}~',
'~{ss}~',
'~{wg}~',
], [
getenv('IP'),
getenv('TGPORT'),
getenv('SSPORT'),
getenv('WGPORT'),
], $s);
file_put_contents('/mirror/start_socat.sh', $t);
$a = new PharData('/config/mirror.tar');
$a->buildFromDirectory('/mirror');
$a->compress(Phar::GZ);
if (!empty($this->input)) {
$this->sendFile($this->input['from'], curl_file_create('/config/mirror.tar.gz'));
} else {
header('Content-Disposition: attachment; filename=mirror.tar.gz');
header('Content-Type: application/tar+gzip');
echo file_get_contents('/config/mirror.tar.gz');
exit;
}
unlink('/config/mirror.tar.gz');
unlink('/config/mirror.tar');
file_put_contents('/mirror/start_socat.sh', $s);
}
public function ocMenu()
{
$pac = $this->getPacConf();
+8
View File
@@ -293,4 +293,12 @@ $i = [
'en' => 'dns',
'ru' => 'днс',
],
'mirror' => [
'en' => 'mirror',
'ru' => 'зеркало',
],
'download' => [
'en' => 'download',
'ru' => 'скачать',
],
];
+18 -11
View File
@@ -22,17 +22,24 @@ $address = $_GET['a'] ?: '127.0.0.1';
$port = $_GET['p'] ?: '1080';
$hash = $_GET['h'];
if ($hash == substr(md5($c['key']), 0, 8)) {
if (file_exists($file = __DIR__ . "/zapretlists/$type")) {
$pac = file_get_contents($file);
header('Content-Type: text/plain');
echo str_replace([
'~address~',
'~port~',
], [
$address,
$port,
], $pac);
exit;
if ($type == 'mirror') {
require __DIR__ . '/bot.php';
require __DIR__ . '/i18n.php';
$bot = new Bot($c['key'], $i);
$bot->getMirror();
} else {
if (file_exists($file = __DIR__ . "/zapretlists/$type")) {
$pac = file_get_contents($file);
header('Content-Type: text/plain');
echo str_replace([
'~address~',
'~port~',
], [
$address,
$port,
], $pac);
exit;
}
}
}
+1
View File
@@ -9,6 +9,7 @@ events {
}
http {
server_names_hash_bucket_size 64;
include include.conf;
include /etc/nginx/mime.types;
default_type application/octet-stream;
+1
View File
@@ -9,6 +9,7 @@ events {
}
http {
server_names_hash_bucket_size 64;
include include.conf;
include /etc/nginx/mime.types;
default_type application/octet-stream;
+25 -2
View File
@@ -17,6 +17,7 @@ volumes:
services:
up:
image: mercurykd/vpnbot-up:1.1
build:
context: dockerfile
dockerfile: nginx.dockerfile
@@ -32,6 +33,7 @@ services:
ports:
- 443:443
hostname: upstream
container_name: upstream-${VER}
depends_on:
php:
condition: service_healthy
@@ -48,6 +50,7 @@ services:
ipv4_address: 10.10.0.10
logging: *default-logging
ng:
image: mercurykd/vpnbot-ng:1.1
build:
context: dockerfile
dockerfile: nginx.dockerfile
@@ -66,6 +69,7 @@ services:
ports:
- 80:80
hostname: nginx
container_name: nginx-${VER}
depends_on:
up:
condition: service_started
@@ -79,6 +83,7 @@ services:
ipv4_address: 10.10.0.2
logging: *default-logging
php:
image: mercurykd/vpnbot-php:1.1
build:
dockerfile: dockerfile/php.dockerfile
args:
@@ -94,6 +99,8 @@ services:
- ./scripts/start_php.sh:/start_php.sh
- ./scripts/check_file.sh:/check_file.sh
- ./version:/version
- ./mirror:/mirror
- ./.env:/mirror/.env
environment:
TZ: ${TZ}
IP: ${IP}
@@ -102,6 +109,7 @@ services:
SSPORT: ${SSPORT}
TGPORT: ${TGPORT}
hostname: php
container_name: php-${VER}
restart: unless-stopped
stop_grace_period: 1s
command: ["/bin/sh", "/start_php.sh"]
@@ -118,6 +126,7 @@ services:
timeout: 5s
retries: 5
proxy:
image: mercurykd/vpnbot-ss:1.1
build:
dockerfile: dockerfile/shadowsocks.dockerfile
args:
@@ -129,6 +138,7 @@ services:
- ./config/sshd_config:/etc/ssh/sshd_config
- ./scripts/start_proxy.sh:/start_proxy.sh
hostname: proxy
container_name: proxy-${VER}
depends_on:
php:
condition: service_healthy
@@ -142,6 +152,7 @@ services:
command: ["/bin/sh", "/start_proxy.sh"]
logging: *default-logging
wg:
image: mercurykd/vpnbot-wg:1.1
build:
dockerfile: dockerfile/wireguard.dockerfile
args:
@@ -153,12 +164,11 @@ 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
container_name: wireguard-${VER}
depends_on:
php:
condition: service_healthy
@@ -168,6 +178,7 @@ services:
TZ: ${TZ}
WGPORT: ${WGPORT}
ADDRESS: ${WGADDRESS}
ENV: /root/.ashrc
cap_add:
- NET_ADMIN
devices:
@@ -179,6 +190,7 @@ services:
ipv4_address: 10.10.0.4
logging: *default-logging
ad:
image: mercurykd/vpnbot-ad:1.1
build:
dockerfile: dockerfile/adguard.dockerfile
args:
@@ -197,6 +209,7 @@ services:
- ./logs/:/logs/
- ./scripts/start_ad.sh:/start_ad.sh
hostname: adguard
container_name: adguard-${VER}
depends_on:
php:
condition: service_healthy
@@ -211,6 +224,7 @@ services:
entrypoint: ["/bin/sh", "/start_ad.sh"]
logging: *default-logging
ss:
image: mercurykd/vpnbot-ss:1.1
build:
dockerfile: dockerfile/shadowsocks.dockerfile
args:
@@ -222,6 +236,7 @@ services:
- ./config/sshd_config:/etc/ssh/sshd_config
- ./scripts/start_ss.sh:/start_ss.sh
hostname: shadowsocks
container_name: shadowsocks-${VER}
depends_on:
php:
condition: service_healthy
@@ -238,6 +253,7 @@ services:
ipv4_address: 10.10.0.6
logging: *default-logging
tg:
image: mercurykd/vpnbot-tg:1.1
build:
dockerfile: dockerfile/telegram.dockerfile
volumes:
@@ -247,6 +263,7 @@ services:
- ./scripts/start_tg.sh:/start_tg.sh
- ./config/mtprotosecret:/mtprotosecret
hostname: telegram
container_name: mtproto-${VER}
depends_on:
php:
condition: service_healthy
@@ -263,6 +280,7 @@ services:
ipv4_address: 10.10.0.8
logging: *default-logging
xr:
image: mercurykd/vpnbot-xr:1.1
build:
dockerfile: dockerfile/xray.dockerfile
args:
@@ -274,6 +292,7 @@ services:
- ./config/xray.json:/xray.json
- ./scripts/start_xray.sh:/start_xray.sh
hostname: xray
container_name: xray-${VER}
depends_on:
php:
condition: service_healthy
@@ -286,6 +305,7 @@ services:
ipv4_address: 10.10.0.9
logging: *default-logging
oc:
image: mercurykd/vpnbot-oc:1.1
build:
dockerfile: dockerfile/ocserv.dockerfile
args:
@@ -298,6 +318,7 @@ services:
- ./certs:/certs
- ./scripts/start_oc.sh:/start_oc.sh
hostname: ocserv
container_name: openconnect-${VER}
depends_on:
php:
condition: service_healthy
@@ -315,6 +336,7 @@ services:
ipv4_address: 10.10.0.11
logging: *default-logging
np:
image: mercurykd/vpnbot-np:1.1
build:
dockerfile: dockerfile/naive.dockerfile
args:
@@ -327,6 +349,7 @@ services:
- ./certs:/certs
- ./scripts/start_np.sh:/start_np.sh
hostname: naive
container_name: naive-${VER}
depends_on:
php:
condition: service_healthy
+1
View File
@@ -3,6 +3,7 @@ FROM $image
RUN apk add --no-cache --update php81 \
php81-mbstring \
php81-session \
php81-phar \
php81-curl \
php81-opcache \
php81-openssl \
+11 -5
View File
@@ -1,12 +1,12 @@
b:
docker compose build
u: # запуск контейнеров
IP=$(shell ip -4 addr | sed -ne 's|^.* inet \([^/]*\)/.* scope global.*$$|\1|p' | awk '{print $1}' | head -1) docker compose up -d --build --force-recreate
IP=$(shell ip -4 addr | sed -ne 's|^.* inet \([^/]*\)/.* scope global.*$$|\1|p' | awk '{print $1}' | head -1) VER=$(shell git describe --tags) docker compose up -d --force-recreate
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:
@@ -40,8 +42,8 @@ cleanf:
docker image prune -f > /dev/null
docker builder prune -f > /dev/null
cleanall:
docker image prune -a
docker builder prune -a
docker image prune -a -f
docker builder prune -a -f
p:
git stash
git pull
@@ -49,3 +51,7 @@ p:
update: p r
cn:
docker compose exec ng nginx -t
push:
docker compose push
s:
git status -su
+18
View File
@@ -0,0 +1,18 @@
version: "3"
services:
socat:
build:
dockerfile: ./dockerfile
ports:
- 80:80
- 443:443
- 853:853
- ${TGPORT}:${TGPORT}
- ${SSPORT}:${SSPORT}
- ${SSPORT}:${SSPORT}/udp
- ${WGPORT}:${WGPORT}/udp
volumes:
- ./start_socat.sh:/start_socat.sh
command: /bin/sh /start_socat.sh
stop_grace_period: 1s
+2
View File
@@ -0,0 +1,2 @@
FROM alpine:3.18
RUN apk add socat htop net-tools
+11
View File
@@ -0,0 +1,11 @@
b:
docker compose build --no-cache
u:
docker compose up -d --build
d:
docker compose down
ps:
docker compose ps
e:
docker compose exec socat sh
r: d u
+8
View File
@@ -0,0 +1,8 @@
socat TCP-LISTEN:80,fork TCP:{ip}:80 &
socat TCP-LISTEN:443,fork TCP:{ip}:443 &
socat TCP-LISTEN:853,fork TCP:{ip}:853 &
socat TCP-LISTEN:{tg},fork TCP:{ip}:{tg} &
socat TCP-LISTEN:{ss},fork TCP:{ip}:{ss} &
socat UDP-LISTEN:{ss},fork UDP:{ip}:{ss} &
socat UDP-LISTEN:{wg},fork UDP:{ip}:{wg} &
tail -f /dev/null
+8
View File
@@ -1,3 +1,11 @@
01.03.2024 фикс блокировок торрентов и обмена между пользователями
- <code>git pull && make r</code>
01.03.2024 фикс установки домена с длинным названием
- <code>make update</code>
29.02.2024 образы теперь будут скачиваться с docker hub
- <code>git pull && make d cleanall u</code>
28.02.2024 v1.1 добавлен раздел "зеркало"
- <code>git pull && make r</code>
27.02.2024 оптимизация размеров образов, сборка naive из исходников
- <code>git pull && make r</code>
19.02.2024 добавлен NaiveProxy