Compare commits

..

20 Commits

Author SHA1 Message Date
mercury 7ce7c56c1b domain for links -> cdn for xray 2024-09-19 12:02:51 +04:00
mercury dca34de723 fix config menu 2024-09-17 20:36:51 +04:00
mercury eb1ad21c88 domain for links 2024-09-17 20:15:34 +04:00
mercury a3ca7d9ed8 fix naming clients AdgHome + xray 2024-09-16 13:07:32 +04:00
mercury 60ba3cf15c fix name clients AdguardHome 2024-09-16 12:17:20 +04:00
mercury cd8bcbe05a singbox: tls->https+user
xray: add user to AdH
2024-09-16 00:06:57 +04:00
mercury 6cc05c88e7 autoupdate command 2024-09-15 01:16:03 +04:00
mercury 795c357897 domain for amnezia 2024-09-15 00:50:46 +04:00
mercury e172868f39 fix checkcert notify 2024-09-10 15:48:55 +04:00
mercury 4ef38775b0 update version 2024-09-10 15:30:59 +04:00
mercury abdb4d791a fix ipinfo case 2024-09-10 15:27:34 +04:00
mercury 6948239144 xray subscriptions: get['cdn'] -> domain without dns 2024-09-08 21:22:38 +04:00
mercury ff0fd177c7 xray subscriptions: get['cdn'] -> domain 2024-09-08 19:45:02 +04:00
mercury 28e66d46fd fix import with transport 2024-09-08 16:22:17 +04:00
mercury edee9c78c5 fix add user xray with transport 2024-09-08 14:54:43 +04:00
mercury 6ad8b3aa92 update version 2024-09-08 12:50:21 +04:00
mercury 31f1825d37 fix change transport 2024-09-08 12:40:51 +04:00
mercury 10d84da53e fix websocket -> reality 2024-09-08 00:58:37 +04:00
mercury c7cc0f31ad fix v2ray links 2024-09-03 19:23:38 +04:00
mercury e3ddb642d7 fix import, fix ws transport 2024-09-03 18:27:26 +04:00
4 changed files with 266 additions and 53 deletions
+216 -52
View File
@@ -139,12 +139,18 @@ class Bot
case preg_match('~^/mirror$~', $this->input['message'], $m):
$this->menu('mirror');
break;
case preg_match('~^/autoupdate$~', $this->input['message'], $m):
$this->autoupdate();
break;
case preg_match('~^/appOutbound$~', $this->input['callback'], $m):
$this->appOutbound();
break;
case preg_match('~^/addSubdomain$~', $this->input['callback'], $m):
$this->addSubdomain();
break;
case preg_match('~^/addLinkDomain$~', $this->input['callback'], $m):
$this->addLinkDomain();
break;
case preg_match('~^/id$~', $this->input['message'], $m):
$this->send($this->input['chat'], $this->input['from'], $this->input['message_id']);
break;
@@ -1090,6 +1096,10 @@ class Bot
]
]);
}
if ($this->getPacConf()['autoupdate']) {
$this->input['chat'] = $this->input['from'] = $c['admin'][0];
$this->applyupdatebot();
}
}
}
}
@@ -1101,7 +1111,7 @@ class Bot
{
try {
require __DIR__ . '/config.php';
if (!empty($c['admin']) && (empty($this->time2) || ((time() - $this->time2) > 3600))) {
if (!empty($c['admin']) && date('H') == 12 && (empty($this->time2) || ((time() - $this->time2) > 4600))) {
$this->time2 = time();
$cert = $this->expireCert();
if (!empty($cert) && $cert - 60 * 60 * 24 * 14 < time()) {
@@ -1356,7 +1366,8 @@ class Bot
$out[] = 'update xray';
$this->update($this->input['chat'], $this->input['message_id'], implode("\n", $out));
$this->restartXray($json['xray']);
$this->setUpstreamDomain($json['xray']['inbounds'][0]['streamSettings']['realitySettings']['serverNames'][0]);
$this->adguardXrayClients();
$this->setUpstreamDomain($json['pac']['transport'] == 'Websocket' ? 't' : ($json['pac']['reality']['domain'] ?: $json['xray']['inbounds'][0]['streamSettings']['realitySettings']['serverNames'][0]));
}
// ocserv
if (!empty($json['oc'])) {
@@ -1375,7 +1386,7 @@ class Bot
$t = file_get_contents('/config/nginx_default.conf');
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']} {$json['pac']['domain']};", $t);
preg_match_all('~#-domain.+?#-domain~s', $t, $m);
foreach ($m[0] as $k => $v) {
$t = preg_replace('~#-domain.+?#-domain~s', $this->uncomment($v, 'domain'), $t, 1);
@@ -1590,7 +1601,7 @@ class Bot
{
$conf = $this->getPacConf();
$ip = $this->ip;
$domain = $conf['domain'] ?: $ip;
$domain = $this->getDomain();
$scheme = empty($ssl = $this->nginxGetTypeCert()) ? 'http' : 'https';
$ss = $this->getSSConfig();
$port = !empty($ss['plugin']) ? (!empty($ssl) ? 443 : 80) : getenv('SSPORT');
@@ -1807,7 +1818,11 @@ class Bot
$out[] = 'Install certificate:';
$this->update($this->input['chat'], $this->input['message_id'], implode("\n", $out));
$adguardClient = $conf['adguardkey'] ? "-d {$conf['adguardkey']}.{$conf['domain']}" : '';
$custom = $conf['subdomain'] ? "-d {$conf['subdomain']}.{$conf['domain']}" : '';
if (!empty($conf['subdomain'])) {
foreach ($conf['subdomain'] as $v) {
$custom .= " -d $v";
}
}
exec("certbot certonly --force-renew --preferred-chain 'ISRG Root X1' -n --agree-tos --email mail@{$conf['domain']} -d {$conf['domain']} -d oc.{$conf['domain']} -d np.{$conf['domain']} $adguardClient $custom --webroot -w /certs/ --logs-dir /logs --max-log-backups 0 2>&1", $out, $code);
if ($code > 0) {
$this->send($this->input['chat'], "ERROR\n" . implode("\n", $out));
@@ -2073,10 +2088,41 @@ class Bot
];
}
public function addLinkDomain()
{
$r = $this->send(
$this->input['chat'],
"@{$this->input['username']} enter domain for link",
$this->input['message_id'],
reply: 'enter domain for link',
);
$_SESSION['reply'][$r['result']['message_id']] = [
'start_message' => $this->input['message_id'],
'callback' => 'setLinkDomain',
'args' => [],
];
}
public function setLinkDomain($text)
{
$c = $this->getPacConf();
if (empty($text)) {
unset($c['linkdomain']);
} else {
$c['linkdomain'] = trim($text);
}
$this->setPacConf($c);
$this->xray();
}
public function setSubdomain($text)
{
$c = $this->getPacConf();
$c['subdomain'] = $text;
if (empty($text)) {
unset($c['subdomain']);
} else {
$c['subdomain'] = array_filter(explode(',', $text), fn($e) => !empty(trim($e)));
}
$this->setPacConf($c);
$this->menu('config');
}
@@ -2148,6 +2194,61 @@ class Bot
$this->menu('adguard');
}
public function guidv4($data = null) {
// Generate 16 bytes (128 bits) of random data or use the data passed into the function.
$data = $data ?? random_bytes(16);
assert(strlen($data) == 16);
// Set version to 0100
$data[6] = chr(ord($data[6]) & 0x0f | 0x40);
// Set bits 6-7 to 10
$data[8] = chr(ord($data[8]) & 0x3f | 0x80);
// Output the 36 character UUID.
return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
}
public function adguardXrayClients()
{
$xr = $this->getXray();
$ad = yaml_parse_file($this->adguard);
foreach ($xr['inbounds'][0]['settings']['clients'] as $k => $v) {
$tmp[] = [
'safe_search' => [
'enabled' => true,
'bing' => true,
'duckduckgo' => true,
'google' => true,
'pixabay' => true,
'yandex' => true,
'youtube' => true,
],
'blocked_services' => [
'schedule' => ['time_zone' => date_default_timezone_get()],
'ids' => [],
],
'name' => $v['email'],
'ids' => [$v['id']],
'tags' => [],
'upstreams' => [],
'uid' => $v['id'],
'upstreams_cache_size' => 0,
'upstreams_cache_enabled' => false,
'use_global_settings' => true,
'filtering_enabled' => false,
'parental_enabled' => false,
'safebrowsing_enabled' => false,
'use_global_blocked_services' => true,
'ignore_querylog' => false,
'ignore_statistics' => false,
];
}
$ad['clients']['persistent'] = $tmp;
yaml_emit_file($this->adguard, $ad);
$this->stopAd();
$this->startAd();
}
public function checkdns()
{
$r = $this->send(
@@ -3171,7 +3272,7 @@ DNS-over-HTTPS with IP:
$mpac = stat(__DIR__ . '/zapretlists/mpac');
$pac = stat(__DIR__ . '/zapretlists/pac');
$conf = $this->getPacConf();
$ip = $conf['domain'] ?: $this->ip;
$ip = $this->getDomain();
$hash = substr(md5($this->key), 0, 8);
$scheme = empty($this->nginxGetTypeCert()) ? 'http' : 'https';
$text = <<<text
@@ -3583,7 +3684,7 @@ DNS-over-HTTPS with IP:
{
$conf = $this->getPacConf();
$ip = $this->ip;
$domain = $conf['domain'] ?: $ip;
$domain = $this->getDomain();
$scheme = empty($ssl = $this->nginxGetTypeCert()) ? 'http' : 'https';
$ss = $this->getSSConfig();
$v2ray = !empty($ss['plugin']) ? 'ON' : 'OFF';
@@ -3763,7 +3864,7 @@ DNS-over-HTTPS with IP:
{
$c = $this->getXray();
$pac = $this->getPacConf();
$domain = $pac['domain'] ?: $this->ip;
$domain = $this->getDomain($pac['transport'] == 'Websocket');
$scheme = empty($this->nginxGetTypeCert()) ? 'http' : 'https';
$hash = substr(md5($this->key), 0, 8);
$si = "$scheme://{$domain}/pac/" . base64_encode(serialize([
@@ -3771,14 +3872,22 @@ DNS-over-HTTPS with IP:
't' => 'si',
's' => $c['inbounds'][0]['settings']['clients'][$i]['id'],
]));
$v2 = "$scheme://{$domain}/pac/" . base64_encode(serialize([
'h' => $hash,
't' => 's',
's' => $c['inbounds'][0]['settings']['clients'][$i]['id'],
]));
switch ($s) {
case 1:
return "$scheme://{$domain}/pac?h=$hash&t=s&s={$c['inbounds'][0]['settings']['clients'][$i]['id']}";
return "v2rayng://install-config?url=$v2#{$c['inbounds'][0]['settings']['clients'][$i]['id']}";
case 2:
return "sing-box://import-remote-profile/?url={$si}#{$c['inbounds'][0]['settings']['clients'][$i]['email']}";
default:
if ($pac['transport'] == 'Websocket') {
return "vless://{$c['inbounds'][0]['settings']['clients'][$i]['id']}@$domain:443?flow=&path=%2Fws&security=tls&sni=$domain&fp=chrome&type=ws#{$c['inbounds'][0]['settings']['clients'][$i]['email']}";
}
return "vless://{$c['inbounds'][0]['settings']['clients'][$i]['id']}@$domain:443?security=reality&sni={$c['inbounds'][0]['streamSettings']['realitySettings']['serverNames'][0]}&fp=chrome&pbk={$pac['xray']}&sid={$c['inbounds'][0]['streamSettings']['realitySettings']['shortIds'][0]}&type=tcp&flow=xtls-rprx-vision#{$c['inbounds'][0]['settings']['clients'][$i]['email']}";
}
}
@@ -3829,8 +3938,9 @@ DNS-over-HTTPS with IP:
public function naiveMenu()
{
$pac = $this->getPacConf();
$domain = $this->getDomain();
$text[] = "Menu -> NaiveProxy";
$text[] = "<code>https://{$pac['naive']['user']}:{$pac['naive']['pass']}@np.{$pac['domain']}</code>";
$text[] = "<code>https://{$pac['naive']['user']}:{$pac['naive']['pass']}@np.$domain</code>";
$data[] = [
[
'text' => $this->i18n('change login'),
@@ -3922,6 +4032,7 @@ DNS-over-HTTPS with IP:
public function ocMenu()
{
$pac = $this->getPacConf();
$domain = $this->getDomain();
$ocserv = file_get_contents('/config/ocserv.conf');
preg_match('~^camouflage_secret[^\n]+?"([^"]+)*"~sm', $ocserv, $m);
$cs = $m[1];
@@ -3930,7 +4041,7 @@ DNS-over-HTTPS with IP:
$pass = htmlspecialchars($pac['ocserv']);
$text[] = "Menu -> OpenConnect";
if (!empty($m[1])) {
$text[] = "<code>https://oc.{$pac['domain']}/?$cs</code>";
$text[] = "<code>https://oc.$domain/?$cs</code>";
}
$text[] = "password: <span class='tg-spoiler'>$pass</span>";
$data[] = [
@@ -3993,6 +4104,7 @@ DNS-over-HTTPS with IP:
if ($i == $k) {
unset($r['inbounds'][0]['settings']['clients'][$k]);
$this->restartXray($r);
$this->adguardXrayClients();
break;
}
}
@@ -4015,13 +4127,18 @@ DNS-over-HTTPS with IP:
public function addxrus($user)
{
$c = $this->getXray();
$p = $this->getPacConf();
$uuid = trim($this->ssh('xray uuid', 'xr'));
$c['inbounds'][0]['settings']['clients'][] = [
'id' => $uuid,
'flow' => 'xtls-rprx-vision',
'email' => $user,
$c['inbounds'][0]['settings']['clients'][] = $p['transport'] == 'Websocket' ? [
'id' => $uuid,
'email' => $user,
] : [
'id' => $uuid,
'flow' => 'xtls-rprx-vision',
'email' => $user,
];
$this->restartXray($c);
$this->adguardXrayClients();
$this->userXr(count($c['inbounds'][0]['settings']['clients']) - 1);
}
@@ -4068,6 +4185,7 @@ DNS-over-HTTPS with IP:
$c = $this->getXray();
$c['inbounds'][0]['settings']['clients'][$i]['email'] = $name;
$this->restartXray($c);
$this->adguardXrayClients();
$this->userXr($i);
}
@@ -4143,7 +4261,7 @@ DNS-over-HTTPS with IP:
public function templates($type)
{
$pac = $this->getPacConf();
$domain = $pac['domain'] ?: $this->ip;
$domain = $this->getDomain();
$hash = substr(md5($this->key), 0, 8);
$text[] = "Menu -> " . $this->i18n('xray') . " -> $type templates";
$templates = $pac["{$type}templates"];
@@ -4207,8 +4325,16 @@ DNS-over-HTTPS with IP:
$c = $this->getXray();
$p = $this->getPacConf();
$text[] = "Menu -> " . $this->i18n('xray');
$text[] = "fake domain: <code>{$c['inbounds'][0]['streamSettings']['realitySettings']['serverNames'][0]}</code>";
if (!empty($fake = $c['inbounds'][0]['streamSettings']['realitySettings']['serverNames'][0])) {
$text[] = "fake domain: <code>$fake</code>";
}
$text[] = 'transport: ' . ($p['transport'] ?: 'Reality');
$data[] = [
[
'text' => $p['linkdomain'] ?: $this->i18n('cdn'),
'callback_data' => '/addLinkDomain',
],
];
$data[] = [
[
'text' => $this->i18n('Reality') . ' ' . ($p['transport'] != 'Websocket' ? $this->i18n('on') : $this->i18n('off')),
@@ -4464,12 +4590,12 @@ DNS-over-HTTPS with IP:
{
$c = $this->getXray()['inbounds'][0]['settings']['clients'][$i];
$pac = $this->getPacConf();
$domain = $pac['domain'] ?: $this->ip;
$domain = $this->getDomain($pac['transport'] == 'Websocket');
$scheme = empty($this->nginxGetTypeCert()) ? 'http' : 'https';
$hash = substr(md5($this->key), 0, 8);
$text[] = "Menu -> " . $this->i18n('xray') . " -> {$c['email']}\n";
$text[] = "<code>{$this->linkXray($i)}</code>\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>";
@@ -4477,8 +4603,8 @@ DNS-over-HTTPS with IP:
$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[] = "\nv2ray config: <code>$scheme://{$domain}/pac?h=$hash&t=s&s={$c['id']}</code>";
$text[] = "sing-box config: <code>$scheme://{$domain}/pac?h=$hash&t=si&s={$c['id']}</code>";
$text[] = "\nv2ray config: <pre><code>$scheme://{$domain}/pac?h=$hash&t=s&s={$c['id']}</code></pre>";
$text[] = "sing-box config: <pre><code>$scheme://{$domain}/pac?h=$hash&t=si&s={$c['id']}</code></pre>";
$text[] = "sing-box windows: <a href='$scheme://{$domain}/pac?h=$hash&t=si&r=w&s={$c['id']}'>windows service</a>";
$data[] = [
@@ -4551,17 +4677,26 @@ DNS-over-HTTPS with IP:
);
}
public function getDomain($cdn = false)
{
$c = $this->getPacConf();
if ($cdn && $c['linkdomain']) {
return $c['linkdomain'];
}
return $c['domain'] ?: $this->ip;
}
public function v2raySubscription($key, $fs = 0)
{
$pac = $this->getPacConf();
$domain = $pac['domain'] ?: $this->ip;
$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, 0, 1);
return $this->userXr($k);
}
if (empty($v['off'])) {
$flag = false;
@@ -4594,7 +4729,7 @@ DNS-over-HTTPS with IP:
{
$type = $_GET['t'] == 's' ? 'v2ray' : 'sing';
$pac = $this->getPacConf();
$domain = $pac['domain'] ?: $this->ip;
$domain = $this->getDomain($pac['transport'] == 'Websocket');
$xr = $this->getXray();
$scheme = empty($this->nginxGetTypeCert()) ? 'http' : 'https';
$hash = substr(md5($this->key), 0, 8);
@@ -4607,6 +4742,7 @@ DNS-over-HTTPS with IP:
}
$template = base64_decode($v["{$type}template"]);
$uid = $v['id'];
$email = $v['email'];
break;
}
}
@@ -4620,19 +4756,23 @@ DNS-over-HTTPS with IP:
't' => 'si',
's' => $uid,
]));
$v2 = "$scheme://{$domain}/pac?h=$hash&t=s&s=$uid";
$v2 = "$scheme://{$domain}/pac/" . base64_encode(serialize([
'h' => $hash,
't' => 's',
's' => $uid,
]));
switch ($_GET['r']) {
case 'si':
header("Location: sing-box://import-remote-profile/?url=" . $si);
header("Location: sing-box://import-remote-profile/?url=$si");
exit;
case 'st':
header("Location: streisand://import/$v2");
exit;
case 'v':
header("Location: v2rayng://install-config?url=" . urlencode($v2));
header("Location: v2rayng://install-config?url=$v2");
exit;
case 'h':
header("Location: hiddify://install-config/?url=" . $si);
header("Location: hiddify://install-config/?url=$si");
exit;
case 'w':
$link = htmlspecialchars($si, ENT_XML1, 'UTF-8');
@@ -4670,7 +4810,7 @@ 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'] = $_GET['cdn'] ?: $domain;
$c['outbounds'][0]['settings']['vnext'][0]['users'][0] = [
'id' => $uid,
'encryption' => 'none',
@@ -4684,14 +4824,14 @@ DNS-over-HTTPS with IP:
],
"tlsSettings" => [
"allowInsecure" => false,
"serverName" => $domain,
"serverName" => $_GET['cdn'] ?: $domain,
"fingerprint" => "chrome"
]
];
unset($c['outbounds'][0]['mux']);
} else {
$c['outbounds'][0]['settings']['vnext'][0]['users'][0]["flow"] = "xtls-rprx-vision";
$c['outbounds'][0]['streamSettings'] = [
$c['outbounds'][0]['settings']['vnext'][0]['users'][0]["flow"] = "xtls-rprx-vision";
$c['outbounds'][0]['streamSettings'] = [
"network" => "tcp",
"security" => "reality",
"realitySettings" => [
@@ -4719,10 +4859,10 @@ DNS-over-HTTPS with IP:
break;
case 'si':
if ($c['dns']['servers'][0]['address'] == '~dns~') {
$c['dns']['servers'][0]['address'] = "tls://" . ($pac['adguardkey'] ? "{$pac['adguardkey']}." : '') . "$domain";
$c['dns']['servers'][0]['address'] = "https://$domain/dns-query/$uid";
}
$c['outbounds'][0]['server'] = $domain;
$c['outbounds'][0]['server'] = $_GET['cdn'] ?: $domain;
$c['outbounds'][0]['uuid'] = $uid;
if ($pac['transport'] == 'Websocket') {
unset($c['outbounds'][0]['tls']['reality']);
@@ -4731,7 +4871,7 @@ DNS-over-HTTPS with IP:
"type" => "ws",
"path" => "/ws"
];
$c['outbounds'][0]['tls']['server_name'] = $domain;
$c['outbounds'][0]['tls']['server_name'] = $_GET['cdn'] ?: $domain;
} else {
unset($c['outbounds'][0]["transport"]);
$c['outbounds'][0]['flow'] = 'xtls-rprx-vision';
@@ -4811,7 +4951,7 @@ DNS-over-HTTPS with IP:
public function createRuleSet($route, $uid)
{
$pac = $this->getPacConf();
$domain = $pac['domain'] ?: $this->ip;
$domain = $this->getDomain();
$scheme = empty($this->nginxGetTypeCert()) ? 'http' : 'https';
$hash = substr(md5($this->key), 0, 8);
@@ -4900,7 +5040,7 @@ DNS-over-HTTPS with IP:
$pac = $this->getPacConf();
$pac['xray'] = $public;
$pac['reality']['shortId'] = $shortId;
$pac['reality']['privateKey'] = $$p['reality']['shortId'];
$pac['reality']['privateKey'] = $private;
$this->setPacConf($pac);
$this->restartXray($c);
}
@@ -5028,7 +5168,7 @@ DNS-over-HTTPS with IP:
{
$conf = $this->getPacConf();
$ip = $this->ip;
$domain = $conf['domain'] ?: $ip;
$domain = $this->getDomain();
$scheme = empty($ssl = $this->nginxGetTypeCert()) ? 'http' : 'https';
$text = "$scheme://$domain/adguard\nLogin: admin\nPass: <span class='tg-spoiler'>{$conf['adpswd']}</span>\n\n";
if ($ssl) {
@@ -5132,6 +5272,15 @@ DNS-over-HTTPS with IP:
return openssl_x509_parse($c)["validTo_time_t"] ?: false;
}
public function domainsCert()
{
$domains = openssl_x509_parse(openssl_x509_read(file_get_contents("/certs/cert_public")))['extensions']["subjectAltName"];
if (empty($domains)) {
return false;
}
return implode("\n", array_map(fn($e) => trim($e), explode(',', str_replace('DNS:', '', $domains))));
}
public function updatebot()
{
$b = exec('git -C / rev-parse --abbrev-ref HEAD');
@@ -5185,10 +5334,16 @@ DNS-over-HTTPS with IP:
public function configMenu()
{
exec('git -C / fetch');
$conf = $this->getPacConf();
$text[] = $conf['domain'] ? "Domains:\n{$conf['domain']}\nnp.{$conf['domain']} (for naiveproxy)\noc.{$conf['domain']} (for openconnect)" . ($conf['adguardkey'] ? "\n{$conf['adguardkey']}.{$conf['domain']} (for adguard DoT)" : '') . ($conf['subdomain'] ? "\n{$conf['subdomain']}.{$conf['domain']} (custom)" : '') : $this->i18n('domain explain');
$conf = $this->getPacConf();
if (!empty($conf['subdomain'])) {
$custom = "\ncustom:\n";
foreach ($conf['subdomain'] as $v) {
$custom .= "$v\n";
}
}
$text[] = $conf['domain'] ? "Domains:\n{$conf['domain']}\nnp.{$conf['domain']} (for naiveproxy)\noc.{$conf['domain']} (for openconnect)" . ($conf['adguardkey'] ? "\n{$conf['adguardkey']}.{$conf['domain']} (for adguard DoT)" : '') . $custom : $this->i18n('domain explain');
$ssl = $this->expireCert();
$text[] = $conf['domain'] ? "\nSSL: " . ($ssl ? date('Y-m-d H:i:s', $this->expireCert()) : 'none') : '';
$text[] = $conf['domain'] ? "\nSSL: " . ($ssl ? date('Y-m-d H:i:s', $this->expireCert()) . "\n" . $this->domainsCert() : 'none') : '';
$data = [
[
@@ -5197,7 +5352,7 @@ DNS-over-HTTPS with IP:
'callback_data' => $conf['domain'] ? '/deldomain' : '/domain',
],
[
'text' => $this->i18n('subdomain') . ($conf['subdomain'] ? ": {$conf['subdomain']}" : ''),
'text' => $this->i18n('+ subdomain'),
'callback_data' => '/addSubdomain',
],
],
@@ -5505,9 +5660,9 @@ DNS-over-HTTPS with IP:
$x = $this->getXray();
$p['transport'] = $ws ? 'Websocket' : 'Reality';
if (!empty($ws)) {
$p['reality']['domain'] = $x['inbounds'][0]['streamSettings']['realitySettings']['serverNames'][0];
$p['reality']['destination'] = $x['inbounds'][0]['streamSettings']['realitySettings']['dest'];
$p['reality']['shortId'] = $x['inbounds'][0]['streamSettings']['realitySettings']['shortIds'][0];
$p['reality']['domain'] = $x['inbounds'][0]['streamSettings']['realitySettings']['serverNames'][0] ?: $p['reality']['domain'];
$p['reality']['destination'] = $x['inbounds'][0]['streamSettings']['realitySettings']['dest'] ?: $p['reality']['destination'];
$p['reality']['shortId'] = $x['inbounds'][0]['streamSettings']['realitySettings']['shortIds'][0] ?: $p['reality']['shortId'];
foreach ($x['inbounds'][0]['settings']['clients'] as $k => $v) {
unset($x['inbounds'][0]['settings']['clients'][$k]['flow']);
}
@@ -5515,8 +5670,8 @@ DNS-over-HTTPS with IP:
"network" => "ws",
"wsSettings" => [
"path" => "/ws"
]
];
]
];
} else {
foreach ($x['inbounds'][0]['settings']['clients'] as $k => $v) {
$x['inbounds'][0]['settings']['clients'][$k]['flow'] = 'xtls-rprx-vision';
@@ -5524,15 +5679,15 @@ DNS-over-HTTPS with IP:
$x['inbounds'][0]['streamSettings'] = [
"network" => "tcp",
"realitySettings" => [
"dest" => $p['reality']['destination'],
"dest" => $p['reality']['destination'] ?: $x['inbounds'][0]['streamSettings']['realitySettings']['dest'],
"maxClientVer" => "",
"maxTimeDiff" => 0,
"minClientVer" => "",
"privateKey" => $p['reality']['privateKey'],
"serverNames" => [
$p['reality']['domain']
$p['reality']['domain'] ?: $x['inbounds'][0]['streamSettings']['realitySettings']['serverNames'][0]
],
"shortIds" => [$p['reality']['shortId']],
"shortIds" => [$p['reality']['shortId']] ?: $x['inbounds'][0]['streamSettings']['realitySettings']['shortIds'][0],
"show" => false,
"xver" => 0
],
@@ -5545,6 +5700,7 @@ DNS-over-HTTPS with IP:
"security" => "reality"
];
}
$this->setUpstreamDomain($ws ? 't' : ($p['reality']['domain'] ?: $x['inbounds'][0]['streamSettings']['realitySettings']['serverNames'][0]));
$this->setPacConf($p);
$this->restartXray($x);
$this->xray();
@@ -5694,7 +5850,7 @@ DNS-over-HTTPS with IP:
$conf[] = '';
$conf[] = $peer['# PublicKey'] ? '# [Peer]' : '[Peer]';
if (!empty($peer['Endpoint'])) {
$peer['Endpoint'] = ($pac['domain'] && !$pac[$this->getInstanceWG(1) . 'amnezia'] ? $pac['domain'] : $this->ip) . ":" . getenv($this->getInstanceWG(1) ? 'WG1PORT' : 'WGPORT');
$peer['Endpoint'] = $this->getDomain() . ":" . getenv($this->getInstanceWG(1) ? 'WG1PORT' : 'WGPORT');
}
foreach ($peer as $k => $v) {
$conf[] = "$k = $v";
@@ -5853,6 +6009,14 @@ DNS-over-HTTPS with IP:
return true;
}
public function autoupdate()
{
$p = $this->getPacConf();
$p['autoupdate'] = !$p['autoupdate'];
$this->setPacConf($p);
$this->send($this->input['from'], $this->i18n('autoupdate') . ' ' . $this->i18n($p['autoupdate'] ? 'on' : 'off'));
}
public function disconnect(...$args)
{
$this->send($this->input['chat'], "disconnect: \n" . var_export($args, true) . "\n", $this->input['message_id']);
+21
View File
@@ -75,6 +75,27 @@ http {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_read_timeout 5d;
}
#-ssl
# # The DoH server block
# location /dns-query {
# access_log /logs/nginx_doh_access;
# # Proxy HTTP/1.1, clear the connection header to enable Keep-Alive
# proxy_http_version 1.1;
# proxy_set_header Connection "";
# proxy_set_header Host $host;
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-Proto https;
# proxy_set_header X-Forwarded-For $remote_addr;
# proxy_set_header X-Forwarded-Host $remote_addr;
# # Enable Cache, and set the cache_key to include the request_body
# proxy_cache doh_cache;
# proxy_cache_key $scheme$proxy_host$uri$is_args$args$request_body;
# # proxy pass to the dohloop upstream
# proxy_pass https://ad/dns-query;
# }
#-ssl
location ~\.well-known {
access_log /logs/nginx_certbot_access;
root /certs/;
+1 -1
View File
@@ -3,7 +3,7 @@ b:
u: # запуск контейнеров
bash ./update/update.sh &
touch ./override.env
IP=$(shell curl https://ipinfo.io/ip) VER=$(shell git describe --tags) docker compose --env-file ./.env --env-file ./override.env up -d --force-recreate
IP=$(shell curl ipinfo.io/ip) VER=$(shell git describe --tags) docker compose --env-file ./.env --env-file ./override.env up -d --force-recreate
d: # остановка контейнеров
-kill -9 $(shell cat ./update/update_pid) > /dev/null
docker compose down --remove-orphans
+28
View File
@@ -1,3 +1,31 @@
17.09.2024 v1.55
- возможность подменить домен в ссылках на конфиги
16.09.2024 v1.54.2
- фикс нэйминга клиентов в adguardHome: замена на uuid
16.09.2024 v1.54.1
- фикс нэйминга клиентов в adguardHome
16.09.2024 v1.54
- ~dns~ в шаблоне сингбокса подменяятся на https://DOMAIN/dns-query/USERNAME
- при добавлении пользователя в XRAY, он также добавляется в AdguardHome как сохраненый клиент
10.09.2024 v1.53
- домен в endpoint для амнезии
10.09.2024 v1.52
- фикс спамящего уведомления о просрочке сертификата
10.09.2024 v1.51
- фикс ipinfo
08.09.2024 v1.50
- fix import with transport
08.09.2024 v1.49
- fix add user xray with transport
08.09.2024 v1.48
- fix change xray transport, save private key xray
08.09.2024 v1.47
- fix websocket -> reality
03.09.2024 v1.46.2
- fix link v2ray
03.09.2024 v1.46.1
- fix import
- fix websocket domain
03.09.2024 v1.46
- возможность добавить кастомный поддомен для Letsencrypt
03.09.2024 v1.45