Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d005ccc919 | |||
| 5df89e7f89 | |||
| f6d72800cb | |||
| 4ff1929a22 | |||
| 46d54ffeee | |||
| 20cde272dd | |||
| 4270ee5b23 | |||
| cdcd6a7931 | |||
| f360091c1a | |||
| 3e52c3650e | |||
| 757c704d38 | |||
| 7c9f4d9815 | |||
| 9bfa7bd0c7 | |||
| d8620ef4f2 | |||
| d4b9c4af48 | |||
| c115661529 | |||
| e0ee25127f | |||
| ae2e9c0205 |
@@ -1,8 +1,10 @@
|
|||||||
TZ=Europe/Samara
|
TZ=Europe/Samara
|
||||||
WGADDRESS=10.0.1.1/24
|
WGADDRESS=10.0.1.1/24
|
||||||
WGPORT=51820
|
WGPORT=51820
|
||||||
|
WG1ADDRESS=10.0.3.1/24
|
||||||
|
WG1PORT=51821
|
||||||
SSPORT=8388
|
SSPORT=8388
|
||||||
TGPORT=4443
|
TGPORT=4443
|
||||||
SYSTEM=ubuntu
|
|
||||||
RELEASE=18.04
|
|
||||||
IMAGE=alpine:3.18.2
|
IMAGE=alpine:3.18.2
|
||||||
|
IP=
|
||||||
|
VER=
|
||||||
|
|||||||
@@ -15,3 +15,6 @@
|
|||||||
!/app/zapretlists/.gitkeep
|
!/app/zapretlists/.gitkeep
|
||||||
.vscode/
|
.vscode/
|
||||||
.idea/
|
.idea/
|
||||||
|
mirror/.env
|
||||||
|
update/*
|
||||||
|
!update/update.sh
|
||||||
|
|||||||
+273
-95
@@ -4,6 +4,7 @@ class Bot
|
|||||||
{
|
{
|
||||||
public $input;
|
public $input;
|
||||||
public $adguard;
|
public $adguard;
|
||||||
|
public $update;
|
||||||
|
|
||||||
public function __construct($key, $i18n)
|
public function __construct($key, $i18n)
|
||||||
{
|
{
|
||||||
@@ -11,6 +12,7 @@ class Bot
|
|||||||
$this->api = "https://api.telegram.org/bot$key/";
|
$this->api = "https://api.telegram.org/bot$key/";
|
||||||
$this->file = "https://api.telegram.org/file/bot$key/";
|
$this->file = "https://api.telegram.org/file/bot$key/";
|
||||||
$this->clients = '/config/clients.json';
|
$this->clients = '/config/clients.json';
|
||||||
|
$this->clients1 = '/config/clients1.json';
|
||||||
$this->pac = '/config/pac.json';
|
$this->pac = '/config/pac.json';
|
||||||
$this->ip = getenv('IP');
|
$this->ip = getenv('IP');
|
||||||
$this->i18n = $i18n;
|
$this->i18n = $i18n;
|
||||||
@@ -18,6 +20,7 @@ class Bot
|
|||||||
$this->dns = '1.1.1.1, 8.8.8.8';
|
$this->dns = '1.1.1.1, 8.8.8.8';
|
||||||
$this->limit = $this->getPacConf()['limitpage'] ?: 5;
|
$this->limit = $this->getPacConf()['limitpage'] ?: 5;
|
||||||
$this->adguard = '/config/AdGuardHome.yaml';
|
$this->adguard = '/config/AdGuardHome.yaml';
|
||||||
|
$this->update = '/update/json';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function input()
|
public function input()
|
||||||
@@ -117,16 +120,25 @@ class Bot
|
|||||||
case preg_match('~^/menu (?P<type>addpeer) (?P<arg>(?:-)?\d+)$~', $this->input['callback'], $m):
|
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>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>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):
|
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);
|
$this->menu(type: $m['type'] ?? false, arg: $m['arg'] ?? false);
|
||||||
break;
|
break;
|
||||||
|
case preg_match('~^/changeWG (\d+)$~', $this->input['callback'], $m):
|
||||||
|
$this->changeWG($m[1]);
|
||||||
|
break;
|
||||||
case preg_match('~^/id$~', $this->input['message'], $m):
|
case preg_match('~^/id$~', $this->input['message'], $m):
|
||||||
$this->send($this->input['chat'], $this->input['from'], $this->input['message_id']);
|
$this->send($this->input['chat'], $this->input['from'], $this->input['message_id']);
|
||||||
break;
|
break;
|
||||||
case preg_match('~^/mtproto$~', $this->input['callback'], $m):
|
case preg_match('~^/mtproto$~', $this->input['callback'], $m):
|
||||||
$this->mtproto();
|
$this->mtproto();
|
||||||
break;
|
break;
|
||||||
|
case preg_match('~^/updatebot$~', $this->input['callback'], $m):
|
||||||
|
$this->updatebot();
|
||||||
|
break;
|
||||||
|
case preg_match('~^/getMirror$~', $this->input['callback'], $m):
|
||||||
|
$this->getMirror();
|
||||||
|
break;
|
||||||
case preg_match('~^/logs$~', $this->input['callback'], $m):
|
case preg_match('~^/logs$~', $this->input['callback'], $m):
|
||||||
$this->logs();
|
$this->logs();
|
||||||
break;
|
break;
|
||||||
@@ -930,12 +942,15 @@ class Bot
|
|||||||
public function shutdownClient()
|
public function shutdownClient()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$clients = $this->readClients();
|
for ($i=0; $i < 2; $i++) {
|
||||||
if ($clients) {
|
$this->wg = $i;
|
||||||
foreach ($clients as $k => $v) {
|
$clients = $this->readClients();
|
||||||
if (!empty($v['interface']['## time'])) {
|
if ($clients) {
|
||||||
if (strtotime($v['interface']['## time']) < time()) {
|
foreach ($clients as $k => $v) {
|
||||||
$this->switchClient($k);
|
if (!empty($v['interface']['## time'])) {
|
||||||
|
if (strtotime($v['interface']['## time']) < time()) {
|
||||||
|
$this->switchClient($k);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -961,16 +976,24 @@ class Bot
|
|||||||
|
|
||||||
public function readClients(): array
|
public function readClients(): array
|
||||||
{
|
{
|
||||||
return json_decode(file_get_contents($this->clients), true) ?: [];
|
return json_decode(file_get_contents($this->getInstanceWG(1) ? $this->clients1 : $this->clients), true) ?: [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function export()
|
public function export()
|
||||||
{
|
{
|
||||||
|
$this->wg = 0;
|
||||||
|
$wg = [
|
||||||
|
'server' => $this->readConfig(),
|
||||||
|
'clients' => json_decode(file_get_contents($this->clients), true) ?: [],
|
||||||
|
];
|
||||||
|
$this->wg = 1;
|
||||||
|
$wg1 = [
|
||||||
|
'server' => $this->readConfig(),
|
||||||
|
'clients' => json_decode(file_get_contents($this->clients1), true) ?: [],
|
||||||
|
];
|
||||||
$conf = [
|
$conf = [
|
||||||
'wg' => [
|
'wg' => $wg,
|
||||||
'server' => $this->readConfig(),
|
'wg1' => $wg1,
|
||||||
'clients' => json_decode(file_get_contents($this->clients), true) ?: [],
|
|
||||||
],
|
|
||||||
'ss' => $this->getSSConfig(),
|
'ss' => $this->getSSConfig(),
|
||||||
'sl' => $this->getSSLocalConfig(),
|
'sl' => $this->getSSLocalConfig(),
|
||||||
'ad' => yaml_parse_file($this->adguard),
|
'ad' => yaml_parse_file($this->adguard),
|
||||||
@@ -987,10 +1010,14 @@ class Bot
|
|||||||
return json_encode($conf, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
return json_encode($conf, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function exportManual()
|
public function exportManual($file = false)
|
||||||
{
|
{
|
||||||
|
$json = $this->export();
|
||||||
|
if (!empty($file)) {
|
||||||
|
file_put_contents($file, $json);
|
||||||
|
}
|
||||||
$bot = $this->request('getMyName', [])['result']['name'];
|
$bot = $this->request('getMyName', [])['result']['name'];
|
||||||
return $this->upload("{$bot}_export_" . date('d_m_Y_H_i') . '.json', $this->export());
|
return $this->upload("{$bot}_export_" . date('d_m_Y_H_i') . '.json', $json);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function import()
|
public function import()
|
||||||
@@ -1009,10 +1036,14 @@ class Bot
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function importFile()
|
public function importFile($file = false)
|
||||||
{
|
{
|
||||||
$r = $this->request('getFile', ['file_id' => $this->input['file_id']]);
|
if (!empty($file)) {
|
||||||
$json = json_decode(file_get_contents($this->file . $r['result']['file_path']), true);
|
$json = json_decode(file_get_contents($file), true);
|
||||||
|
} else {
|
||||||
|
$r = $this->request('getFile', ['file_id' => $this->input['file_id']]);
|
||||||
|
$json = json_decode(file_get_contents($this->file . $r['result']['file_path']), true);
|
||||||
|
}
|
||||||
if (empty($json) || !is_array($json)) {
|
if (empty($json) || !is_array($json)) {
|
||||||
$this->answer($this->input['callback_id'], 'error', true);
|
$this->answer($this->input['callback_id'], 'error', true);
|
||||||
} else {
|
} else {
|
||||||
@@ -1040,8 +1071,19 @@ class Bot
|
|||||||
if (!empty($json['wg'])) {
|
if (!empty($json['wg'])) {
|
||||||
$out[] = 'update wireguard';
|
$out[] = 'update wireguard';
|
||||||
$this->update($this->input['chat'], $this->input['message_id'], implode("\n", $out));
|
$this->update($this->input['chat'], $this->input['message_id'], implode("\n", $out));
|
||||||
|
$this->wg = 0;
|
||||||
$this->saveClients($json['wg']['clients']);
|
$this->saveClients($json['wg']['clients']);
|
||||||
$this->restartWG($this->createConfig($json['wg']['server']), $switch_amnezia);
|
$this->restartWG($this->createConfig($json['wg']['server']), $switch_amnezia);
|
||||||
|
$this->iptablesWG();
|
||||||
|
}
|
||||||
|
// wg1
|
||||||
|
if (!empty($json['wg1'])) {
|
||||||
|
$out[] = 'update wireguard 1';
|
||||||
|
$this->update($this->input['chat'], $this->input['message_id'], implode("\n", $out));
|
||||||
|
$this->wg = 1;
|
||||||
|
$this->saveClients($json['wg1']['clients']);
|
||||||
|
$this->restartWG($this->createConfig($json['wg1']['server']), $switch_amnezia);
|
||||||
|
$this->iptablesWG();
|
||||||
}
|
}
|
||||||
// ad
|
// ad
|
||||||
if (!empty($json['ad'])) {
|
if (!empty($json['ad'])) {
|
||||||
@@ -1096,7 +1138,7 @@ class Bot
|
|||||||
|
|
||||||
$t = file_get_contents('/config/nginx_default.conf');
|
$t = file_get_contents('/config/nginx_default.conf');
|
||||||
if (!empty($json['pac']['domain'])) {
|
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);
|
preg_match_all('~#-domain.+?#-domain~s', $t, $m);
|
||||||
foreach ($m[0] as $k => $v) {
|
foreach ($m[0] as $k => $v) {
|
||||||
$t = preg_replace('~#-domain.+?#-domain~s', $this->uncomment($v, 'domain'), $t, 1);
|
$t = preg_replace('~#-domain.+?#-domain~s', $this->uncomment($v, 'domain'), $t, 1);
|
||||||
@@ -1116,8 +1158,12 @@ class Bot
|
|||||||
|
|
||||||
$out[] = "end import";
|
$out[] = "end import";
|
||||||
$this->update($this->input['chat'], $this->input['message_id'], implode("\n", $out));
|
$this->update($this->input['chat'], $this->input['message_id'], implode("\n", $out));
|
||||||
|
$this->language = $this->getPacConf()['language'] ?: 'en';
|
||||||
|
$this->limit = $this->getPacConf()['limitpage'] ?: 5;
|
||||||
sleep(3);
|
sleep(3);
|
||||||
$this->menu();
|
if (empty($file)) {
|
||||||
|
$this->menu();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1165,14 +1211,14 @@ class Bot
|
|||||||
public function switchAmnezia($page = 0)
|
public function switchAmnezia($page = 0)
|
||||||
{
|
{
|
||||||
$c = $this->getPacConf();
|
$c = $this->getPacConf();
|
||||||
$c['amnezia'] = $c['amnezia'] ? 0 : 1;
|
$amnezia = $c[$this->getInstanceWG(1) . 'amnezia'] = $c[$this->getInstanceWG(1) . 'amnezia'] ? 0 : 1;
|
||||||
$this->setPacConf($c);
|
$this->setPacConf($c);
|
||||||
|
|
||||||
$pk = $this->presharedKey();
|
$pk = $this->presharedKey();
|
||||||
$ak = $this->amneziaKeys();
|
$ak = $this->amneziaKeys();
|
||||||
$clients = $this->readClients();
|
$clients = $this->readClients();
|
||||||
foreach ($clients as $k => $v) {
|
foreach ($clients as $k => $v) {
|
||||||
if (!empty($c['amnezia'])) {
|
if (!empty($amnezia)) {
|
||||||
$clients[$k]['peers'][0]['PresharedKey'] = $pk;
|
$clients[$k]['peers'][0]['PresharedKey'] = $pk;
|
||||||
$clients[$k]['interface']['Jc'] = $ak['Jc'];
|
$clients[$k]['interface']['Jc'] = $ak['Jc'];
|
||||||
$clients[$k]['interface']['Jmin'] = $ak['Jmin'];
|
$clients[$k]['interface']['Jmin'] = $ak['Jmin'];
|
||||||
@@ -1199,7 +1245,7 @@ class Bot
|
|||||||
$this->saveClients($clients);
|
$this->saveClients($clients);
|
||||||
|
|
||||||
$wg = $this->readConfig();
|
$wg = $this->readConfig();
|
||||||
if (!empty($c['amnezia'])) {
|
if (!empty($amnezia)) {
|
||||||
$wg['interface']['Jc'] = $ak['Jc'];
|
$wg['interface']['Jc'] = $ak['Jc'];
|
||||||
$wg['interface']['Jmin'] = $ak['Jmin'];
|
$wg['interface']['Jmin'] = $ak['Jmin'];
|
||||||
$wg['interface']['Jmax'] = $ak['Jmax'];
|
$wg['interface']['Jmax'] = $ak['Jmax'];
|
||||||
@@ -1222,7 +1268,7 @@ class Bot
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ($wg['peers'] as $k => $v) {
|
foreach ($wg['peers'] as $k => $v) {
|
||||||
if (!empty($c['amnezia'])) {
|
if (!empty($amnezia)) {
|
||||||
$wg['peers'][$k]['PresharedKey'] = $pk;
|
$wg['peers'][$k]['PresharedKey'] = $pk;
|
||||||
} else {
|
} else {
|
||||||
unset($wg['peers'][$k]['PresharedKey']);
|
unset($wg['peers'][$k]['PresharedKey']);
|
||||||
@@ -1232,30 +1278,34 @@ class Bot
|
|||||||
$this->menu('wg', $page);
|
$this->menu('wg', $page);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function switchTorrent($page)
|
public function switchTorrent($page = 0, $restart = false)
|
||||||
{
|
{
|
||||||
$c = $this->getPacConf();
|
$c = $this->getPacConf();
|
||||||
$c['blocktorrent'] = $c['blocktorrent'] ? 0 : 1;
|
$c[$this->getInstanceWG(1) . 'blocktorrent'] = $c[$this->getInstanceWG(1) . 'blocktorrent'] ? 0 : 1;
|
||||||
$this->setPacConf($c);
|
$this->setPacConf($c);
|
||||||
if ($c['blocktorrent']) {
|
$this->iptablesWG();
|
||||||
$this->ssh('bash /block_torrent.sh');
|
$this->answer($this->input['callback_id'], 'доступ к торрентам ' . ($c[$this->getInstanceWG(1) . 'blocktorrent'] ? 'заблокирован' : 'разблокирован'), true);
|
||||||
} else {
|
|
||||||
$this->ssh('bash /unblock_torrent.sh');
|
|
||||||
}
|
|
||||||
$this->answer($this->input['callback_id'], 'доступ к торрентам ' . ($c['blocktorrent'] ? 'заблокирован' : 'разблокирован'), true);
|
|
||||||
$this->menu('wg', $page);
|
$this->menu('wg', $page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function iptablesWG()
|
||||||
|
{
|
||||||
|
$c = $this->getPacConf();
|
||||||
|
$this->ssh('iptables -F', $this->getInstanceWG());
|
||||||
|
if ($c['exchange']) {
|
||||||
|
$this->ssh('bash /block_exchange.sh', $this->getInstanceWG());
|
||||||
|
}
|
||||||
|
if ($c['blocktorrent']) {
|
||||||
|
$this->ssh('bash /block_torrent.sh', $this->getInstanceWG());
|
||||||
|
}
|
||||||
|
}
|
||||||
public function switchExchange($page)
|
public function switchExchange($page)
|
||||||
{
|
{
|
||||||
$c = $this->getPacConf();
|
$c = $this->getPacConf();
|
||||||
$c['exchange'] = $c['exchange'] ? 0 : 1;
|
$c[$this->getInstanceWG(1) . 'exchange'] = $c[$this->getInstanceWG(1) . 'exchange'] ? 0 : 1;
|
||||||
$this->setPacConf($c);
|
$this->setPacConf($c);
|
||||||
if ($c['exchange']) {
|
$this->iptablesWG();
|
||||||
$this->ssh('bash /block_exchange.sh');
|
$this->answer($this->input['callback_id'], 'обмен между пользователями ' . ($c[$this->getInstanceWG(1) . 'exchange'] ? 'заблокирован' : 'разблокирован'), true);
|
||||||
} else {
|
|
||||||
$this->ssh('bash /unblock_exchange.sh');
|
|
||||||
}
|
|
||||||
$this->answer($this->input['callback_id'], 'обмен между пользователями ' . ($c['exchange'] ? 'заблокирован' : 'разблокирован'), true);
|
|
||||||
$this->menu('wg', $page);
|
$this->menu('wg', $page);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1399,7 +1449,7 @@ class Bot
|
|||||||
$conf = $this->getPacConf();
|
$conf = $this->getPacConf();
|
||||||
$conf['domain'] = idn_to_ascii($domain);
|
$conf['domain'] = idn_to_ascii($domain);
|
||||||
$nginx = file_get_contents('/config/nginx.conf');
|
$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);
|
preg_match_all('~#-domain.+?#-domain~s', $t, $m);
|
||||||
foreach ($m[0] as $k => $v) {
|
foreach ($m[0] as $k => $v) {
|
||||||
$t = preg_replace('~#-domain.+?#-domain~s', $this->uncomment($v, 'domain'), $t, 1);
|
$t = preg_replace('~#-domain.+?#-domain~s', $this->uncomment($v, 'domain'), $t, 1);
|
||||||
@@ -2115,15 +2165,22 @@ DNS-over-HTTPS with IP:
|
|||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getTitleWG()
|
||||||
|
{
|
||||||
|
$c = $this->getPacConf();
|
||||||
|
return $this->i18n($c[$this->getInstanceWG(1) . 'amnezia'] ? 'amnezia' : 'wg_title') . ' ' . $c['wg_instance'];
|
||||||
|
}
|
||||||
|
|
||||||
public function statusWg(int $page = 0)
|
public function statusWg(int $page = 0)
|
||||||
{
|
{
|
||||||
|
$c = $this->getPacConf();
|
||||||
$conf = $this->readConfig();
|
$conf = $this->readConfig();
|
||||||
$status = $this->readStatus();
|
$status = $this->readStatus();
|
||||||
$clients = $this->getClients($page);
|
$clients = $this->getClients($page);
|
||||||
$bt = $this->getPacConf()['blocktorrent'];
|
$bt = $c[$this->getInstanceWG(1) . 'blocktorrent'];
|
||||||
$ex = $this->getPacConf()['exchange'];
|
$ex = $c[$this->getInstanceWG(1) . 'exchange'];
|
||||||
$dns = $this->getPacConf()['dns'];
|
$dns = $c[$this->getInstanceWG(1) . 'dns'];
|
||||||
$am = $this->getPacConf()['amnezia'];
|
$am = $c[$this->getInstanceWG(1) . 'amnezia'];
|
||||||
$data = [
|
$data = [
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
@@ -2204,7 +2261,7 @@ DNS-over-HTTPS with IP:
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$text = "Menu -> Wireguard\n\n<code>" . implode(PHP_EOL, $text ?: []) . '</code>';
|
$text = "Menu -> " . $this->getTitleWG() . "\n\n<code>" . implode(PHP_EOL, $text ?: []) . '</code>';
|
||||||
$data[] = [
|
$data[] = [
|
||||||
[
|
[
|
||||||
'text' => $this->i18n('update status'),
|
'text' => $this->i18n('update status'),
|
||||||
@@ -2241,9 +2298,9 @@ DNS-over-HTTPS with IP:
|
|||||||
{
|
{
|
||||||
$c = $this->getPacConf();
|
$c = $this->getPacConf();
|
||||||
if ($text) {
|
if ($text) {
|
||||||
$c['dns'] = $text;
|
$c[$this->getInstanceWG(1) . 'dns'] = $text;
|
||||||
} else {
|
} else {
|
||||||
unset($c['dns']);
|
unset($c[$this->getInstanceWG(1) . 'dns']);
|
||||||
}
|
}
|
||||||
$this->setPacConf($c);
|
$this->setPacConf($c);
|
||||||
$this->menu('wg', $page);
|
$this->menu('wg', $page);
|
||||||
@@ -2483,7 +2540,7 @@ DNS-over-HTTPS with IP:
|
|||||||
$name = $this->getName($clients[$client]['interface']);
|
$name = $this->getName($clients[$client]['interface']);
|
||||||
$conf = $this->createConfig($clients[$client]);
|
$conf = $this->createConfig($clients[$client]);
|
||||||
return [
|
return [
|
||||||
'text' => "<code>$conf</code>\n\n<b>$name</b>",
|
'text' => "<code>$conf</code>\n\n<b>$name</b> ({$this->getTitleWG()})",
|
||||||
'data' => [
|
'data' => [
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
@@ -2890,30 +2947,28 @@ DNS-over-HTTPS with IP:
|
|||||||
return $this->i18n[$menu][$this->language] ?: $menu;
|
return $this->i18n[$menu][$this->language] ?: $menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function changeWG($i)
|
||||||
|
{
|
||||||
|
$c = $this->getPacConf();
|
||||||
|
$c['wg_instance'] = $i;
|
||||||
|
$this->setPacConf($c);
|
||||||
|
$this->menu('wg', 0);
|
||||||
|
}
|
||||||
|
|
||||||
public function menu($type = false, $arg = false, $return = false)
|
public function menu($type = false, $arg = false, $return = false)
|
||||||
{
|
{
|
||||||
$menu = [
|
$menu = [
|
||||||
'main' => [
|
'main' => [
|
||||||
'text' => $this->i18n('menu'),
|
'text' => 'v' . getenv('VER'),
|
||||||
'data' => [
|
'data' => [
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
'text' => $this->i18n($this->getPacConf()['amnezia'] ? 'amnezia' : 'wg_title'),
|
'text' => $this->i18n($this->getPacConf()['amnezia'] ? 'amnezia' : 'wg_title'),
|
||||||
'callback_data' => "/menu wg 0",
|
'callback_data' => "/changeWG 0",
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'text' => $this->i18n('ad_title'),
|
'text' => $this->i18n($this->getPacConf()['wg1_amnezia'] ? 'amnezia' : 'wg_title'),
|
||||||
'callback_data' => "/menu adguard",
|
'callback_data' => "/changeWG 1",
|
||||||
],
|
|
||||||
],
|
|
||||||
[
|
|
||||||
[
|
|
||||||
'text' => $this->i18n('sh_title'),
|
|
||||||
'callback_data' => "/menu ss",
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'text' => $this->i18n('ocserv'),
|
|
||||||
'callback_data' => "/menu oc",
|
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@@ -2921,6 +2976,16 @@ DNS-over-HTTPS with IP:
|
|||||||
'text' => $this->i18n('xray'),
|
'text' => $this->i18n('xray'),
|
||||||
'callback_data' => "/xray",
|
'callback_data' => "/xray",
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'text' => $this->i18n('naive'),
|
||||||
|
'callback_data' => "/menu naive",
|
||||||
|
],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[
|
||||||
|
'text' => $this->i18n('ocserv'),
|
||||||
|
'callback_data' => "/menu oc",
|
||||||
|
],
|
||||||
[
|
[
|
||||||
'text' => $this->i18n('mtproto'),
|
'text' => $this->i18n('mtproto'),
|
||||||
'callback_data' => "/mtproto",
|
'callback_data' => "/mtproto",
|
||||||
@@ -2928,8 +2993,18 @@ DNS-over-HTTPS with IP:
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
'text' => $this->i18n('naive'),
|
'text' => $this->i18n('sh_title'),
|
||||||
'callback_data' => "/menu naive",
|
'callback_data' => "/menu ss",
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'text' => $this->i18n('mirror'),
|
||||||
|
'callback_data' => "/menu mirror",
|
||||||
|
],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[
|
||||||
|
'text' => $this->i18n('ad_title'),
|
||||||
|
'callback_data' => "/menu adguard",
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'text' => $this->i18n('pac'),
|
'text' => $this->i18n('pac'),
|
||||||
@@ -2951,7 +3026,7 @@ DNS-over-HTTPS with IP:
|
|||||||
'text' => $this->i18n('donate'),
|
'text' => $this->i18n('donate'),
|
||||||
'url' => "https://yoomoney.ru/to/410011827900450",
|
'url' => "https://yoomoney.ru/to/410011827900450",
|
||||||
],
|
],
|
||||||
]
|
],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'wg' => $type == 'wg' ? $this->statusWg($arg) : false,
|
'wg' => $type == 'wg' ? $this->statusWg($arg) : false,
|
||||||
@@ -2968,6 +3043,7 @@ DNS-over-HTTPS with IP:
|
|||||||
'lang' => $type == 'lang' ? $this->menuLang() : false,
|
'lang' => $type == 'lang' ? $this->menuLang() : false,
|
||||||
'oc' => $type == 'oc' ? $this->ocMenu() : false,
|
'oc' => $type == 'oc' ? $this->ocMenu() : false,
|
||||||
'naive' => $type == 'naive' ? $this->naiveMenu() : false,
|
'naive' => $type == 'naive' ? $this->naiveMenu() : false,
|
||||||
|
'mirror' => $type == 'mirror' ? $this->mirrorMenu() : false,
|
||||||
];
|
];
|
||||||
|
|
||||||
$text = $menu[$type ?: 'main' ]['text'];
|
$text = $menu[$type ?: 'main' ]['text'];
|
||||||
@@ -3034,6 +3110,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()
|
public function ocMenu()
|
||||||
{
|
{
|
||||||
$pac = $this->getPacConf();
|
$pac = $this->getPacConf();
|
||||||
@@ -3212,7 +3354,7 @@ DNS-over-HTTPS with IP:
|
|||||||
|
|
||||||
public function addWg($page)
|
public function addWg($page)
|
||||||
{
|
{
|
||||||
$text = "Menu -> Wireguard -> Add peer\n\n";
|
$text = "Menu -> {$this->getTitleWG()} -> Add peer\n\n";
|
||||||
$data[] = [
|
$data[] = [
|
||||||
[
|
[
|
||||||
'text' => $this->i18n('all traffic'),
|
'text' => $this->i18n('all traffic'),
|
||||||
@@ -3353,6 +3495,15 @@ DNS-over-HTTPS with IP:
|
|||||||
return openssl_x509_parse($c)["validTo_time_t"] ?: false;
|
return openssl_x509_parse($c)["validTo_time_t"] ?: false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function updatebot()
|
||||||
|
{
|
||||||
|
$this->exportManual($this->update);
|
||||||
|
$r = $this->send($this->input['from'], 'update...');
|
||||||
|
file_put_contents('/update/reload_message', "{$this->input['from']}:{$r['result']['message_id']}");
|
||||||
|
file_put_contents('/update/pipe', '1');
|
||||||
|
$this->delete($this->input['from'], $this->input['message_id']);
|
||||||
|
}
|
||||||
|
|
||||||
public function configMenu()
|
public function configMenu()
|
||||||
{
|
{
|
||||||
$conf = $this->getPacConf();
|
$conf = $this->getPacConf();
|
||||||
@@ -3463,6 +3614,12 @@ DNS-over-HTTPS with IP:
|
|||||||
'callback_data' => "/debug",
|
'callback_data' => "/debug",
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
$data[] = [
|
||||||
|
[
|
||||||
|
'text' => $this->i18n('update bot'),
|
||||||
|
'callback_data' => "/updatebot",
|
||||||
|
],
|
||||||
|
];
|
||||||
$data[] = [
|
$data[] = [
|
||||||
[
|
[
|
||||||
'text' => $this->i18n('back'),
|
'text' => $this->i18n('back'),
|
||||||
@@ -3624,9 +3781,17 @@ DNS-over-HTTPS with IP:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getInstanceWG($k = false)
|
||||||
|
{
|
||||||
|
if (!empty($k)) {
|
||||||
|
return ($this->wg ?? $this->getPacConf()['wg_instance']) ? 'wg1_' : '';
|
||||||
|
}
|
||||||
|
return ($this->wg ?? $this->getPacConf()['wg_instance']) ? 'wg1' : 'wg';
|
||||||
|
}
|
||||||
|
|
||||||
public function readConfig()
|
public function readConfig()
|
||||||
{
|
{
|
||||||
$r = $this->ssh('cat /etc/wireguard/wg0.conf');
|
$r = $this->ssh('cat /etc/wireguard/wg0.conf', $this->getInstanceWG());
|
||||||
$r = explode(PHP_EOL, $r);
|
$r = explode(PHP_EOL, $r);
|
||||||
$r = array_filter($r);
|
$r = array_filter($r);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
@@ -3664,7 +3829,7 @@ DNS-over-HTTPS with IP:
|
|||||||
|
|
||||||
public function readStatus()
|
public function readStatus()
|
||||||
{
|
{
|
||||||
$r = $this->ssh($this->getWGType());
|
$r = $this->ssh($this->getWGType(), $this->getInstanceWG());
|
||||||
$r = explode(PHP_EOL, $r);
|
$r = explode(PHP_EOL, $r);
|
||||||
$r = array_filter($r);
|
$r = array_filter($r);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
@@ -3709,7 +3874,7 @@ DNS-over-HTTPS with IP:
|
|||||||
$conf[] = "[Interface]";
|
$conf[] = "[Interface]";
|
||||||
if (empty($data['interface']['ListenPort'])) {
|
if (empty($data['interface']['ListenPort'])) {
|
||||||
if (empty($data['interface']['DNS'])) {
|
if (empty($data['interface']['DNS'])) {
|
||||||
$data['interface']['DNS'] = $this->getPacConf()['dns'] ?: $this->dns;
|
$data['interface']['DNS'] = $this->getPacConf()[$this->getInstanceWG(1) . 'dns'] ?: $this->dns;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach ($data['interface'] as $k => $v) {
|
foreach ($data['interface'] as $k => $v) {
|
||||||
@@ -3721,7 +3886,7 @@ DNS-over-HTTPS with IP:
|
|||||||
$conf[] = '';
|
$conf[] = '';
|
||||||
$conf[] = $peer['# PublicKey'] ? '# [Peer]' : '[Peer]';
|
$conf[] = $peer['# PublicKey'] ? '# [Peer]' : '[Peer]';
|
||||||
if (!empty($peer['Endpoint'])) {
|
if (!empty($peer['Endpoint'])) {
|
||||||
$peer['Endpoint'] = ($pac['domain'] && !$pac['amnezia'] ? $pac['domain'] : $this->ip) . ":" . getenv('WGPORT');
|
$peer['Endpoint'] = ($pac['domain'] && !$pac[$this->getInstanceWG(1) . 'amnezia'] ? $pac['domain'] : $this->ip) . ":" . getenv($this->getInstanceWG(1) ? 'WG1PORT' : 'WGPORT');
|
||||||
}
|
}
|
||||||
foreach ($peer as $k => $v) {
|
foreach ($peer as $k => $v) {
|
||||||
$conf[] = "$k = $v";
|
$conf[] = "$k = $v";
|
||||||
@@ -3734,18 +3899,18 @@ DNS-over-HTTPS with IP:
|
|||||||
public function presharedKey()
|
public function presharedKey()
|
||||||
{
|
{
|
||||||
$c = $this->getPacConf();
|
$c = $this->getPacConf();
|
||||||
if (empty($c['presharedkey'])) {
|
if (empty($c[$this->getInstanceWG(1) . 'presharedkey'])) {
|
||||||
$c['presharedkey'] = trim($this->ssh("{$this->getWGType()} genpsk"));
|
$c[$this->getInstanceWG(1) . 'presharedkey'] = trim($this->ssh("{$this->getWGType()} genpsk", $this->getInstanceWG()));
|
||||||
$this->setPacConf($c);
|
$this->setPacConf($c);
|
||||||
}
|
}
|
||||||
return $c['presharedkey'];
|
return $c[$this->getInstanceWG(1) . 'presharedkey'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function amneziaKeys()
|
public function amneziaKeys()
|
||||||
{
|
{
|
||||||
$c = $this->getPacConf();
|
$c = $this->getPacConf();
|
||||||
if (empty($c['amnezia_keys'])) {
|
if (empty($c[$this->getInstanceWG(1) . 'amnezia_keys'])) {
|
||||||
$c['amnezia_keys'] = [
|
$c[$this->getInstanceWG(1) . 'amnezia_keys'] = [
|
||||||
'Jc' => rand(3, 10),
|
'Jc' => rand(3, 10),
|
||||||
'Jmin' => 50,
|
'Jmin' => 50,
|
||||||
'Jmax' => 1000,
|
'Jmax' => 1000,
|
||||||
@@ -3758,7 +3923,7 @@ DNS-over-HTTPS with IP:
|
|||||||
];
|
];
|
||||||
$this->setPacConf($c);
|
$this->setPacConf($c);
|
||||||
}
|
}
|
||||||
return $c['amnezia_keys'];
|
return $c[$this->getInstanceWG(1) . 'amnezia_keys'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createPeer($ips_user = false, $name = false)
|
public function createPeer($ips_user = false, $name = false)
|
||||||
@@ -3781,9 +3946,9 @@ DNS-over-HTTPS with IP:
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$public_server_key = trim($this->ssh("echo {$conf['interface']['PrivateKey']} | {$this->getWGType()} pubkey"));
|
$public_server_key = trim($this->ssh("echo {$conf['interface']['PrivateKey']} | {$this->getWGType()} pubkey", $this->getInstanceWG()));
|
||||||
$private_peer_key = trim($this->ssh("{$this->getWGType()} genkey"));
|
$private_peer_key = trim($this->ssh("{$this->getWGType()} genkey", $this->getInstanceWG()));
|
||||||
$public_peer_key = trim($this->ssh("echo $private_peer_key | {$this->getWGType()} pubkey"));
|
$public_peer_key = trim($this->ssh("echo $private_peer_key | {$this->getWGType()} pubkey", $this->getInstanceWG()));
|
||||||
|
|
||||||
$name = ($name ? "$name" : '') . time();
|
$name = ($name ? "$name" : '') . time();
|
||||||
|
|
||||||
@@ -3792,7 +3957,7 @@ DNS-over-HTTPS with IP:
|
|||||||
'PublicKey' => $public_peer_key,
|
'PublicKey' => $public_peer_key,
|
||||||
'AllowedIPs' => "$client_ip/32",
|
'AllowedIPs' => "$client_ip/32",
|
||||||
],
|
],
|
||||||
$this->getPacConf()['amnezia'] ? ['PresharedKey' => $this->presharedKey()] : []
|
$this->getPacConf()[$this->getInstanceWG(1) . 'amnezia'] ? ['PresharedKey' => $this->presharedKey()] : []
|
||||||
);
|
);
|
||||||
$client_conf = [
|
$client_conf = [
|
||||||
'interface' => array_merge(
|
'interface' => array_merge(
|
||||||
@@ -3802,7 +3967,7 @@ DNS-over-HTTPS with IP:
|
|||||||
'Address' => "$client_ip/32",
|
'Address' => "$client_ip/32",
|
||||||
'MTU' => 1350,
|
'MTU' => 1350,
|
||||||
],
|
],
|
||||||
$this->getPacConf()['amnezia'] ? $this->amneziaKeys() : []
|
$this->getPacConf()[$this->getInstanceWG(1) . 'amnezia'] ? $this->amneziaKeys() : []
|
||||||
),
|
),
|
||||||
'peers' => [
|
'peers' => [
|
||||||
array_merge(
|
array_merge(
|
||||||
@@ -3811,7 +3976,7 @@ DNS-over-HTTPS with IP:
|
|||||||
'AllowedIPs' => $ips_user ?: "0.0.0.0/0",
|
'AllowedIPs' => $ips_user ?: "0.0.0.0/0",
|
||||||
'PersistentKeepalive' => 20,
|
'PersistentKeepalive' => 20,
|
||||||
],
|
],
|
||||||
$this->getPacConf()['amnezia'] ? ['PresharedKey' => $this->presharedKey()] : []
|
$this->getPacConf()[$this->getInstanceWG(1) . 'amnezia'] ? ['PresharedKey' => $this->presharedKey()] : []
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
@@ -3836,39 +4001,47 @@ DNS-over-HTTPS with IP:
|
|||||||
|
|
||||||
public function syncPortClients()
|
public function syncPortClients()
|
||||||
{
|
{
|
||||||
$endpoint = $this->ip . ':' . getenv('WGPORT');
|
$endpoint = [
|
||||||
$clients = $this->readClients();
|
$this->ip . ':' . getenv('WGPORT'),
|
||||||
foreach ($clients as $k => $v) {
|
$this->ip . ':' . getenv('WG1PORT'),
|
||||||
foreach ($v['peers'] as $i => $j) {
|
];
|
||||||
$clients[$k]['peers'][$i]['Endpoint'] = $endpoint;
|
for ($i=0; $i < 2; $i++) {
|
||||||
|
$this->wg = $i;
|
||||||
|
$clients = $this->readClients();
|
||||||
|
foreach ($clients as $k => $v) {
|
||||||
|
foreach ($v['peers'] as $i => $j) {
|
||||||
|
$clients[$k]['peers'][$i]['Endpoint'] = $endpoint[$i];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
$this->saveClients($clients);
|
||||||
}
|
}
|
||||||
$this->saveClients($clients);
|
unset($this->wg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function saveClients(array $clients)
|
public function saveClients(array $clients)
|
||||||
{
|
{
|
||||||
$domain = ($this->getPacConf()['domain'] ?: $this->ip) . ":" . getenv('WGPORT');
|
$c = $this->getPacConf();
|
||||||
|
$domain = ($c['domain'] ?: $this->ip) . ":" . getenv($this->getInstanceWG(1) ? 'WG1PORT' : 'WGPORT');
|
||||||
foreach ($clients as $k => $v) {
|
foreach ($clients as $k => $v) {
|
||||||
$clients[$k]['peers'][0]['Endpoint'] = $domain;
|
$clients[$k]['peers'][0]['Endpoint'] = $domain;
|
||||||
}
|
}
|
||||||
file_put_contents($this->clients, json_encode($clients, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
|
file_put_contents($this->getInstanceWG(1) ? $this->clients1 : $this->clients, json_encode($clients, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getWGType($revert = 0)
|
public function getWGType($revert = 0)
|
||||||
{
|
{
|
||||||
$wg = $this->getPacConf()['amnezia'];
|
$wg = $this->getPacConf()[$this->getInstanceWG(1) . 'amnezia'];
|
||||||
return ($revert ? !$wg : $wg) ? 'awg' : 'wg';
|
return ($revert ? !$wg : $wg) ? 'awg' : 'wg';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function restartWG($conf_str, $switch = false)
|
public function restartWG($conf_str, $switch = false)
|
||||||
{
|
{
|
||||||
$this->ssh("echo '$conf_str' > /etc/wireguard/wg0.conf");
|
$this->ssh("echo '$conf_str' > /etc/wireguard/wg0.conf", $this->getInstanceWG());
|
||||||
if (!empty($switch)) {
|
if (!empty($switch)) {
|
||||||
$this->ssh("{$this->getWGType(1)}-quick down wg0");
|
$this->ssh("{$this->getWGType(1)}-quick down wg0", $this->getInstanceWG());
|
||||||
$this->ssh("{$this->getWGType()}-quick up wg0");
|
$this->ssh("{$this->getWGType()}-quick up wg0", $this->getInstanceWG());
|
||||||
} else {
|
} else {
|
||||||
$this->ssh("{$this->getWGType()} syncconf wg0 <({$this->getWGType()}-quick strip wg0)");
|
$this->ssh("{$this->getWGType()} syncconf wg0 <({$this->getWGType()}-quick strip wg0)", $this->getInstanceWG());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -3930,10 +4103,15 @@ DNS-over-HTTPS with IP:
|
|||||||
die('нет айпи');
|
die('нет айпи');
|
||||||
}
|
}
|
||||||
echo "$ip\n";
|
echo "$ip\n";
|
||||||
var_dump($this->request('setWebhook', [
|
var_dump($r = $this->request('setWebhook', [
|
||||||
'url' => "https://$ip/tlgrm?k={$this->key}",
|
'url' => "https://$ip/tlgrm?k={$this->key}",
|
||||||
'certificate' => curl_file_create('/certs/self_public'),
|
'certificate' => curl_file_create('/certs/self_public'),
|
||||||
]));
|
]));
|
||||||
|
if (!empty($r['result']) && $r['result'] == true) {
|
||||||
|
file_put_contents('/start', 1);
|
||||||
|
} else {
|
||||||
|
die("set webhook fail\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setcommands()
|
public function setcommands()
|
||||||
|
|||||||
@@ -293,4 +293,16 @@ $i = [
|
|||||||
'en' => 'dns',
|
'en' => 'dns',
|
||||||
'ru' => 'днс',
|
'ru' => 'днс',
|
||||||
],
|
],
|
||||||
|
'mirror' => [
|
||||||
|
'en' => 'mirror',
|
||||||
|
'ru' => 'зеркало',
|
||||||
|
],
|
||||||
|
'download' => [
|
||||||
|
'en' => 'download',
|
||||||
|
'ru' => 'скачать',
|
||||||
|
],
|
||||||
|
'update bot' => [
|
||||||
|
'en' => 'update bot',
|
||||||
|
'ru' => 'обновить бота',
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|||||||
+18
-11
@@ -22,17 +22,24 @@ $address = $_GET['a'] ?: '127.0.0.1';
|
|||||||
$port = $_GET['p'] ?: '1080';
|
$port = $_GET['p'] ?: '1080';
|
||||||
$hash = $_GET['h'];
|
$hash = $_GET['h'];
|
||||||
if ($hash == substr(md5($c['key']), 0, 8)) {
|
if ($hash == substr(md5($c['key']), 0, 8)) {
|
||||||
if (file_exists($file = __DIR__ . "/zapretlists/$type")) {
|
if ($type == 'mirror') {
|
||||||
$pac = file_get_contents($file);
|
require __DIR__ . '/bot.php';
|
||||||
header('Content-Type: text/plain');
|
require __DIR__ . '/i18n.php';
|
||||||
echo str_replace([
|
$bot = new Bot($c['key'], $i);
|
||||||
'~address~',
|
$bot->getMirror();
|
||||||
'~port~',
|
} else {
|
||||||
], [
|
if (file_exists($file = __DIR__ . "/zapretlists/$type")) {
|
||||||
$address,
|
$pac = file_get_contents($file);
|
||||||
$port,
|
header('Content-Type: text/plain');
|
||||||
], $pac);
|
echo str_replace([
|
||||||
exit;
|
'~address~',
|
||||||
|
'~port~',
|
||||||
|
], [
|
||||||
|
$address,
|
||||||
|
$port,
|
||||||
|
], $pac);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,9 +11,3 @@ $bot = new Bot($c['key'], $i);
|
|||||||
$bot->setwebhook();
|
$bot->setwebhook();
|
||||||
$bot->setcommands();
|
$bot->setcommands();
|
||||||
$bot->syncPortClients();
|
$bot->syncPortClients();
|
||||||
if (!empty($c['admin'])) {
|
|
||||||
$ip = getenv('IP');
|
|
||||||
foreach ($c['admin'] as $k => $v) {
|
|
||||||
$bot->send($v, "start $ip");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require __DIR__ . '/timezone.php';
|
||||||
|
|
||||||
|
// require __DIR__ . '/debug.php';
|
||||||
|
require __DIR__ . '/bot.php';
|
||||||
|
require __DIR__ . '/config.php';
|
||||||
|
require __DIR__ . '/i18n.php';
|
||||||
|
|
||||||
|
$bot = new Bot($c['key'], $i);
|
||||||
|
|
||||||
|
if (!empty($c['admin'])) {
|
||||||
|
$ip = getenv('IP');
|
||||||
|
$rm = explode(':', trim(file_get_contents('/update/reload_message')));
|
||||||
|
$m = file_get_contents('/update/message');
|
||||||
|
foreach ($c['admin'] as $k => $v) {
|
||||||
|
$r = $bot->send($v, "start $ip");
|
||||||
|
$bot->input['chat'] = $v;
|
||||||
|
$bot->input['message_id'] = $r['result']['message_id'];
|
||||||
|
if (file_exists($bot->update)) {
|
||||||
|
if (!empty($m)) {
|
||||||
|
$bot->send($v, "<pre>$m</pre>", $v == $rm[0] ? $rm[1] : 0);
|
||||||
|
}
|
||||||
|
$r = $bot->send($v, "import settings");
|
||||||
|
$bot->input['chat'] = $v;
|
||||||
|
$bot->input['message_id'] = $r['result']['message_id'];
|
||||||
|
$bot->input['callback_id'] = $r['result']['message_id'];
|
||||||
|
if (empty($flag)) {
|
||||||
|
$bot->importFile($bot->update);
|
||||||
|
unlink($bot->update);
|
||||||
|
$flag = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
file_put_contents('/update/message', '');
|
||||||
|
file_put_contents('/update/reload_message', '');
|
||||||
|
$bot->menu();
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
[]
|
||||||
@@ -9,6 +9,7 @@ events {
|
|||||||
}
|
}
|
||||||
|
|
||||||
http {
|
http {
|
||||||
|
server_names_hash_bucket_size 64;
|
||||||
include include.conf;
|
include include.conf;
|
||||||
include /etc/nginx/mime.types;
|
include /etc/nginx/mime.types;
|
||||||
default_type application/octet-stream;
|
default_type application/octet-stream;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ events {
|
|||||||
}
|
}
|
||||||
|
|
||||||
http {
|
http {
|
||||||
|
server_names_hash_bucket_size 64;
|
||||||
include include.conf;
|
include include.conf;
|
||||||
include /etc/nginx/mime.types;
|
include /etc/nginx/mime.types;
|
||||||
default_type application/octet-stream;
|
default_type application/octet-stream;
|
||||||
|
|||||||
+116
-2
@@ -17,6 +17,7 @@ volumes:
|
|||||||
|
|
||||||
services:
|
services:
|
||||||
up:
|
up:
|
||||||
|
image: mercurykd/vpnbot-up:1.1
|
||||||
build:
|
build:
|
||||||
context: dockerfile
|
context: dockerfile
|
||||||
dockerfile: nginx.dockerfile
|
dockerfile: nginx.dockerfile
|
||||||
@@ -32,6 +33,7 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- 443:443
|
- 443:443
|
||||||
hostname: upstream
|
hostname: upstream
|
||||||
|
container_name: upstream-${VER}
|
||||||
depends_on:
|
depends_on:
|
||||||
php:
|
php:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
@@ -48,6 +50,7 @@ services:
|
|||||||
ipv4_address: 10.10.0.10
|
ipv4_address: 10.10.0.10
|
||||||
logging: *default-logging
|
logging: *default-logging
|
||||||
ng:
|
ng:
|
||||||
|
image: mercurykd/vpnbot-ng:1.1
|
||||||
build:
|
build:
|
||||||
context: dockerfile
|
context: dockerfile
|
||||||
dockerfile: nginx.dockerfile
|
dockerfile: nginx.dockerfile
|
||||||
@@ -66,6 +69,7 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- 80:80
|
- 80:80
|
||||||
hostname: nginx
|
hostname: nginx
|
||||||
|
container_name: nginx-${VER}
|
||||||
depends_on:
|
depends_on:
|
||||||
up:
|
up:
|
||||||
condition: service_started
|
condition: service_started
|
||||||
@@ -79,6 +83,7 @@ services:
|
|||||||
ipv4_address: 10.10.0.2
|
ipv4_address: 10.10.0.2
|
||||||
logging: *default-logging
|
logging: *default-logging
|
||||||
php:
|
php:
|
||||||
|
image: mercurykd/vpnbot-php:1.1
|
||||||
build:
|
build:
|
||||||
dockerfile: dockerfile/php.dockerfile
|
dockerfile: dockerfile/php.dockerfile
|
||||||
args:
|
args:
|
||||||
@@ -94,14 +99,21 @@ services:
|
|||||||
- ./scripts/start_php.sh:/start_php.sh
|
- ./scripts/start_php.sh:/start_php.sh
|
||||||
- ./scripts/check_file.sh:/check_file.sh
|
- ./scripts/check_file.sh:/check_file.sh
|
||||||
- ./version:/version
|
- ./version:/version
|
||||||
|
- ./mirror:/mirror
|
||||||
|
- ./.env:/mirror/.env
|
||||||
|
- ./update:/update
|
||||||
environment:
|
environment:
|
||||||
TZ: ${TZ}
|
TZ: ${TZ}
|
||||||
IP: ${IP}
|
IP: ${IP}
|
||||||
ADDRESS: ${WGADDRESS}
|
ADDRESS: ${WGADDRESS}
|
||||||
WGPORT: ${WGPORT}
|
WGPORT: ${WGPORT}
|
||||||
|
WG1ADDRESS: ${WG1ADDRESS}
|
||||||
|
WG1PORT: ${WG1PORT}
|
||||||
SSPORT: ${SSPORT}
|
SSPORT: ${SSPORT}
|
||||||
TGPORT: ${TGPORT}
|
TGPORT: ${TGPORT}
|
||||||
|
VER: ${VER}
|
||||||
hostname: php
|
hostname: php
|
||||||
|
container_name: php-${VER}
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
stop_grace_period: 1s
|
stop_grace_period: 1s
|
||||||
command: ["/bin/sh", "/start_php.sh"]
|
command: ["/bin/sh", "/start_php.sh"]
|
||||||
@@ -117,7 +129,57 @@ services:
|
|||||||
interval: 5s
|
interval: 5s
|
||||||
timeout: 5s
|
timeout: 5s
|
||||||
retries: 5
|
retries: 5
|
||||||
|
service:
|
||||||
|
image: mercurykd/vpnbot-php:1.1
|
||||||
|
build:
|
||||||
|
dockerfile: dockerfile/php.dockerfile
|
||||||
|
args:
|
||||||
|
image: ${IMAGE}
|
||||||
|
volumes:
|
||||||
|
- ./config/.profile:/root/.ashrc:ro
|
||||||
|
- ./config/php.ini:/etc/php81/php.ini
|
||||||
|
- ./config/:/config/
|
||||||
|
- ./certs/:/certs/
|
||||||
|
- ./ssh:/ssh
|
||||||
|
- ./app:/app
|
||||||
|
- ./logs/:/logs/
|
||||||
|
- ./update:/update
|
||||||
|
- ./scripts/start_service.sh:/start_service.sh
|
||||||
|
environment:
|
||||||
|
TZ: ${TZ}
|
||||||
|
IP: ${IP}
|
||||||
|
ADDRESS: ${WGADDRESS}
|
||||||
|
WGPORT: ${WGPORT}
|
||||||
|
WG1ADDRESS: ${WG1ADDRESS}
|
||||||
|
WG1PORT: ${WG1PORT}
|
||||||
|
SSPORT: ${SSPORT}
|
||||||
|
TGPORT: ${TGPORT}
|
||||||
|
VER: ${VER}
|
||||||
|
hostname: service
|
||||||
|
container_name: service-${VER}
|
||||||
|
# restart: unless-stopped
|
||||||
|
stop_grace_period: 1s
|
||||||
|
command: ["/bin/sh", "/start_service.sh"]
|
||||||
|
working_dir: /app
|
||||||
|
networks:
|
||||||
|
default:
|
||||||
|
ipv4_address: 10.10.0.15
|
||||||
|
logging: *default-logging
|
||||||
|
depends_on:
|
||||||
|
- up
|
||||||
|
- ng
|
||||||
|
- php
|
||||||
|
- proxy
|
||||||
|
- wg
|
||||||
|
- wg1
|
||||||
|
- ad
|
||||||
|
- ss
|
||||||
|
- tg
|
||||||
|
- xr
|
||||||
|
- oc
|
||||||
|
- np
|
||||||
proxy:
|
proxy:
|
||||||
|
image: mercurykd/vpnbot-ss:1.1
|
||||||
build:
|
build:
|
||||||
dockerfile: dockerfile/shadowsocks.dockerfile
|
dockerfile: dockerfile/shadowsocks.dockerfile
|
||||||
args:
|
args:
|
||||||
@@ -129,6 +191,7 @@ services:
|
|||||||
- ./config/sshd_config:/etc/ssh/sshd_config
|
- ./config/sshd_config:/etc/ssh/sshd_config
|
||||||
- ./scripts/start_proxy.sh:/start_proxy.sh
|
- ./scripts/start_proxy.sh:/start_proxy.sh
|
||||||
hostname: proxy
|
hostname: proxy
|
||||||
|
container_name: proxy-${VER}
|
||||||
depends_on:
|
depends_on:
|
||||||
php:
|
php:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
@@ -142,6 +205,7 @@ services:
|
|||||||
command: ["/bin/sh", "/start_proxy.sh"]
|
command: ["/bin/sh", "/start_proxy.sh"]
|
||||||
logging: *default-logging
|
logging: *default-logging
|
||||||
wg:
|
wg:
|
||||||
|
image: mercurykd/vpnbot-wg:1.1
|
||||||
build:
|
build:
|
||||||
dockerfile: dockerfile/wireguard.dockerfile
|
dockerfile: dockerfile/wireguard.dockerfile
|
||||||
args:
|
args:
|
||||||
@@ -153,12 +217,11 @@ services:
|
|||||||
- ./scripts/start_wg.sh:/start_wg.sh
|
- ./scripts/start_wg.sh:/start_wg.sh
|
||||||
- ./scripts/reset_wg.sh:/reset_wg.sh
|
- ./scripts/reset_wg.sh:/reset_wg.sh
|
||||||
- ./scripts/block_torrent.sh:/block_torrent.sh
|
- ./scripts/block_torrent.sh:/block_torrent.sh
|
||||||
- ./scripts/unblock_torrent.sh:/unblock_torrent.sh
|
|
||||||
- ./scripts/block_exchange.sh:/block_exchange.sh
|
- ./scripts/block_exchange.sh:/block_exchange.sh
|
||||||
- ./scripts/unblock_exchange.sh:/unblock_exchange.sh
|
|
||||||
- ./ssh:/ssh
|
- ./ssh:/ssh
|
||||||
- ./config/sshd_config:/etc/ssh/sshd_config
|
- ./config/sshd_config:/etc/ssh/sshd_config
|
||||||
hostname: wireguard
|
hostname: wireguard
|
||||||
|
container_name: wireguard-${VER}
|
||||||
depends_on:
|
depends_on:
|
||||||
php:
|
php:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
@@ -168,6 +231,7 @@ services:
|
|||||||
TZ: ${TZ}
|
TZ: ${TZ}
|
||||||
WGPORT: ${WGPORT}
|
WGPORT: ${WGPORT}
|
||||||
ADDRESS: ${WGADDRESS}
|
ADDRESS: ${WGADDRESS}
|
||||||
|
ENV: /root/.ashrc
|
||||||
cap_add:
|
cap_add:
|
||||||
- NET_ADMIN
|
- NET_ADMIN
|
||||||
devices:
|
devices:
|
||||||
@@ -178,7 +242,46 @@ services:
|
|||||||
default:
|
default:
|
||||||
ipv4_address: 10.10.0.4
|
ipv4_address: 10.10.0.4
|
||||||
logging: *default-logging
|
logging: *default-logging
|
||||||
|
wg1:
|
||||||
|
image: mercurykd/vpnbot-wg:1.1
|
||||||
|
build:
|
||||||
|
dockerfile: dockerfile/wireguard.dockerfile
|
||||||
|
args:
|
||||||
|
image: ${IMAGE}
|
||||||
|
volumes:
|
||||||
|
- ./config/.profile:/root/.ashrc:ro
|
||||||
|
- ./config/wg1.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/block_exchange.sh:/block_exchange.sh
|
||||||
|
- ./ssh:/ssh
|
||||||
|
- ./config/sshd_config:/etc/ssh/sshd_config
|
||||||
|
hostname: wireguard1
|
||||||
|
container_name: wireguard1-${VER}
|
||||||
|
depends_on:
|
||||||
|
php:
|
||||||
|
condition: service_healthy
|
||||||
|
ports:
|
||||||
|
- ${WG1PORT}:${WG1PORT}/udp
|
||||||
|
environment:
|
||||||
|
TZ: ${TZ}
|
||||||
|
WGPORT: ${WG1PORT}
|
||||||
|
ADDRESS: ${WG1ADDRESS}
|
||||||
|
ENV: /root/.ashrc
|
||||||
|
cap_add:
|
||||||
|
- NET_ADMIN
|
||||||
|
devices:
|
||||||
|
- /dev/net/tun:/dev/net/tun
|
||||||
|
stop_grace_period: 1s
|
||||||
|
command: ["/bin/sh", "/start_wg.sh"]
|
||||||
|
networks:
|
||||||
|
default:
|
||||||
|
ipv4_address: 10.10.0.14
|
||||||
|
logging: *default-logging
|
||||||
ad:
|
ad:
|
||||||
|
image: mercurykd/vpnbot-ad:1.1
|
||||||
build:
|
build:
|
||||||
dockerfile: dockerfile/adguard.dockerfile
|
dockerfile: dockerfile/adguard.dockerfile
|
||||||
args:
|
args:
|
||||||
@@ -197,6 +300,7 @@ services:
|
|||||||
- ./logs/:/logs/
|
- ./logs/:/logs/
|
||||||
- ./scripts/start_ad.sh:/start_ad.sh
|
- ./scripts/start_ad.sh:/start_ad.sh
|
||||||
hostname: adguard
|
hostname: adguard
|
||||||
|
container_name: adguard-${VER}
|
||||||
depends_on:
|
depends_on:
|
||||||
php:
|
php:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
@@ -211,6 +315,7 @@ services:
|
|||||||
entrypoint: ["/bin/sh", "/start_ad.sh"]
|
entrypoint: ["/bin/sh", "/start_ad.sh"]
|
||||||
logging: *default-logging
|
logging: *default-logging
|
||||||
ss:
|
ss:
|
||||||
|
image: mercurykd/vpnbot-ss:1.1
|
||||||
build:
|
build:
|
||||||
dockerfile: dockerfile/shadowsocks.dockerfile
|
dockerfile: dockerfile/shadowsocks.dockerfile
|
||||||
args:
|
args:
|
||||||
@@ -222,6 +327,7 @@ services:
|
|||||||
- ./config/sshd_config:/etc/ssh/sshd_config
|
- ./config/sshd_config:/etc/ssh/sshd_config
|
||||||
- ./scripts/start_ss.sh:/start_ss.sh
|
- ./scripts/start_ss.sh:/start_ss.sh
|
||||||
hostname: shadowsocks
|
hostname: shadowsocks
|
||||||
|
container_name: shadowsocks-${VER}
|
||||||
depends_on:
|
depends_on:
|
||||||
php:
|
php:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
@@ -238,6 +344,7 @@ services:
|
|||||||
ipv4_address: 10.10.0.6
|
ipv4_address: 10.10.0.6
|
||||||
logging: *default-logging
|
logging: *default-logging
|
||||||
tg:
|
tg:
|
||||||
|
image: mercurykd/vpnbot-tg:1.1
|
||||||
build:
|
build:
|
||||||
dockerfile: dockerfile/telegram.dockerfile
|
dockerfile: dockerfile/telegram.dockerfile
|
||||||
volumes:
|
volumes:
|
||||||
@@ -247,6 +354,7 @@ services:
|
|||||||
- ./scripts/start_tg.sh:/start_tg.sh
|
- ./scripts/start_tg.sh:/start_tg.sh
|
||||||
- ./config/mtprotosecret:/mtprotosecret
|
- ./config/mtprotosecret:/mtprotosecret
|
||||||
hostname: telegram
|
hostname: telegram
|
||||||
|
container_name: mtproto-${VER}
|
||||||
depends_on:
|
depends_on:
|
||||||
php:
|
php:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
@@ -263,6 +371,7 @@ services:
|
|||||||
ipv4_address: 10.10.0.8
|
ipv4_address: 10.10.0.8
|
||||||
logging: *default-logging
|
logging: *default-logging
|
||||||
xr:
|
xr:
|
||||||
|
image: mercurykd/vpnbot-xr:1.1
|
||||||
build:
|
build:
|
||||||
dockerfile: dockerfile/xray.dockerfile
|
dockerfile: dockerfile/xray.dockerfile
|
||||||
args:
|
args:
|
||||||
@@ -274,6 +383,7 @@ services:
|
|||||||
- ./config/xray.json:/xray.json
|
- ./config/xray.json:/xray.json
|
||||||
- ./scripts/start_xray.sh:/start_xray.sh
|
- ./scripts/start_xray.sh:/start_xray.sh
|
||||||
hostname: xray
|
hostname: xray
|
||||||
|
container_name: xray-${VER}
|
||||||
depends_on:
|
depends_on:
|
||||||
php:
|
php:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
@@ -286,6 +396,7 @@ services:
|
|||||||
ipv4_address: 10.10.0.9
|
ipv4_address: 10.10.0.9
|
||||||
logging: *default-logging
|
logging: *default-logging
|
||||||
oc:
|
oc:
|
||||||
|
image: mercurykd/vpnbot-oc:1.1
|
||||||
build:
|
build:
|
||||||
dockerfile: dockerfile/ocserv.dockerfile
|
dockerfile: dockerfile/ocserv.dockerfile
|
||||||
args:
|
args:
|
||||||
@@ -298,6 +409,7 @@ services:
|
|||||||
- ./certs:/certs
|
- ./certs:/certs
|
||||||
- ./scripts/start_oc.sh:/start_oc.sh
|
- ./scripts/start_oc.sh:/start_oc.sh
|
||||||
hostname: ocserv
|
hostname: ocserv
|
||||||
|
container_name: openconnect-${VER}
|
||||||
depends_on:
|
depends_on:
|
||||||
php:
|
php:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
@@ -315,6 +427,7 @@ services:
|
|||||||
ipv4_address: 10.10.0.11
|
ipv4_address: 10.10.0.11
|
||||||
logging: *default-logging
|
logging: *default-logging
|
||||||
np:
|
np:
|
||||||
|
image: mercurykd/vpnbot-np:1.1
|
||||||
build:
|
build:
|
||||||
dockerfile: dockerfile/naive.dockerfile
|
dockerfile: dockerfile/naive.dockerfile
|
||||||
args:
|
args:
|
||||||
@@ -327,6 +440,7 @@ services:
|
|||||||
- ./certs:/certs
|
- ./certs:/certs
|
||||||
- ./scripts/start_np.sh:/start_np.sh
|
- ./scripts/start_np.sh:/start_np.sh
|
||||||
hostname: naive
|
hostname: naive
|
||||||
|
container_name: naive-${VER}
|
||||||
depends_on:
|
depends_on:
|
||||||
php:
|
php:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ FROM $image
|
|||||||
RUN apk add --no-cache --update php81 \
|
RUN apk add --no-cache --update php81 \
|
||||||
php81-mbstring \
|
php81-mbstring \
|
||||||
php81-session \
|
php81-session \
|
||||||
|
php81-phar \
|
||||||
php81-curl \
|
php81-curl \
|
||||||
php81-opcache \
|
php81-opcache \
|
||||||
php81-openssl \
|
php81-openssl \
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
b:
|
b:
|
||||||
docker compose build
|
docker compose build
|
||||||
u: # запуск контейнеров
|
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
|
bash ./update/update.sh &
|
||||||
|
IP=$(shell curl https://ipinfo.io/ip) VER=$(shell git describe --tags) docker compose up -d --force-recreate
|
||||||
d: # остановка контейнеров
|
d: # остановка контейнеров
|
||||||
docker compose down
|
-kill -9 $(shell cat ./update/update_pid) > /dev/null
|
||||||
|
docker compose down --remove-orphans
|
||||||
dv: # остановка контейнеров
|
dv: # остановка контейнеров
|
||||||
docker compose down -v
|
docker compose down -v
|
||||||
r: cleanf d u cleanf
|
r: d cleanf u cleanf
|
||||||
ps: # список контейнеров
|
ps: # список контейнеров
|
||||||
docker compose ps
|
docker compose ps
|
||||||
l: # логи из контейнеров
|
l: # логи из контейнеров
|
||||||
@@ -15,6 +17,8 @@ php: # консоль сервиса
|
|||||||
docker compose exec php /bin/sh
|
docker compose exec php /bin/sh
|
||||||
wg: # консоль сервиса
|
wg: # консоль сервиса
|
||||||
docker compose exec wg /bin/sh
|
docker compose exec wg /bin/sh
|
||||||
|
wg1: # консоль сервиса
|
||||||
|
docker compose exec wg1 /bin/sh
|
||||||
ss: # консоль сервиса
|
ss: # консоль сервиса
|
||||||
docker compose exec ss /bin/sh
|
docker compose exec ss /bin/sh
|
||||||
ng: # консоль сервиса
|
ng: # консоль сервиса
|
||||||
@@ -25,12 +29,14 @@ up: # консоль сервиса
|
|||||||
docker compose exec up /bin/sh
|
docker compose exec up /bin/sh
|
||||||
ad: # консоль сервиса
|
ad: # консоль сервиса
|
||||||
docker compose exec ad /bin/sh
|
docker compose exec ad /bin/sh
|
||||||
|
wp: # консоль сервиса
|
||||||
|
docker compose exec wp bash
|
||||||
proxy: # консоль сервиса
|
proxy: # консоль сервиса
|
||||||
docker compose exec proxy /bin/sh
|
docker compose exec proxy /bin/sh
|
||||||
tg: # консоль сервиса
|
tg: # консоль сервиса
|
||||||
docker compose exec tg /bin/sh
|
docker compose exec tg /bin/sh
|
||||||
xr: # консоль сервиса
|
xr: # консоль сервиса
|
||||||
docker compose exec xr /bin/shec tg /bin/sh
|
docker compose exec xr /bin/sh
|
||||||
oc: # консоль сервиса
|
oc: # консоль сервиса
|
||||||
docker compose exec oc /bin/sh
|
docker compose exec oc /bin/sh
|
||||||
clean:
|
clean:
|
||||||
@@ -40,12 +46,13 @@ cleanf:
|
|||||||
docker image prune -f > /dev/null
|
docker image prune -f > /dev/null
|
||||||
docker builder prune -f > /dev/null
|
docker builder prune -f > /dev/null
|
||||||
cleanall:
|
cleanall:
|
||||||
docker image prune -a
|
docker image prune -a -f
|
||||||
docker builder prune -a
|
docker builder prune -a -f
|
||||||
p:
|
push:
|
||||||
git stash
|
docker compose push
|
||||||
git pull
|
s:
|
||||||
git stash pop stash@{0}
|
git status -su
|
||||||
update: p r
|
c:
|
||||||
cn:
|
git add config/
|
||||||
docker compose exec ng nginx -t
|
git checkout .
|
||||||
|
git reset
|
||||||
@@ -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
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
FROM alpine:3.18
|
||||||
|
RUN apk add socat htop net-tools
|
||||||
@@ -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
|
||||||
@@ -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
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
if [[ -f "/ssh/key.pub" && -s "/ssh/key.pub" ]]; then
|
if [[ -f "/start" && -f "/ssh/key.pub" && -s "/ssh/key.pub" ]]; then
|
||||||
exit 0;
|
exit 0;
|
||||||
else
|
else
|
||||||
exit 1;
|
exit 1;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
route add -net 10.0.1.0 netmask 255.255.255.0 gw wg
|
route add -net 10.0.1.0 netmask 255.255.255.0 gw wg
|
||||||
|
route add -net 10.0.3.0 netmask 255.255.255.0 gw wg1
|
||||||
route add -net 10.0.2.0 netmask 255.255.255.0 gw oc
|
route add -net 10.0.2.0 netmask 255.255.255.0 gw oc
|
||||||
cat /ssh/key.pub > /root/.ssh/authorized_keys
|
cat /ssh/key.pub > /root/.ssh/authorized_keys
|
||||||
ssh-keygen -A
|
ssh-keygen -A
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
php service.php
|
||||||
+33
-14
@@ -1,3 +1,7 @@
|
|||||||
|
cat /ssh/key.pub > /root/.ssh/authorized_keys
|
||||||
|
ssh-keygen -A
|
||||||
|
exec /usr/sbin/sshd -D -e "$@" &
|
||||||
|
|
||||||
INTERFACE=$(route | grep '^default' | grep -o '[^ ]*$')
|
INTERFACE=$(route | grep '^default' | grep -o '[^ ]*$')
|
||||||
if [ $(cat /etc/wireguard/wg0.conf | wc -c) -eq 0 ]
|
if [ $(cat /etc/wireguard/wg0.conf | wc -c) -eq 0 ]
|
||||||
then
|
then
|
||||||
@@ -13,21 +17,36 @@ fi
|
|||||||
iptables -t nat -A POSTROUTING --destination 10.10.0.5 -j ACCEPT
|
iptables -t nat -A POSTROUTING --destination 10.10.0.5 -j ACCEPT
|
||||||
iptables -t nat -A POSTROUTING -o $INTERFACE -j MASQUERADE
|
iptables -t nat -A POSTROUTING -o $INTERFACE -j MASQUERADE
|
||||||
ln -s /etc/wireguard/wg0.conf /etc/amnezia/amneziawg/wg0.conf
|
ln -s /etc/wireguard/wg0.conf /etc/amnezia/amneziawg/wg0.conf
|
||||||
if [ $(cat /pac.json | jq .amnezia) -eq 1 ]
|
if [ "$HOSTNAME" = "wireguard1" ]
|
||||||
then
|
then
|
||||||
awg-quick up wg0
|
if [ $(cat /pac.json | jq .wg1_amnezia) -eq 1 ]
|
||||||
|
then
|
||||||
|
awg-quick up wg0
|
||||||
|
else
|
||||||
|
wg-quick up wg0
|
||||||
|
fi
|
||||||
|
if [ $(cat /pac.json | jq .wg1_blocktorrent) -eq 1 ]
|
||||||
|
then
|
||||||
|
sh /block_torrent.sh
|
||||||
|
fi
|
||||||
|
if [ $(cat /pac.json | jq .wg1_exchange) -eq 1 ]
|
||||||
|
then
|
||||||
|
sh /block_exchange.sh
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
wg-quick up wg0
|
if [ $(cat /pac.json | jq .amnezia) -eq 1 ]
|
||||||
fi
|
then
|
||||||
cat /ssh/key.pub > /root/.ssh/authorized_keys
|
awg-quick up wg0
|
||||||
ssh-keygen -A
|
else
|
||||||
exec /usr/sbin/sshd -D -e "$@" &
|
wg-quick up wg0
|
||||||
if [ $(cat /pac.json | jq .blocktorrent) -eq 1 ]
|
fi
|
||||||
then
|
if [ $(cat /pac.json | jq .blocktorrent) -eq 1 ]
|
||||||
sh /block_torrent.sh
|
then
|
||||||
fi
|
sh /block_torrent.sh
|
||||||
if [ $(cat /pac.json | jq .exchange) -eq 1 ]
|
fi
|
||||||
then
|
if [ $(cat /pac.json | jq .exchange) -eq 1 ]
|
||||||
sh /block_exchange.sh
|
then
|
||||||
|
sh /block_exchange.sh
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
tail -f /dev/null
|
tail -f /dev/null
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
iptables -D FORWARD -i wg0 -o wg0 -j REJECT
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
iptables -D FORWARD -p tcp -m ipp2p --bit -j DROP
|
|
||||||
iptables -D FORWARD -p udp -m ipp2p --bit -j DROP
|
|
||||||
iptables -D FORWARD -m string --algo bm --string "BitTorrent" -j DROP
|
|
||||||
iptables -D FORWARD -m string --algo bm --string "BitTorrent protocol" -j DROP
|
|
||||||
iptables -D FORWARD -m string --algo bm --string "peer_id=" -j DROP
|
|
||||||
iptables -D FORWARD -m string --algo bm --string ".torrent" -j DROP
|
|
||||||
iptables -D FORWARD -m string --algo bm --string "announce.php?passkey=" -j DROP
|
|
||||||
iptables -D FORWARD -m string --algo bm --string "torrent" -j DROP
|
|
||||||
iptables -D FORWARD -m string --algo bm --string "announce" -j DROP
|
|
||||||
iptables -D FORWARD -m string --algo bm --string "info_hash" -j DROP
|
|
||||||
iptables -D OUTPUT -p tcp -m ipp2p --bit -j DROP
|
|
||||||
iptables -D OUTPUT -p udp -m ipp2p --bit -j DROP
|
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
pwd=`pwd`
|
||||||
|
> $pwd/update/pipe
|
||||||
|
echo "$$" > $pwd/update/update_pid
|
||||||
|
|
||||||
|
while true
|
||||||
|
do
|
||||||
|
cmd=$(cat $pwd/update/pipe)
|
||||||
|
if [[ -n "$cmd" ]]
|
||||||
|
then
|
||||||
|
docker compose down --remove-orphans
|
||||||
|
git reset --hard
|
||||||
|
git pull > ./update/message
|
||||||
|
IP=$(curl https://ipinfo.io/ip) VER=$(git describe --tags) docker compose up -d --force-recreate
|
||||||
|
bash $pwd/update/update.sh &
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
@@ -1,3 +1,15 @@
|
|||||||
|
03.03.2024 возможность обновления бота по кнопке из самого бота
|
||||||
|
- <code>git pull && make r</code>
|
||||||
|
02.03.2024 2 сервера wireguard, для возможности один запускать как wireguard а второй как amnezia
|
||||||
|
- <code>git pull && make r</code>
|
||||||
|
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 из исходников
|
27.02.2024 оптимизация размеров образов, сборка naive из исходников
|
||||||
- <code>git pull && make r</code>
|
- <code>git pull && make r</code>
|
||||||
19.02.2024 добавлен NaiveProxy
|
19.02.2024 добавлен NaiveProxy
|
||||||
|
|||||||
Reference in New Issue
Block a user