Compare commits

...

2 Commits

Author SHA1 Message Date
mercury e0ee25127f update version 2024-02-28 15:22:16 +04:00
mercury ae2e9c0205 mirror 2024-02-28 14:53:11 +04:00
13 changed files with 162 additions and 15 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
+77 -1
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;
@@ -2936,6 +2939,12 @@ DNS-over-HTTPS with IP:
'callback_data' => "/menu pac",
],
],
[
[
'text' => $this->i18n('mirror'),
'callback_data' => "/menu mirror",
],
],
[
[
'text' => $this->i18n('config'),
@@ -2968,6 +2977,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 +3044,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;
}
}
}
+13
View File
@@ -32,6 +32,7 @@ services:
ports:
- 443:443
hostname: upstream
container_name: upstream-${VER}
depends_on:
php:
condition: service_healthy
@@ -66,6 +67,7 @@ services:
ports:
- 80:80
hostname: nginx
container_name: nginx-${VER}
depends_on:
up:
condition: service_started
@@ -94,6 +96,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 +106,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"]
@@ -129,6 +134,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
@@ -159,6 +165,7 @@ services:
- ./ssh:/ssh
- ./config/sshd_config:/etc/ssh/sshd_config
hostname: wireguard
container_name: wireguard-${VER}
depends_on:
php:
condition: service_healthy
@@ -197,6 +204,7 @@ services:
- ./logs/:/logs/
- ./scripts/start_ad.sh:/start_ad.sh
hostname: adguard
container_name: adguard-${VER}
depends_on:
php:
condition: service_healthy
@@ -222,6 +230,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
@@ -247,6 +256,7 @@ services:
- ./scripts/start_tg.sh:/start_tg.sh
- ./config/mtprotosecret:/mtprotosecret
hostname: telegram
container_name: mtproto-${VER}
depends_on:
php:
condition: service_healthy
@@ -274,6 +284,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
@@ -298,6 +309,7 @@ services:
- ./certs:/certs
- ./scripts/start_oc.sh:/start_oc.sh
hostname: ocserv
container_name: openconnect-${VER}
depends_on:
php:
condition: service_healthy
@@ -327,6 +339,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 \
+1 -1
View File
@@ -1,7 +1,7 @@
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 --build --force-recreate
d: # остановка контейнеров
docker compose down
dv: # остановка контейнеров
+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
+2
View File
@@ -1,3 +1,5 @@
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