|
|
|
@@ -1101,7 +1101,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 +1356,7 @@ 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->setUpstreamDomain($json['pac']['transport'] == 'Websocket' ? 't' : ($json['pac']['reality']['domain'] ?: $json['xray']['inbounds'][0]['streamSettings']['realitySettings']['serverNames'][0]));
|
|
|
|
|
}
|
|
|
|
|
// ocserv
|
|
|
|
|
if (!empty($json['oc'])) {
|
|
|
|
@@ -1807,7 +1807,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));
|
|
|
|
@@ -2076,7 +2080,7 @@ class Bot
|
|
|
|
|
public function setSubdomain($text)
|
|
|
|
|
{
|
|
|
|
|
$c = $this->getPacConf();
|
|
|
|
|
$c['subdomain'] = $text;
|
|
|
|
|
$c['subdomain'] = array_filter(explode(',', $text), fn($e) => !empty(trim($e)));
|
|
|
|
|
$this->setPacConf($c);
|
|
|
|
|
$this->menu('config');
|
|
|
|
|
}
|
|
|
|
@@ -3771,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']}";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@@ -4015,11 +4027,15 @@ 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->userXr(count($c['inbounds'][0]['settings']['clients']) - 1);
|
|
|
|
@@ -4207,7 +4223,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[] = [
|
|
|
|
|
[
|
|
|
|
@@ -4469,7 +4487,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>";
|
|
|
|
@@ -4477,8 +4495,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[] = [
|
|
|
|
@@ -4620,19 +4638,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 +4692,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 +4706,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" => [
|
|
|
|
@@ -4722,7 +4744,7 @@ DNS-over-HTTPS with IP:
|
|
|
|
|
$c['dns']['servers'][0]['address'] = "tls://" . ($pac['adguardkey'] ? "{$pac['adguardkey']}." : '') . "$domain";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$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 +4753,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';
|
|
|
|
@@ -4900,7 +4922,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);
|
|
|
|
|
}
|
|
|
|
@@ -5185,8 +5207,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']} (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') : '';
|
|
|
|
|
|
|
|
|
@@ -5197,7 +5225,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,10 +5533,9 @@ DNS-over-HTTPS with IP:
|
|
|
|
|
$x = $this->getXray();
|
|
|
|
|
$p['transport'] = $ws ? 'Websocket' : 'Reality';
|
|
|
|
|
if (!empty($ws)) {
|
|
|
|
|
$this->setUpstreamDomain('');
|
|
|
|
|
$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']);
|
|
|
|
|
}
|
|
|
|
@@ -5516,8 +5543,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';
|
|
|
|
@@ -5525,15 +5552,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
|
|
|
|
|
],
|
|
|
|
@@ -5546,6 +5573,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();
|
|
|
|
@@ -5695,7 +5723,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'] = ($pac['domain'] ? $pac['domain'] : $this->ip) . ":" . getenv($this->getInstanceWG(1) ? 'WG1PORT' : 'WGPORT');
|
|
|
|
|
}
|
|
|
|
|
foreach ($peer as $k => $v) {
|
|
|
|
|
$conf[] = "$k = $v";
|
|
|
|
|