Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e2f84b0ee7 | |||
| b394e769c6 | |||
| 7d8dc1dd2d | |||
| 34b1de5132 | |||
| 12b5d84afc | |||
| c3d90ada83 | |||
| dbe3f290ea | |||
| b56b48e080 | |||
| 21b7a4816f | |||
| 51ecb815ba | |||
| 66cee61d41 | |||
| 66225917fe | |||
| be227f6a33 | |||
| 37d392a240 | |||
| 565573cfc2 | |||
| 3813f43b92 | |||
| f34427c13c |
+4
-1
@@ -22,4 +22,7 @@ update/*
|
||||
override.env
|
||||
override.html
|
||||
override.php
|
||||
docker-compose.override.yml
|
||||
docker-compose.override.yml
|
||||
backup.json
|
||||
app/webapp/override/
|
||||
.rest
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
require __DIR__ . '/timezone.php';
|
||||
|
||||
require __DIR__ . '/bot.php';
|
||||
require __DIR__ . '/config.php';
|
||||
require __DIR__ . '/i18n.php';
|
||||
if ($c['debug']) {
|
||||
require __DIR__ . '/debug.php';
|
||||
}
|
||||
|
||||
$bot = new Bot($c['key'], $i);
|
||||
echo $bot->export();
|
||||
+240
-83
@@ -163,6 +163,12 @@ class Bot
|
||||
case preg_match('~^/mirror$~', $this->input['message'], $m):
|
||||
$this->menu('mirror');
|
||||
break;
|
||||
case preg_match('~^/mainOutbound$~', $this->input['callback'], $m):
|
||||
$this->mainOutbound();
|
||||
break;
|
||||
case preg_match('~^/importIps (.+)$~', $this->input['callback'], $m):
|
||||
$this->importIps($m[1]);
|
||||
break;
|
||||
case preg_match('~^/switchBanIp$~', $this->input['callback'], $m):
|
||||
$this->switchBanIp();
|
||||
break;
|
||||
@@ -202,7 +208,7 @@ class Bot
|
||||
case preg_match('~^/cleanLogs (.+?)(?:\s(1))?$~', $this->input['callback'], $m):
|
||||
$this->cleanLogs($m[1], $m[2]);
|
||||
break;
|
||||
case preg_match('~^/allowIp (\d+\.\d+\.\d+\.\d+) (\d+)(?:\s(\d+))?$~', $this->input['callback'], $m):
|
||||
case preg_match('~^/allowIp (.+?) (\d+)(?:\s(\d+))?$~', $this->input['callback'], $m):
|
||||
$this->allowIp($m[1], $m[2], $m[3]);
|
||||
break;
|
||||
case preg_match('~^/searchIp (.+)$~', $this->input['callback'], $m):
|
||||
@@ -319,13 +325,13 @@ class Bot
|
||||
case preg_match('~^/defaultMTU (?P<arg>\d+(?:_(?:-)?\d+)?)$~', $this->input['callback'], $m):
|
||||
$this->defaultMTU(...explode('_', $m['arg']));
|
||||
break;
|
||||
case preg_match('~^/subnet (?P<arg>-?\d+(?:_(?:-)?\d+)?)$~', $this->input['callback'], $m):
|
||||
case preg_match('~^/subnet (?P<arg>-?\d+(?:_-?\d+)?(?:_\d)?)$~', $this->input['callback'], $m):
|
||||
$this->subnet(...explode('_', $m['arg']));
|
||||
break;
|
||||
case preg_match('~^/subnetAdd (?P<arg>-?\d+(?:_(?:-)?\d+)?)$~', $this->input['callback'], $m):
|
||||
case preg_match('~^/subnetAdd (?P<arg>-?\d+(?:_-?\d+)?(?:_-?\d+)?)$~', $this->input['callback'], $m):
|
||||
$this->subnetAdd(...explode('_', $m['arg']));
|
||||
break;
|
||||
case preg_match('~^/subnetDelete (?P<arg>-?\d+(?:_-?\d+)?(?:_-?\d+)?)$~', $this->input['callback'], $m):
|
||||
case preg_match('~^/subnetDelete (?P<arg>-?\d+(?:_-?\d+)?(?:_-?\d+)?(?:_-?\d+)?)$~', $this->input['callback'], $m):
|
||||
$this->subnetDelete(...explode('_', $m['arg']));
|
||||
break;
|
||||
case preg_match('~^/addSubnets (?P<arg>-?\d+(?:_(?:-)?\d+)?)$~', $this->input['callback'], $m):
|
||||
@@ -600,7 +606,7 @@ class Bot
|
||||
$this->addOverrideHtml();
|
||||
break;
|
||||
case preg_match('~^/export$~', $this->input['callback'], $m):
|
||||
$this->exportManual();
|
||||
$this->pinBackup();
|
||||
break;
|
||||
case preg_match('~^/import$~', $this->input['callback'], $m):
|
||||
$this->import();
|
||||
@@ -1223,12 +1229,13 @@ class Bot
|
||||
}
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
file_put_contents('/logs/php_error', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function checkBackup($delta)
|
||||
{
|
||||
$c = $this->getPacConf();
|
||||
$c = $this->getPacConf();
|
||||
if (!empty($c['backup'])) {
|
||||
$now = strtotime(date('Y-m-d H:i:s'));
|
||||
[$start, $period] = explode('/', $c['backup']);
|
||||
@@ -1241,9 +1248,6 @@ class Bot
|
||||
&& $now - $start >= 0
|
||||
&& (($now - $start) % $period < $delta)
|
||||
) {
|
||||
if (!empty($c['pinbackup'])) {
|
||||
$this->pinAdmin($c['pinbackup'], 1);
|
||||
}
|
||||
$this->pinBackup();
|
||||
}
|
||||
}
|
||||
@@ -1265,12 +1269,19 @@ class Bot
|
||||
}
|
||||
}
|
||||
|
||||
public function pinBackup()
|
||||
public function pinBackup($file = false)
|
||||
{
|
||||
require __DIR__ . '/config.php';
|
||||
$conf = $this->getPacConf();
|
||||
$bot = preg_replace('~[\W]~iu', '_', $this->request('getMyName', [])['result']['name']);
|
||||
$conf['pinbackup'] = $this->upload("{$bot}_export_" . date('d_m_Y_H_i') . '.json', $this->export(), $c['admin'][0])['result']['message_id'];
|
||||
$conf = $this->getPacConf();
|
||||
$bot = preg_replace('~[\W]~iu', '_', $this->request('getMyName', [])['result']['name']);
|
||||
$json = $this->export();
|
||||
if (!empty($file)) {
|
||||
file_put_contents($file, $json);
|
||||
}
|
||||
if (!empty($conf['pinbackup'])) {
|
||||
$this->pinAdmin($conf['pinbackup'], 1);
|
||||
}
|
||||
$conf['pinbackup'] = $this->upload("{$bot}_export_" . date('d_m_Y_H_i') . '.json', $json, $c['admin'][0])['result']['message_id'];
|
||||
$this->setPacConf($conf);
|
||||
$this->pinAdmin($conf['pinbackup']);
|
||||
}
|
||||
@@ -1293,9 +1304,13 @@ class Bot
|
||||
$this->send($v, implode("\n", $diff), 0, [
|
||||
[
|
||||
[
|
||||
'text' => 'changelog',
|
||||
'text' => 'changelog',
|
||||
'web_app' => ['url' => "https://raw.githubusercontent.com/mercurykd/vpnbot/$b/version"],
|
||||
]
|
||||
],
|
||||
[
|
||||
'text' => $this->i18n('update bot'),
|
||||
'callback_data' => "/applyupdatebot",
|
||||
],
|
||||
]
|
||||
]);
|
||||
}
|
||||
@@ -1454,16 +1469,6 @@ class Bot
|
||||
return json_encode($conf, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
}
|
||||
|
||||
public function exportManual($file = false)
|
||||
{
|
||||
$json = $this->export();
|
||||
if (!empty($file)) {
|
||||
file_put_contents($file, $json);
|
||||
}
|
||||
$bot = preg_replace('~[\W]~iu', '_', $this->request('getMyName', [])['result']['name']);
|
||||
return $this->upload("{$bot}_export_" . date('d_m_Y_H_i') . '.json', $json);
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
$r = $this->send(
|
||||
@@ -3107,7 +3112,7 @@ DNS-over-HTTPS with IP:
|
||||
$this->menu('client', "{$client}_$page");
|
||||
}
|
||||
|
||||
public function subnetAdd($wgpage, $page)
|
||||
public function subnetAdd($wgpage, $page, $openconnect)
|
||||
{
|
||||
$r = $this->send(
|
||||
$this->input['chat'],
|
||||
@@ -3119,11 +3124,11 @@ DNS-over-HTTPS with IP:
|
||||
'start_message' => $this->input['message_id'],
|
||||
'start_callback' => $this->input['callback_id'],
|
||||
'callback' => 'subnetSave',
|
||||
'args' => [$wgpage, $page],
|
||||
'args' => [$wgpage, $page, $openconnect],
|
||||
];
|
||||
}
|
||||
|
||||
public function subnetSave($text, $wgpage, $page)
|
||||
public function subnetSave($text, $wgpage, $page, $openconnect)
|
||||
{
|
||||
$c = $this->getPacConf();
|
||||
$subnets = explode(',', $text);
|
||||
@@ -3132,15 +3137,42 @@ DNS-over-HTTPS with IP:
|
||||
$this->setPacConf($c);
|
||||
$page = floor(count($c['subnets']) / $this->limit);
|
||||
}
|
||||
$this->subnet($wgpage, $page);
|
||||
if (!empty($openconnect)) {
|
||||
$this->ocservRoute();
|
||||
}
|
||||
$this->subnet($wgpage, $page, $openconnect);
|
||||
}
|
||||
|
||||
public function subnetDelete($wgpage, $k, $page = 0)
|
||||
public function subnetDelete($wgpage, $k, $page = 0, $openconnect = 0)
|
||||
{
|
||||
$c = $this->getPacConf();
|
||||
unset($c['subnets'][$k]);
|
||||
$this->setPacConf($c);
|
||||
$this->subnet($wgpage, $page);
|
||||
if (!empty($openconnect)) {
|
||||
$this->ocservRoute();
|
||||
}
|
||||
$this->subnet($wgpage, $page, $openconnect);
|
||||
}
|
||||
|
||||
public function ocservRoute()
|
||||
{
|
||||
$p = $this->getPacConf();
|
||||
$c = file_get_contents('/config/ocserv.conf');
|
||||
$t = preg_replace('~^route[^\n]+~sm', '', $c);
|
||||
if (!empty($p['subnets'])) {
|
||||
foreach ($p['subnets'] as $v) {
|
||||
if (preg_match('~^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/\d{1,2}~', $v)) {
|
||||
$t .= "route = $v";
|
||||
$flag = true;
|
||||
}
|
||||
}
|
||||
if (empty($flag)) {
|
||||
$t .= 'route = default';
|
||||
}
|
||||
} else {
|
||||
$t .= 'route = default';
|
||||
}
|
||||
$this->restartOcserv($t);
|
||||
}
|
||||
|
||||
public function calc()
|
||||
@@ -3196,10 +3228,10 @@ DNS-over-HTTPS with IP:
|
||||
}
|
||||
}
|
||||
|
||||
public function subnet($wgpage = 0, $page = 0, $count = 5)
|
||||
public function subnet($wgpage = 0, $page = 0, $openconnect = 0)
|
||||
{
|
||||
$count = $this->limit;
|
||||
$text = "Menu -> Wireguard -> " . $this->i18n('listSubnet') . "\n";
|
||||
$text = 'Menu -> ' . ($openconnect ? 'Openconnect' : 'Wireguard') . ' -> ' . $this->i18n('listSubnet') . "\n";
|
||||
$data[] = [
|
||||
[
|
||||
'text' => $this->i18n('calc'),
|
||||
@@ -3209,7 +3241,7 @@ DNS-over-HTTPS with IP:
|
||||
$data[] = [
|
||||
[
|
||||
'text' => $this->i18n('add'),
|
||||
'callback_data' => "/subnetAdd {$wgpage}_$page",
|
||||
'callback_data' => "/subnetAdd {$wgpage}_{$page}_$openconnect",
|
||||
],
|
||||
];
|
||||
$subnets = $this->getPacConf()['subnets'];
|
||||
@@ -3222,7 +3254,7 @@ DNS-over-HTTPS with IP:
|
||||
$data[] = [
|
||||
[
|
||||
'text' => $this->i18n('delete') . " $v",
|
||||
'callback_data' => "/subnetDelete {$wgpage}_{$k}_$page",
|
||||
'callback_data' => "/subnetDelete {$wgpage}_{$k}_{$page}_$openconnect",
|
||||
],
|
||||
];
|
||||
}
|
||||
@@ -3230,11 +3262,11 @@ DNS-over-HTTPS with IP:
|
||||
$data[] = [
|
||||
[
|
||||
'text' => '<<',
|
||||
'callback_data' => "/subnet {$wgpage}_" . ($page - 1 >= 0 ? $page - 1 : $all - 1),
|
||||
'callback_data' => "/subnet {$wgpage}_" . ($page - 1 >= 0 ? $page - 1 : $all - 1) . ($openconnect ? '_1' : ''),
|
||||
],
|
||||
[
|
||||
'text' => '>>',
|
||||
'callback_data' => "/subnet {$wgpage}_" . ($page < $all - 1 ? $page + 1 : 0),
|
||||
'callback_data' => "/subnet {$wgpage}_" . ($page < $all - 1 ? $page + 1 : 0) . ($openconnect ? '_1' : ''),
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -3242,7 +3274,7 @@ DNS-over-HTTPS with IP:
|
||||
$data[] = [
|
||||
[
|
||||
'text' => $this->i18n('back'),
|
||||
'callback_data' => "/menu wg $wgpage",
|
||||
'callback_data' => $openconnect ? '/menu oc' : "/menu wg $wgpage",
|
||||
],
|
||||
];
|
||||
$this->update(
|
||||
@@ -3795,7 +3827,7 @@ DNS-over-HTTPS with IP:
|
||||
[$data] = $this->listPac('includelist', $page, 'xtlsproxy');
|
||||
$data[] = [
|
||||
[
|
||||
'text' => 'set to ' . ($p['domains_outbound'] ? 'proxy' : 'direct'),
|
||||
'text' => 'set to ' . ($p['domains_outbound'] ? ($p['outbound'] ?: 'proxy') : 'direct'),
|
||||
'callback_data' => "/domainsOutbound",
|
||||
],
|
||||
];
|
||||
@@ -3853,7 +3885,7 @@ DNS-over-HTTPS with IP:
|
||||
$p = $this->getPacConf();
|
||||
$data[] = [
|
||||
[
|
||||
'text' => 'set to ' . ($p['app_outbound'] ? 'proxy' : 'direct'),
|
||||
'text' => 'set to ' . ($p['app_outbound'] ? ($p['outbound'] ?: 'proxy') : 'direct'),
|
||||
'callback_data' => "/appOutbound",
|
||||
],
|
||||
];
|
||||
@@ -3879,7 +3911,7 @@ DNS-over-HTTPS with IP:
|
||||
$p = $this->getPacConf();
|
||||
$data[] = [
|
||||
[
|
||||
'text' => 'set to ' . ($p['process_outbound'] ? 'proxy' : 'direct'),
|
||||
'text' => 'set to ' . ($p['process_outbound'] ? ($p['outbound'] ?: 'proxy') : 'direct'),
|
||||
'callback_data' => "/processOutbound",
|
||||
],
|
||||
];
|
||||
@@ -4343,24 +4375,14 @@ DNS-over-HTTPS with IP:
|
||||
public function analysisIp(int $page = 0, $return = false)
|
||||
{
|
||||
$pac = $this->getPacConf();
|
||||
foreach (array_merge($pac['white'] ?: [], $pac['deny'] ?: [], [
|
||||
'10.10.0.1' ,'10.10.1.1' ,
|
||||
'10.10.0.2' ,'10.10.1.2' ,
|
||||
'10.10.0.3' ,'10.10.1.3' ,
|
||||
'10.10.0.4' ,'10.10.1.4' ,
|
||||
'10.10.0.5' ,'10.10.1.5' ,
|
||||
'10.10.0.6' ,'10.10.1.6' ,
|
||||
'10.10.0.7' ,'10.10.1.7' ,
|
||||
'10.10.0.8' ,'10.10.1.8' ,
|
||||
'10.10.0.9' ,'10.10.1.9' ,
|
||||
'10.10.0.10','10.10.1.10',
|
||||
'10.10.0.11','10.10.1.11',
|
||||
'10.10.0.12','10.10.1.12',
|
||||
'10.10.0.13','10.10.1.13',
|
||||
'10.10.0.14','10.10.1.14',
|
||||
'10.10.0.15','10.10.1.15',
|
||||
]) as $v) {
|
||||
$xr[$v] = true;
|
||||
foreach (array_merge($pac['white'] ?: [], $pac['deny'] ?: [], ['10.10.0.0/23']) as $v) {
|
||||
if (!empty(preg_match('~^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/(\d{1,2})~', $v, $m))) {
|
||||
for ($i = ip2long($m[1]); $i < ip2long($m[1]) + pow(2, 32 - $m[2]) - 1; $i++) {
|
||||
$xr[long2ip($i)] = true;
|
||||
}
|
||||
} else {
|
||||
$xr[$v] = true;
|
||||
}
|
||||
}
|
||||
if ($r = fopen('/logs/nginx_tlgrm_access', 'r')) {
|
||||
while (feof($r) === false) {
|
||||
@@ -4545,14 +4567,59 @@ DNS-over-HTTPS with IP:
|
||||
}
|
||||
}
|
||||
|
||||
public function importIps($type)
|
||||
{
|
||||
switch ($type) {
|
||||
case 'telegram':
|
||||
$r = file_get_contents('https://core.telegram.org/resources/cidr.txt');
|
||||
if (!empty($r)) {
|
||||
$domains = explode("\n", $r);
|
||||
}
|
||||
break;
|
||||
case 'gcore':
|
||||
$r = json_decode(file_get_contents('https://api.gcore.com/cdn/public-ip-list'), true);
|
||||
if (!empty($r['addresses'])) {
|
||||
$domains = $r['addresses'];
|
||||
}
|
||||
break;
|
||||
case 'cloudflare':
|
||||
$r = json_decode(file_get_contents('https://api.cloudflare.com/client/v4/ips'), true);
|
||||
if (!empty($r['result']['ipv4_cidrs'])) {
|
||||
$domains = $r['result']['ipv4_cidrs'];
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (!empty($domains = array_filter($domains ?: [], fn($e) => preg_match('~^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/\d{1,2}~', $e)))) {
|
||||
$this->addInclude(implode(',', $domains), 'white');
|
||||
}
|
||||
}
|
||||
|
||||
public function denyList($page = 0, $white = 0)
|
||||
{
|
||||
$text = 'Menu -> IP -> ' . ($white ? 'white' : 'deny') . ' list';
|
||||
$text = 'Menu -> IP -> ' . ($white ? 'ignore' : 'block') . 'list';
|
||||
$domains = $this->getPacConf()[$white ? 'white' : 'deny'] ?: [];
|
||||
$all = (int) ceil(count($domains) / $this->limit);
|
||||
$page = min($page, $all - 1);
|
||||
$page = $page < 0 ? $all - 1 : $page;
|
||||
|
||||
$data[] = [
|
||||
[
|
||||
'text' => $this->i18n('telegram IPs'),
|
||||
'callback_data' => "/importIps telegram",
|
||||
],
|
||||
];
|
||||
$data[] = [
|
||||
[
|
||||
'text' => $this->i18n('gcore IPs'),
|
||||
'callback_data' => "/importIps gcore",
|
||||
],
|
||||
];
|
||||
$data[] = [
|
||||
[
|
||||
'text' => $this->i18n('cloudflare IPs'),
|
||||
'callback_data' => "/importIps cloudflare",
|
||||
],
|
||||
];
|
||||
$data[] = [
|
||||
[
|
||||
'text' => $this->i18n('add'),
|
||||
@@ -4689,6 +4756,20 @@ DNS-over-HTTPS with IP:
|
||||
public function syncDeny()
|
||||
{
|
||||
$pac = $this->getPacConf();
|
||||
if ($r = fopen('/logs/nginx_tlgrm_access', 'r')) {
|
||||
while (feof($r) === false) {
|
||||
$l = fgets($r);
|
||||
if (preg_match('~(\d+\.\d+\.\d+\.\d+)~', $l, $m)) {
|
||||
$xr[$m[1]] = true;
|
||||
}
|
||||
}
|
||||
fclose($r);
|
||||
}
|
||||
if (!empty($xr)) {
|
||||
foreach (array_keys($xr) as $v) {
|
||||
$text .= "allow $v;\n";
|
||||
}
|
||||
}
|
||||
if (!empty($pac['white'])) {
|
||||
$pac['white'] = array_unique($pac['white']);
|
||||
sort($pac['white']);
|
||||
@@ -4699,8 +4780,12 @@ DNS-over-HTTPS with IP:
|
||||
if (!empty($pac['deny'])) {
|
||||
$pac['deny'] = array_unique($pac['deny']);
|
||||
sort($pac['deny']);
|
||||
foreach ($pac['deny'] as $v) {
|
||||
$text .= "deny $v;\n";
|
||||
foreach ($pac['deny'] as $k => $v) {
|
||||
if (!in_array($v, $pac['white'] ?: []) && !in_array($v, array_keys($xr ?: []))) {
|
||||
$text .= "deny $v;\n";
|
||||
} else {
|
||||
unset($pac['deny'][$k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->setPacConf($pac);
|
||||
@@ -4903,11 +4988,19 @@ DNS-over-HTTPS with IP:
|
||||
'text' => $this->i18n('change password'),
|
||||
'callback_data' => "/changeOcPass",
|
||||
],
|
||||
];
|
||||
$data[] = [
|
||||
[
|
||||
'text' => $this->i18n('dns') . ": $dns",
|
||||
'callback_data' => "/changeOcDns",
|
||||
],
|
||||
];
|
||||
$data[] = [
|
||||
[
|
||||
'text' => $this->i18n('listSubnet'),
|
||||
'callback_data' => "/subnet 0_0_1",
|
||||
],
|
||||
];
|
||||
$data[] = [
|
||||
[
|
||||
'text' => $this->i18n('expose-iroutes') . ' ' . $this->i18n($expose ? 'on' : 'off'),
|
||||
@@ -5222,6 +5315,23 @@ DNS-over-HTTPS with IP:
|
||||
$domain = $this->getDomain();
|
||||
$hash = substr(md5($this->key), 0, 8);
|
||||
$text[] = "Menu -> " . $this->i18n('xray') . " -> $type templates";
|
||||
$text[] = <<<TEXT
|
||||
<code>~outbound~</code>
|
||||
<code>"~pac~"</code>
|
||||
<code>~dns~</code>
|
||||
<code>~uid~</code>
|
||||
<code>~domain~</code>
|
||||
<code>~directdomain~</code>
|
||||
<code>~cdndomain~</code>
|
||||
<code>~short_id~</code>
|
||||
<code>~public_key~</code>
|
||||
<code>~server_name~</code>
|
||||
<code>~app_outbound~</code>
|
||||
<code>~process_outbound~</code>
|
||||
<code>~domains_outbound~</code>
|
||||
<code>~final_outbound~</code>
|
||||
<code>~ip~</code>
|
||||
TEXT;
|
||||
$templates = $pac["{$type}templates"];
|
||||
|
||||
$data[] = [
|
||||
@@ -5283,6 +5393,34 @@ DNS-over-HTTPS with IP:
|
||||
);
|
||||
}
|
||||
|
||||
public function mainOutbound()
|
||||
{
|
||||
$r = $this->send(
|
||||
$this->input['chat'],
|
||||
"@{$this->input['username']} send name",
|
||||
$this->input['message_id'],
|
||||
reply: 'send name',
|
||||
);
|
||||
$_SESSION['reply'][$r['result']['message_id']] = [
|
||||
'start_message' => $this->input['message_id'],
|
||||
'start_callback' => $this->input['callback_id'],
|
||||
'callback' => 'setMainOutbound',
|
||||
'args' => [],
|
||||
];
|
||||
}
|
||||
|
||||
public function setMainOutbound($text)
|
||||
{
|
||||
$pac = $this->getPacConf();
|
||||
if (!empty($text)) {
|
||||
$pac['outbound'] = $text;
|
||||
} else {
|
||||
unset($pac['outbound']);
|
||||
}
|
||||
$this->setPacConf($pac);
|
||||
$this->xray();
|
||||
}
|
||||
|
||||
public function xray($page = 0)
|
||||
{
|
||||
if (!$this->ssh('pgrep xray', 'xr')) {
|
||||
@@ -5295,6 +5433,12 @@ DNS-over-HTTPS with IP:
|
||||
$text[] = "fake domain: <code>$fake</code>";
|
||||
}
|
||||
$text[] = 'transport: ' . ($p['transport'] ?: 'Reality');
|
||||
$data[] = [
|
||||
[
|
||||
'text' => $this->i18n('main outbound name: ') . ($p['outbound'] ?: 'proxy'),
|
||||
'callback_data' => '/mainOutbound',
|
||||
],
|
||||
];
|
||||
$data[] = [
|
||||
[
|
||||
'text' => $p['linkdomain'] ?: $this->i18n('cdn'),
|
||||
@@ -5875,7 +6019,6 @@ DNS-over-HTTPS with IP:
|
||||
$c['outbounds'][$index]['tls']['reality']['short_id'] = '~short_id~';
|
||||
}
|
||||
|
||||
$c['route'] = $this->addRuleSet($c['route']);
|
||||
$c['route'] = $this->createRuleSet($c['route'], $uid, $domain);
|
||||
break;
|
||||
}
|
||||
@@ -5885,6 +6028,8 @@ DNS-over-HTTPS with IP:
|
||||
'~dns~' => "https://$domain/dns-query/$uid",
|
||||
'~uid~' => $uid,
|
||||
'~domain~' => $domain,
|
||||
'~directdomain~' => $pac['domain'],
|
||||
'~cdndomain~' => $pac['linkdomain'],
|
||||
'~short_id~' => $xr['inbounds'][0]['streamSettings']['realitySettings']['shortIds'][0],
|
||||
'~public_key~' => $pac['xray'],
|
||||
'~server_name~' => $xr['inbounds'][0]['streamSettings']['realitySettings']['serverNames'][0],
|
||||
@@ -5894,6 +6039,7 @@ DNS-over-HTTPS with IP:
|
||||
'~final_outbound~' => $pac['final_outbound'] ? $outbound : 'direct',
|
||||
'~ip~' => $this->ip,
|
||||
]);
|
||||
$json = $this->addRuleSet($json);
|
||||
$json = $this->clearEmptyRules($json);
|
||||
|
||||
header('Content-type: application/json');
|
||||
@@ -5927,29 +6073,40 @@ DNS-over-HTTPS with IP:
|
||||
return json_encode($json);
|
||||
}
|
||||
|
||||
public function addRuleSet($route)
|
||||
public function addRuleSet($json)
|
||||
{
|
||||
foreach ($route['rules'] as $k => $v) {
|
||||
$t[$v['outbound']] = $k;
|
||||
}
|
||||
$p = $this->getPacConf();
|
||||
if (!empty($p['rulessetlist'])) {
|
||||
foreach ($p['rulessetlist'] as $k => $v) {
|
||||
if (!empty($v)) {
|
||||
[$type, $time, $url] = explode(':', $k, 3);
|
||||
$route['rule_set'][] = [
|
||||
"tag" => $k,
|
||||
"type" => "remote",
|
||||
"format" => "binary",
|
||||
"url" => $url,
|
||||
"download_detour" => "direct",
|
||||
"update_interval" => $time
|
||||
];
|
||||
$route['rules'][$t[$type]]['rule_set'][] = $k;
|
||||
$json = json_decode($json, 1);
|
||||
if (!empty($json['route']['rules'])) {
|
||||
foreach ($json['route']['rules'] as $k => $v) {
|
||||
if (!empty($v['addruleset'])) {
|
||||
$t[$v['outbound']] = $k;
|
||||
}
|
||||
}
|
||||
$this->sd($t, 1);
|
||||
$p = $this->getPacConf();
|
||||
if (!empty($p['rulessetlist'])) {
|
||||
foreach ($p['rulessetlist'] as $k => $v) {
|
||||
if (!empty($v)) {
|
||||
[$type, $time, $url] = explode(':', $k, 3);
|
||||
if (!empty($json['route']['rules'][$t[$type]])) {
|
||||
$json['route']['rule_set'][] = [
|
||||
"tag" => $k,
|
||||
"type" => "remote",
|
||||
"format" => "binary",
|
||||
"url" => $url,
|
||||
"download_detour" => "direct",
|
||||
"update_interval" => $time
|
||||
];
|
||||
$json['route']['rules'][$t[$type]]['rule_set'][] = $k;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($json['route']['rules'] as $k => $v) {
|
||||
unset($json['route']['rules'][$k]['addruleset']);
|
||||
}
|
||||
}
|
||||
return $route;
|
||||
return json_encode($json);
|
||||
}
|
||||
|
||||
public function createRuleSet($route, $uid, $domain)
|
||||
@@ -6368,7 +6525,7 @@ DNS-over-HTTPS with IP:
|
||||
|
||||
public function applyupdatebot()
|
||||
{
|
||||
$this->exportManual($this->update);
|
||||
$this->pinBackup($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/key', $this->key);
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ if (!empty($bot->selfupdate)) {
|
||||
$bot->offWarp();
|
||||
}
|
||||
$bot->dontshowcron = 1;
|
||||
$bot->adguardSync();
|
||||
$bot->sslip();
|
||||
$bot->adguardSync();
|
||||
$bot->syncDeny();
|
||||
$bot->cleanDocker();
|
||||
|
||||
+1
-1
@@ -505,7 +505,7 @@ ipv4-netmask = 255.255.255.0
|
||||
|
||||
# Whether to tunnel all DNS queries via the VPN. This is the default
|
||||
# when a default route is set.
|
||||
#tunnel-all-dns = true
|
||||
tunnel-all-dns = true
|
||||
|
||||
# The advertised DNS server. Use multiple lines for
|
||||
# multiple servers.
|
||||
|
||||
@@ -111,6 +111,7 @@
|
||||
"outbound": "dns-out"
|
||||
},
|
||||
{
|
||||
"addruleset": true,
|
||||
"createruleset": [
|
||||
{
|
||||
"name": "pac",
|
||||
@@ -125,6 +126,7 @@
|
||||
"outbound": "~domains_outbound~"
|
||||
},
|
||||
{
|
||||
"addruleset": true,
|
||||
"createruleset": [
|
||||
{
|
||||
"name": "package",
|
||||
@@ -139,6 +141,7 @@
|
||||
"outbound": "~app_outbound~"
|
||||
},
|
||||
{
|
||||
"addruleset": true,
|
||||
"createruleset": [
|
||||
{
|
||||
"name": "process",
|
||||
@@ -153,6 +156,7 @@
|
||||
"outbound": "~process_outbound~"
|
||||
},
|
||||
{
|
||||
"addruleset": true,
|
||||
"createruleset": [
|
||||
{
|
||||
"name": "block",
|
||||
@@ -167,6 +171,7 @@
|
||||
"outbound": "block"
|
||||
},
|
||||
{
|
||||
"addruleset": true,
|
||||
"createruleset": [
|
||||
{
|
||||
"name": "warp",
|
||||
|
||||
@@ -160,7 +160,9 @@ services:
|
||||
- ./ssh:/ssh
|
||||
- ./app:/app
|
||||
- ./logs/:/logs/
|
||||
- ./version:/version
|
||||
- ./update:/update
|
||||
- ./.git:/.git
|
||||
- ./scripts/start_service.sh:/start_service.sh
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||
environment:
|
||||
|
||||
@@ -59,4 +59,12 @@ c:
|
||||
git checkout .
|
||||
git reset
|
||||
webhook:
|
||||
docker compose exec php php checkwebhook.php
|
||||
docker compose exec php php checkwebhook.php
|
||||
reset:
|
||||
make d
|
||||
git reset --hard
|
||||
git clean -fd
|
||||
docker volume rm vpnbot_adguard vpnbot_warp
|
||||
make u
|
||||
backup:
|
||||
docker compose exec php php backup.php > backup.json
|
||||
@@ -1,5 +0,0 @@
|
||||
make d
|
||||
rm /etc/systemd/resolved.conf.d/adguardhome.conf
|
||||
mv /etc/resolv.conf.backup /etc/resolv.conf
|
||||
systemctl reload-or-restart systemd-resolved
|
||||
make u
|
||||
@@ -1,8 +0,0 @@
|
||||
mkdir /etc/systemd/resolved.conf.d
|
||||
echo "[Resolve]
|
||||
DNS=127.0.0.1
|
||||
DNSStubListener=no" > /etc/systemd/resolved.conf.d/adguardhome.conf
|
||||
mv /etc/resolv.conf /etc/resolv.conf.backup
|
||||
ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
|
||||
systemctl reload-or-restart systemd-resolved
|
||||
make d u
|
||||
@@ -1,3 +1,22 @@
|
||||
21.11.2024 v1.107
|
||||
- xray: добавлены теги ~cdndomain~, ~directdomain~
|
||||
- xray: возможность менять имя главного аутбаунда(тот аутбаунд который заполняет бот, в шаблонах идет как ~outbound~) для клиентских конфигов
|
||||
- xray: в шаблонах теперь надо явно указывать ключ addruleset в route -> rules, чтобы бот заполнил их правилами из списка ruleset (см origin шаблон)
|
||||
- openconnect: добавлена маршрутизация (список подсетей общий с wireguard)
|
||||
- ip ban: фикс обработки подсетей в белом/черном списках
|
||||
- ip ban: в белый список можно импортировать адреса от telegram, gcore, cloudflare
|
||||
- добавлена в игнор папка app/webapp/override. она не будет перезатираться после обновления, туда можно положить ваши ресурсы к override.html
|
||||
- <code>make backup</code> - сохранит в корень backup.json
|
||||
- <code>make reset</code> - обнуляет все настройки
|
||||
18.11.2024 v1.106
|
||||
- фикс отвала бота при пустых логах телеги
|
||||
17.11.2024 v1.105
|
||||
- фикс установки домена при первом запуске
|
||||
16.11.2024 v1.104
|
||||
- единая механика закрепления бэкапа
|
||||
- фикс текста уведомления о новой версии
|
||||
16.11.2024 v1.103
|
||||
- фикс уведомления о новой версии
|
||||
16.11.2024 v1.102
|
||||
- переделан раздел списка ip под управление кнопками
|
||||
- возможность добавить свои айпи в blocklist/whitelist
|
||||
|
||||
Reference in New Issue
Block a user