Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3087bee82d | |||
| 96fbf5a3c3 | |||
| b32bd960fa | |||
| ba0895ea4c |
+64
-90
@@ -271,6 +271,9 @@ class Bot
|
||||
case preg_match('~^/addOcUser$~', $this->input['callback'], $m):
|
||||
$this->addOcUser();
|
||||
break;
|
||||
case preg_match('~^/changeOcExpose$~', $this->input['callback'], $m):
|
||||
$this->changeOcExpose();
|
||||
break;
|
||||
case preg_match('~^/addXrUser$~', $this->input['callback'], $m):
|
||||
$this->addXrUser();
|
||||
break;
|
||||
@@ -1446,9 +1449,7 @@ class Bot
|
||||
$this->language = $this->getPacConf()['language'] ?: 'en';
|
||||
$this->limit = $this->getPacConf()['limitpage'] ?: 5;
|
||||
sleep(3);
|
||||
if (empty($file)) {
|
||||
$this->menu();
|
||||
}
|
||||
$this->menu();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1788,8 +1789,6 @@ class Bot
|
||||
if (empty($c['domain'])) {
|
||||
$this->addDomain(str_replace('.', '-', $this->ip) . '.nip.io', 1);
|
||||
$this->setSSL('letsencrypt');
|
||||
} else {
|
||||
$this->menu();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4133,7 +4132,9 @@ DNS-over-HTTPS with IP:
|
||||
preg_match('~^camouflage_secret[^\n]+?"([^"]+)*"~sm', $ocserv, $m);
|
||||
$cs = $m[1];
|
||||
preg_match('~^dns = ([^\n]+)~sm', $ocserv, $m);
|
||||
$dns = $m[1];
|
||||
$dns = $m[1];
|
||||
preg_match('~^expose-iroutes = (true)~sm', $ocserv, $m);
|
||||
$expose = $m[1];
|
||||
$pass = htmlspecialchars($pac['ocserv']);
|
||||
$text[] = "Menu -> OpenConnect";
|
||||
if (!empty($m[1])) {
|
||||
@@ -4154,6 +4155,12 @@ DNS-over-HTTPS with IP:
|
||||
'callback_data' => "/changeOcDns",
|
||||
],
|
||||
];
|
||||
$data[] = [
|
||||
[
|
||||
'text' => $this->i18n('expose-iroutes') . ' ' . $this->i18n($expose ? 'on' : 'off'),
|
||||
'callback_data' => "/changeOcExpose",
|
||||
],
|
||||
];
|
||||
$data[] = [
|
||||
[
|
||||
'text' => $this->i18n('add peer'),
|
||||
@@ -4181,6 +4188,15 @@ DNS-over-HTTPS with IP:
|
||||
];
|
||||
}
|
||||
|
||||
public function changeOcExpose()
|
||||
{
|
||||
$c = file_get_contents('/config/ocserv.conf');
|
||||
preg_match('~^expose-iroutes = ([^\n]+)~sm', $c, $m);
|
||||
$t = preg_replace('~^expose-iroutes[^\n]+~sm', "expose-iroutes = " . ($m[1] == 'true' ? 'false' : 'true'), $c);
|
||||
$this->restartOcserv($t);
|
||||
$this->menu('oc');
|
||||
}
|
||||
|
||||
public function deloc($i)
|
||||
{
|
||||
$clients = $this->getClientsOc();
|
||||
@@ -4833,45 +4849,6 @@ DNS-over-HTTPS with IP:
|
||||
return $c['domain'] ?: $this->ip;
|
||||
}
|
||||
|
||||
public function v2raySubscription($key, $fs = 0)
|
||||
{
|
||||
$pac = $this->getPacConf();
|
||||
$domain = $this->getDomain();
|
||||
$xr = $this->getXray();
|
||||
|
||||
$flag = true;
|
||||
foreach ($xr['inbounds'][0]['settings']['clients'] as $k => $v) {
|
||||
if ($v['id'] == $key) {
|
||||
if (!empty($fs)) {
|
||||
return $this->userXr($k);
|
||||
}
|
||||
if (empty($v['off'])) {
|
||||
$flag = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($flag) {
|
||||
return;
|
||||
}
|
||||
|
||||
$c = json_decode(file_get_contents('/config/v2ray.json'), true);
|
||||
|
||||
$c['outbounds'][0]['settings']['vnext'][0]['address'] = $domain;
|
||||
$c['outbounds'][0]['settings']['vnext'][0]['users'][0]['id'] = $key;
|
||||
$c['outbounds'][0]['streamSettings']['realitySettings']['serverName'] = $xr['inbounds'][0]['streamSettings']['realitySettings']['serverNames'][0];
|
||||
$c['outbounds'][0]['streamSettings']['realitySettings']['publicKey'] = $pac['xray'];
|
||||
$c['outbounds'][0]['streamSettings']['realitySettings']['shortId'] = $xr['inbounds'][0]['streamSettings']['realitySettings']['shortIds'][0];
|
||||
$c['routing']['rules'][0]['domain'] = array_keys(array_filter($pac['includelist']));
|
||||
|
||||
if (empty($c['routing']['rules'][0]['domain'])) {
|
||||
unset($c['routing']['rules'][0]);
|
||||
$c['routing']['rules'] = array_values($c['routing']['rules']);
|
||||
|
||||
}
|
||||
echo json_encode($c);
|
||||
}
|
||||
|
||||
public function subscription()
|
||||
{
|
||||
$type = $_GET['t'] == 's' ? 'v2ray' : 'sing';
|
||||
@@ -4956,9 +4933,9 @@ DNS-over-HTTPS with IP:
|
||||
|
||||
switch ($_GET['t']) {
|
||||
case 's':
|
||||
$c['outbounds'][0]['settings']['vnext'][0]['address'] = $domain;
|
||||
$c['outbounds'][0]['settings']['vnext'][0]['address'] = '~domain~';
|
||||
$c['outbounds'][0]['settings']['vnext'][0]['users'][0] = [
|
||||
'id' => $uid,
|
||||
'id' => '~uid~',
|
||||
'encryption' => 'none',
|
||||
];
|
||||
if ($pac['transport'] == 'Websocket') {
|
||||
@@ -4970,7 +4947,7 @@ DNS-over-HTTPS with IP:
|
||||
],
|
||||
"tlsSettings" => [
|
||||
"allowInsecure" => false,
|
||||
"serverName" => $domain,
|
||||
"serverName" => '~domain~',
|
||||
"fingerprint" => "chrome"
|
||||
]
|
||||
];
|
||||
@@ -4981,10 +4958,10 @@ DNS-over-HTTPS with IP:
|
||||
"network" => "tcp",
|
||||
"security" => "reality",
|
||||
"realitySettings" => [
|
||||
"serverName" => $xr['inbounds'][0]['streamSettings']['realitySettings']['serverNames'][0],
|
||||
"serverName" => '~server_name~',
|
||||
"fingerprint" => "chrome",
|
||||
"publicKey" => $pac['xray'],
|
||||
"shortId" => $xr['inbounds'][0]['streamSettings']['realitySettings']['shortIds'][0],
|
||||
"publicKey" => '~public_key~',
|
||||
"shortId" => '~short_id~',
|
||||
]
|
||||
];
|
||||
$c['outbounds'][0]['mux'] = [
|
||||
@@ -4992,24 +4969,10 @@ DNS-over-HTTPS with IP:
|
||||
"concurrency" => -1
|
||||
];
|
||||
}
|
||||
|
||||
foreach ($c['routing']['rules'] as $k => $v) {
|
||||
if (array_key_exists('domain', $v) && $v['domain'] == '~pac~') {
|
||||
$c['routing']['rules'][$k]['domain'] = array_keys(array_filter($pac['includelist'] ?: []));
|
||||
if (empty($c['routing']['rules'][$k]['domain'])) {
|
||||
unset($c['routing']['rules'][$k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
$c['routing']['rules'] = array_values($c['routing']['rules']);
|
||||
break;
|
||||
case 'si':
|
||||
if ($c['dns']['servers'][0]['address'] == '~dns~') {
|
||||
$c['dns']['servers'][0]['address'] = "https://$domain/dns-query/$uid";
|
||||
}
|
||||
|
||||
$c['outbounds'][0]['server'] = $domain;
|
||||
$c['outbounds'][0]['uuid'] = $uid;
|
||||
$c['outbounds'][0]['server'] = '~domain~';
|
||||
$c['outbounds'][0]['uuid'] = '~uid~';
|
||||
if ($pac['transport'] == 'Websocket') {
|
||||
unset($c['outbounds'][0]['tls']['reality']);
|
||||
unset($c['outbounds'][0]['flow']);
|
||||
@@ -5017,43 +4980,52 @@ DNS-over-HTTPS with IP:
|
||||
"type" => "ws",
|
||||
"path" => "/ws"
|
||||
];
|
||||
$c['outbounds'][0]['tls']['server_name'] = $domain;
|
||||
$c['outbounds'][0]['tls']['server_name'] = '~domain~';
|
||||
} else {
|
||||
unset($c['outbounds'][0]["transport"]);
|
||||
$c['outbounds'][0]['flow'] = 'xtls-rprx-vision';
|
||||
$c['outbounds'][0]['tls']['reality']['public_key'] = $pac['xray'];
|
||||
$c['outbounds'][0]['tls']['server_name'] = $xr['inbounds'][0]['streamSettings']['realitySettings']['serverNames'][0];
|
||||
$c['outbounds'][0]['tls']['reality']['short_id'] = $xr['inbounds'][0]['streamSettings']['realitySettings']['shortIds'][0];
|
||||
$c['outbounds'][0]['tls']['reality']['public_key'] = '~public_key~';
|
||||
$c['outbounds'][0]['tls']['server_name'] = '~server_name~';
|
||||
$c['outbounds'][0]['tls']['reality']['short_id'] = '~short_id~';
|
||||
}
|
||||
|
||||
foreach ($c['route']['rules'] as $k => $v) {
|
||||
if (array_key_exists('domain_suffix', $v) && $v['domain_suffix'] == '~pac~') {
|
||||
$c['route']['rules'][$k]['domain_suffix'] = array_keys(array_filter($pac['includelist'] ?: []));
|
||||
if (empty($c['route']['rules'][$k]['domain_suffix'])) {
|
||||
unset($c['route']['rules'][$k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
$c['route']['rules'] = array_values($c['route']['rules']);
|
||||
$c['route'] = $this->addRuleSet($c['route']);
|
||||
$c['route'] = $this->createRuleSet($c['route'], $uid, $domain);
|
||||
$c['route'] = $this->clearEmptyRules($c['route']);
|
||||
$c['route'] = $this->addRuleSet($c['route']);
|
||||
$c['route'] = $this->createRuleSet($c['route'], $uid, $domain);
|
||||
break;
|
||||
}
|
||||
|
||||
$json = $this->replaceTags(json_encode($c), [
|
||||
'"~pac~"' => json_encode(array_keys(array_filter($pac['includelist'] ?: []))),
|
||||
'~dns~' => "https://$domain/dns-query/$uid",
|
||||
'~uid~' => $uid,
|
||||
'~domain~' => $domain,
|
||||
'~short_id~' => $xr['inbounds'][0]['streamSettings']['realitySettings']['shortIds'][0],
|
||||
'~public_key~' => $pac['xray'],
|
||||
'~server_name~' => $xr['inbounds'][0]['streamSettings']['realitySettings']['serverNames'][0],
|
||||
]);
|
||||
$json = $this->clearEmptyRules($json);
|
||||
|
||||
header('Content-type: application/json');
|
||||
echo json_encode($c);
|
||||
echo $json;
|
||||
}
|
||||
|
||||
public function clearEmptyRules($route)
|
||||
public function replaceTags($subject, $tags)
|
||||
{
|
||||
foreach ($route['rules'] as $k => $v) {
|
||||
if (count($v) == 1) {
|
||||
unset($route['rules'][$k]);
|
||||
return str_replace(array_keys($tags), array_values($tags), $subject);
|
||||
}
|
||||
|
||||
public function clearEmptyRules($json)
|
||||
{
|
||||
$json = json_decode($json, 1);
|
||||
if (!empty($json['routing']['rules'])) {
|
||||
foreach ($json['routing']['rules'] as $k => $v) {
|
||||
if (array_key_exists('domain', $v) && empty($v['domain'])) {
|
||||
unset($json['routing']['rules'][$k]);
|
||||
}
|
||||
}
|
||||
$json['routing']['rules'] = array_values($json['routing']['rules']);
|
||||
}
|
||||
$route['rules'] = array_values($route['rules']);
|
||||
return $route;
|
||||
return json_encode($json);
|
||||
}
|
||||
|
||||
public function addRuleSet($route)
|
||||
@@ -5762,6 +5734,8 @@ DNS-over-HTTPS with IP:
|
||||
unlink($this->update);
|
||||
$flag = true;
|
||||
}
|
||||
} else {
|
||||
$this->menu();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -341,4 +341,8 @@ $i = [
|
||||
'en' => 'fake html',
|
||||
'ru' => 'фейк заглушка',
|
||||
],
|
||||
'expose-iroutes' => [
|
||||
'en' => 'expose-iroutes',
|
||||
'ru' => 'изоляция клиентов',
|
||||
],
|
||||
];
|
||||
|
||||
+1
-1
@@ -584,7 +584,7 @@ route = default
|
||||
# When set to true, all client's iroutes are made visible to all
|
||||
# connecting clients except for the ones offering them. This option
|
||||
# only makes sense if config-per-user is set.
|
||||
#expose-iroutes = true
|
||||
expose-iroutes = false
|
||||
|
||||
# Groups that a client is allowed to select from.
|
||||
# A client may belong in multiple groups, and in certain use-cases
|
||||
|
||||
@@ -462,6 +462,11 @@ services:
|
||||
default:
|
||||
ipv4_address: 10.10.0.11
|
||||
logging: *default-logging
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: '0.50'
|
||||
memory: 200M
|
||||
np:
|
||||
image: mercurykd/vpnbot-np:1.1
|
||||
build:
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
21.10.2024 v1.74
|
||||
- openconnect: expose-iroutes on/off
|
||||
21.10.2024 v1.73
|
||||
- openconnect: ограничение контейнера по цпу и памяти
|
||||
21.10.2024 v1.72
|
||||
- xray: теги в кастомных шаблонах
|
||||
21.10.2024 v1.71
|
||||
- фикс установки nip.io при первом запуске
|
||||
- фикс инициализации вебпанели adguardHome при первом запуске
|
||||
|
||||
Reference in New Issue
Block a user