Compare commits

..

7 Commits

Author SHA1 Message Date
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
mercury 589823e45d custom subdomain 2024-09-03 13:15:34 +04:00
mercury 0364188fe8 chat link 2024-09-03 10:48:15 +04:00
2 changed files with 93 additions and 26 deletions
+82 -26
View File
@@ -142,6 +142,9 @@ class Bot
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('~^/id$~', $this->input['message'], $m):
$this->send($this->input['chat'], $this->input['from'], $this->input['message_id']);
break;
@@ -1372,7 +1375,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);
@@ -1693,7 +1696,7 @@ class Bot
$conf = $this->getPacConf();
$conf['domain'] = idn_to_ascii($domain);
$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']} *.{$conf['domain']};", $nginx);
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);
@@ -1803,9 +1806,13 @@ class Bot
case 'letsencrypt':
$out[] = 'Install certificate:';
$this->update($this->input['chat'], $this->input['message_id'], implode("\n", $out));
$adguardClient = $this->getPacConf()['adguardkey'];
$adguardClient = $adguardClient ? "-d $adguardClient.{$conf['domain']}" : '';
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 --webroot -w /certs/ --logs-dir /logs --max-log-backups 0 2>&1", $out, $code);
$adguardClient = $conf['adguardkey'] ? "-d {$conf['adguardkey']}.{$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));
break;
@@ -2054,6 +2061,30 @@ class Bot
'args' => [],
];
}
public function addSubdomain()
{
$r = $this->send(
$this->input['chat'],
"@{$this->input['username']} enter subdomain",
$this->input['message_id'],
reply: 'enter subdomain',
);
$_SESSION['reply'][$r['result']['message_id']] = [
'start_message' => $this->input['message_id'],
'callback' => 'setSubdomain',
'args' => [],
];
}
public function setSubdomain($text)
{
$c = $this->getPacConf();
$c['subdomain'] = array_filter(explode(',', $text), fn($e) => !empty(trim($e)));
$this->setPacConf($c);
$this->menu('config');
}
public function enterPage()
{
$r = $this->send(
@@ -3683,7 +3714,7 @@ DNS-over-HTTPS with IP:
[
[
'text' => $this->i18n('chat'),
'url' => "https://t.me/vpnbot_group",
'url' => "https://t.me/+BYuWVd36cZYwNTMy",
],
[
'text' => $this->i18n('donate'),
@@ -3744,14 +3775,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']}";
}
}
@@ -4180,7 +4219,9 @@ 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[] = [
[
@@ -4442,7 +4483,7 @@ DNS-over-HTTPS with IP:
$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>";
@@ -4450,8 +4491,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[] = [
@@ -4593,19 +4634,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');
@@ -4873,7 +4918,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);
}
@@ -5158,8 +5203,14 @@ 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']}\noc.{$conf['domain']}" . ($conf['adguardkey'] ? "\n{$conf['adguardkey']}.{$conf['domain']}" : '') : $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') : '';
@@ -5169,6 +5220,10 @@ DNS-over-HTTPS with IP:
'text' => $conf['domain'] ? "{$this->i18n('delete')} {$conf['domain']}" : $this->i18n('install domain'),
'callback_data' => $conf['domain'] ? '/deldomain' : '/domain',
],
[
'text' => $this->i18n('subdomain'),
'callback_data' => '/addSubdomain',
],
],
];
if ($conf['domain']) {
@@ -5474,9 +5529,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']);
}
@@ -5484,8 +5539,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';
@@ -5493,15 +5548,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
],
@@ -5514,6 +5569,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();
+11
View File
@@ -1,3 +1,14 @@
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
- выбор транспорта reality/websocket
26.08.2024 v1.44