Compare commits

..

14 Commits

Author SHA1 Message Date
mercury 8ad00bc47a update version 2024-11-21 18:09:25 +04:00
mercury 4902eb53ce fix addruleset for direct 2024-11-21 16:04:09 +04:00
mercury 253cceb44c fix analyze ip autoban 2024-11-21 12:13:02 +04:00
mercury 9d53f2896c fix analyze memory 2024-11-21 11:49:29 +04:00
mercury 550a8ad3b7 fix ip/32 analyze 2024-11-21 01:37:22 +04:00
mercury e2f84b0ee7 update version 2024-11-21 00:39:07 +04:00
mercury b394e769c6 роутинг для openconnect 2024-11-21 00:24:50 +04:00
mercury 7d8dc1dd2d duplicating the list of subnets for openconnect 2024-11-20 20:59:25 +04:00
mercury 34b1de5132 import telegram, gcore, cloudflare ip 2024-11-20 20:58:17 +04:00
mercury 12b5d84afc IP analyzer takes into account subnets 2024-11-20 17:12:08 +04:00
mercury c3d90ada83 addruleset and additional tags 2024-11-20 15:55:10 +04:00
mercury dbe3f290ea commands reset and backup 2024-11-20 15:46:03 +04:00
mercury b56b48e080 override ignore 2024-11-20 15:45:02 +04:00
mercury 21b7a4816f fix bot dump when telegram logs are empty 2024-11-18 00:31:53 +04:00
7 changed files with 296 additions and 80 deletions
+4 -1
View File
@@ -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
+13
View File
@@ -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();
+246 -77
View File
@@ -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):
@@ -1223,6 +1229,7 @@ class Bot
}
}
} catch (Exception $e) {
file_put_contents('/logs/php_error', $e->getMessage());
}
}
@@ -3105,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'],
@@ -3117,12 +3124,15 @@ 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)
{
if (!preg_match('~^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/\d{1,2}$~', $text)) {
return $this->send($this->input['chat'], "wrong format: $text", $this->input['message_id']);
}
$c = $this->getPacConf();
$subnets = explode(',', $text);
if ($subnets) {
@@ -3130,15 +3140,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()
@@ -3194,10 +3231,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'),
@@ -3207,7 +3244,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'];
@@ -3220,7 +3257,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",
],
];
}
@@ -3228,11 +3265,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' : ''),
]
];
}
@@ -3240,7 +3277,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(
@@ -3793,7 +3830,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",
],
];
@@ -3851,7 +3888,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",
],
];
@@ -3877,7 +3914,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",
],
];
@@ -4308,22 +4345,38 @@ DNS-over-HTTPS with IP:
);
}
public function suspicious($regexp, $file, $ip, $title, $reverse = false)
public function ipInRange($ip, $range) {
[$range, $netmask] = explode('/', $range, 2);
$rangeDecimal = ip2long($range);
$ipDecimal = ip2long($ip);
$wildcardDecimal = pow(2, 32 - $netmask) - 1;
$netmaskDecimal = ~$wildcardDecimal;
return ($ipDecimal & $netmaskDecimal) == ($rangeDecimal & $netmaskDecimal);
}
public function suspicious($regexp, $file, $ranges, $title, $reverse = false)
{
if ($r = fopen($file, 'r')) {
while (feof($r) === false) {
$l = fgets($r);
if (preg_match('~(\d+\.\d+\.\d+\.\d+)~', $l, $m)) {
if ($reverse xor preg_match($regexp, $l)) {
if (is_array($ip)) {
if (empty($ip[$m[1]])) {
if (is_array($ranges)) {
$flag = true;
foreach ($ranges as $range) {
if ($this->ipInRange($m[1], $range)) {
$flag = false;
break;
}
}
if ($flag) {
$ret[$m[1]][] = [
'title' => $title,
'log' => $l,
];
}
} else {
if ($ip == $m[1]) {
if ($this->ipInRange($m[1], $ranges)) {
$ret[$m[1]][] = [
'title' => $title,
'log' => $l,
@@ -4341,30 +4394,21 @@ 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;
$xr = [];
foreach (array_merge($pac['white'] ?: [], $pac['deny'] ?: [], ['10.10.0.0/23']) as $v) {
if (preg_match('~^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})(?:(/\d{1,2}))?$~', $v, $m)) {
if (!in_array($m[1] . ($m[2] ?: '/32'), $xr)) {
$xr[] = $m[1] . ($m[2] ?: '/32');
}
}
}
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;
if (!in_array("{$m[1]}/32", $xr)) {
$xr[] = "{$m[1]}/32";
}
}
}
fclose($r);
@@ -4373,7 +4417,9 @@ DNS-over-HTTPS with IP:
while (feof($r) === false) {
$l = fgets($r);
if (preg_match('~(\d+\.\d+\.\d+\.\d+)(?=.+accepted)~', $l, $m)) {
$xr[$m[1]] = true;
if (!in_array("{$m[1]}/32", $xr)) {
$xr[] = "{$m[1]}/32";
}
}
}
fclose($r);
@@ -4512,9 +4558,9 @@ DNS-over-HTTPS with IP:
public function searchSuspiciousIp($ip)
{
$t = [
$this->suspicious('~\d+\.\d+\.\d+\.\d+.+200\s\d+\s0$~', '/logs/upstream_access', $ip, 'possibly a Reality Degenerate'),
$this->suspicious($this->reg, '/logs/nginx_default_access', $ip, 'possibly a scanner', true),
$this->suspicious($this->reg, '/logs/nginx_domain_access', $ip, 'possibly a scanner', true),
$this->suspicious('~\d+\.\d+\.\d+\.\d+.+200\s\d+\s0$~', '/logs/upstream_access', "$ip/32", 'possibly a Reality Degenerate'),
$this->suspicious($this->reg, '/logs/nginx_default_access', "$ip/32", 'possibly a scanner', true),
$this->suspicious($this->reg, '/logs/nginx_domain_access', "$ip/32", 'possibly a scanner', true),
];
foreach ($t as $r) {
if (!empty($r)) {
@@ -4543,6 +4589,33 @@ 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 ? 'ignore' : 'block') . 'list';
@@ -4551,6 +4624,26 @@ DNS-over-HTTPS with IP:
$page = min($page, $all - 1);
$page = $page < 0 ? $all - 1 : $page;
if (!empty($white)) {
$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'),
@@ -4696,8 +4789,10 @@ DNS-over-HTTPS with IP:
}
fclose($r);
}
foreach (array_keys($xr) as $v) {
$text .= "allow $v;\n";
if (!empty($xr)) {
foreach (array_keys($xr) as $v) {
$text .= "allow $v;\n";
}
}
if (!empty($pac['white'])) {
$pac['white'] = array_unique($pac['white']);
@@ -4709,8 +4804,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);
@@ -4913,11 +5012,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'),
@@ -5232,6 +5339,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[] = [
@@ -5293,6 +5417,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')) {
@@ -5305,6 +5457,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'),
@@ -5632,12 +5790,11 @@ DNS-over-HTTPS with IP:
$text[] = "Menu -> " . $this->i18n('xray') . " -> {$c['email']}\n";
$text[] = "<pre><code>{$this->linkXray($i)}</code></pre>\n";
$text[] = "import subscribe:";
$text[] = "<a href='$scheme://{$domain}/pac?h=$hash&t=s&r=v&s={$c['id']}#{$c['email']}'>v2rayng</a>";
$text[] = "<a href='$scheme://{$domain}/pac?h=$hash&t=si&r=si&s={$c['id']}#{$c['email']}'>sing-box</a>";
$text[] = "<a href='$scheme://{$domain}/pac?h=$hash&t=s&r=st&s={$c['id']}#{$c['email']}'>streisand</a>";
$text[] = "<a href='$scheme://{$domain}/pac?h=$hash&t=si&r=h&s={$c['id']}#{$c['email']}'>hiddify</a>";
$text[] = "<a href='$scheme://{$domain}/pac?h=$hash&t=si&r=k&s={$c['id']}#{$c['email']}'>karing</a>";
$text[] = "<a href='$scheme://{$domain}/pac?h=$hash&t=s&r=v&s={$c['id']}#{$c['email']}'>import://v2rayng</a>";
$text[] = "<a href='$scheme://{$domain}/pac?h=$hash&t=si&r=si&s={$c['id']}#{$c['email']}'>import://sing-box</a>";
$text[] = "<a href='$scheme://{$domain}/pac?h=$hash&t=s&r=st&s={$c['id']}#{$c['email']}'>import://streisand</a>";
$text[] = "<a href='$scheme://{$domain}/pac?h=$hash&t=si&r=h&s={$c['id']}#{$c['email']}'>import://hiddify</a>";
$text[] = "<a href='$scheme://{$domain}/pac?h=$hash&t=si&r=k&s={$c['id']}#{$c['email']}'>import://karing</a>";
$si = "$scheme://{$domain}/pac/" . base64_encode(serialize([
'h' => $hash,
@@ -5885,7 +6042,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;
}
@@ -5895,6 +6051,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],
@@ -5904,6 +6062,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');
@@ -5937,29 +6096,39 @@ 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;
}
}
$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)
+1 -1
View File
@@ -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.
+6
View File
@@ -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",
@@ -181,6 +186,7 @@
"outbound": "~outbound~"
},
{
"addruleset": true,
"outbound": "direct"
}
],
+9 -1
View File
@@ -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
+17
View File
@@ -1,3 +1,20 @@
21.11.2024 v1.108
- xray: addruleset для direct
- openconnect:ограничение формата при добавлении подсети
- новый механизм сверки ip для анализатора айпи
- мелкие фиксы меню и текста
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