|
|
|
@@ -133,12 +133,21 @@ class Bot
|
|
|
|
|
case preg_match('~^/changeWG (\d+)$~', $this->input['callback'], $m):
|
|
|
|
|
$this->changeWG($m[1]);
|
|
|
|
|
break;
|
|
|
|
|
case preg_match('~^/changeTransport(?: (\d+))?$~', $this->input['callback'], $m):
|
|
|
|
|
$this->changeTransport($m[1] ?: false);
|
|
|
|
|
break;
|
|
|
|
|
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('~^/id$~', $this->input['message'], $m):
|
|
|
|
|
$this->send($this->input['chat'], $this->input['from'], $this->input['message_id']);
|
|
|
|
|
break;
|
|
|
|
@@ -1084,6 +1093,10 @@ class Bot
|
|
|
|
|
]
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
if ($this->getPacConf()['autoupdate']) {
|
|
|
|
|
$this->input['chat'] = $this->input['from'] = $c['admin'][0];
|
|
|
|
|
$this->applyupdatebot();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@@ -1095,7 +1108,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()) {
|
|
|
|
@@ -1350,7 +1363,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'])) {
|
|
|
|
@@ -1369,7 +1383,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);
|
|
|
|
@@ -1690,7 +1704,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);
|
|
|
|
@@ -1800,9 +1814,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;
|
|
|
|
@@ -2051,6 +2069,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(
|
|
|
|
@@ -2118,6 +2160,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' => str_replace(['_', ' '], '-', $v['email']),
|
|
|
|
|
'ids' => [$v['email']],
|
|
|
|
|
'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(
|
|
|
|
@@ -3680,7 +3777,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'),
|
|
|
|
@@ -3741,14 +3838,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']}";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@@ -3963,6 +4068,7 @@ DNS-over-HTTPS with IP:
|
|
|
|
|
if ($i == $k) {
|
|
|
|
|
unset($r['inbounds'][0]['settings']['clients'][$k]);
|
|
|
|
|
$this->restartXray($r);
|
|
|
|
|
$this->adguardXrayClients();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@@ -3985,13 +4091,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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -4038,6 +4149,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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -4175,18 +4287,34 @@ DNS-over-HTTPS with IP:
|
|
|
|
|
$this->generateSecretXray();
|
|
|
|
|
}
|
|
|
|
|
$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' => $this->i18n('changeFakeDomain'),
|
|
|
|
|
'callback_data' => "/changeFakeDomain",
|
|
|
|
|
'text' => $this->i18n('Reality') . ' ' . ($p['transport'] != 'Websocket' ? $this->i18n('on') : $this->i18n('off')),
|
|
|
|
|
'callback_data' => "/changeTransport",
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'text' => $this->i18n('selfFakeDomain'),
|
|
|
|
|
'callback_data' => "/selfFakeDomain",
|
|
|
|
|
'text' => $this->i18n('Websocket') . ' ' . ($p['transport'] == 'Websocket' ? $this->i18n('on') : $this->i18n('off')),
|
|
|
|
|
'callback_data' => "/changeTransport 1",
|
|
|
|
|
],
|
|
|
|
|
];
|
|
|
|
|
if ($p['transport'] != 'Websocket') {
|
|
|
|
|
$data[] = [
|
|
|
|
|
[
|
|
|
|
|
'text' => $this->i18n('changeFakeDomain'),
|
|
|
|
|
'callback_data' => "/changeFakeDomain",
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'text' => $this->i18n('selfFakeDomain'),
|
|
|
|
|
'callback_data' => "/selfFakeDomain",
|
|
|
|
|
],
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
$data[] = [
|
|
|
|
|
[
|
|
|
|
|
'text' => $this->i18n('v2ray templates'),
|
|
|
|
@@ -4341,6 +4469,7 @@ DNS-over-HTTPS with IP:
|
|
|
|
|
{
|
|
|
|
|
$text[] = "Menu -> " . $this->i18n('warp');
|
|
|
|
|
$text[] = "status: " . $this->warpStatus();
|
|
|
|
|
$text[] = "key: " . $this->getPacConf()['warp'];
|
|
|
|
|
$data[] = [
|
|
|
|
|
[
|
|
|
|
|
'text' => $this->i18n('set key'),
|
|
|
|
@@ -4424,7 +4553,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>";
|
|
|
|
@@ -4432,8 +4561,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[] = [
|
|
|
|
@@ -4562,6 +4691,7 @@ DNS-over-HTTPS with IP:
|
|
|
|
|
}
|
|
|
|
|
$template = base64_decode($v["{$type}template"]);
|
|
|
|
|
$uid = $v['id'];
|
|
|
|
|
$email = $v['email'];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@@ -4575,19 +4705,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');
|
|
|
|
@@ -4625,11 +4759,42 @@ DNS-over-HTTPS with IP:
|
|
|
|
|
|
|
|
|
|
switch ($_GET['t']) {
|
|
|
|
|
case 's':
|
|
|
|
|
$c['outbounds'][0]['settings']['vnext'][0]['address'] = $domain;
|
|
|
|
|
$c['outbounds'][0]['settings']['vnext'][0]['users'][0]['id'] = $uid;
|
|
|
|
|
$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['outbounds'][0]['settings']['vnext'][0]['address'] = $_GET['cdn'] ?: $domain;
|
|
|
|
|
$c['outbounds'][0]['settings']['vnext'][0]['users'][0] = [
|
|
|
|
|
'id' => $uid,
|
|
|
|
|
'encryption' => 'none',
|
|
|
|
|
];
|
|
|
|
|
if ($pac['transport'] == 'Websocket') {
|
|
|
|
|
$c['outbounds'][0]['streamSettings'] = [
|
|
|
|
|
"network" => "ws",
|
|
|
|
|
"security" => "tls",
|
|
|
|
|
"wsSettings" => [
|
|
|
|
|
"path" => "/ws?ed=2560"
|
|
|
|
|
],
|
|
|
|
|
"tlsSettings" => [
|
|
|
|
|
"allowInsecure" => false,
|
|
|
|
|
"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'] = [
|
|
|
|
|
"network" => "tcp",
|
|
|
|
|
"security" => "reality",
|
|
|
|
|
"realitySettings" => [
|
|
|
|
|
"serverName" => $xr['inbounds'][0]['streamSettings']['realitySettings']['serverNames'][0],
|
|
|
|
|
"fingerprint" => "chrome",
|
|
|
|
|
"publicKey" => $pac['xray'],
|
|
|
|
|
"shortId" => $xr['inbounds'][0]['streamSettings']['realitySettings']['shortIds'][0],
|
|
|
|
|
]
|
|
|
|
|
];
|
|
|
|
|
$c['outbounds'][0]['mux'] = [
|
|
|
|
|
"enabled" => false,
|
|
|
|
|
"concurrency" => -1
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach ($c['routing']['rules'] as $k => $v) {
|
|
|
|
|
if (array_key_exists('domain', $v) && $v['domain'] == '~pac~') {
|
|
|
|
@@ -4643,14 +4808,27 @@ 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/$email";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$c['outbounds'][0]['server'] = $_GET['cdn'] ?: $domain;
|
|
|
|
|
$c['outbounds'][0]['uuid'] = $uid;
|
|
|
|
|
if ($pac['transport'] == 'Websocket') {
|
|
|
|
|
unset($c['outbounds'][0]['tls']['reality']);
|
|
|
|
|
unset($c['outbounds'][0]['flow']);
|
|
|
|
|
$c['outbounds'][0]["transport"] = [
|
|
|
|
|
"type" => "ws",
|
|
|
|
|
"path" => "/ws"
|
|
|
|
|
];
|
|
|
|
|
$c['outbounds'][0]['tls']['server_name'] = $_GET['cdn'] ?: $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]['server'] = $domain;
|
|
|
|
|
$c['outbounds'][0]['uuid'] = $uid;
|
|
|
|
|
$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];
|
|
|
|
|
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'] ?: []));
|
|
|
|
@@ -4810,6 +4988,8 @@ DNS-over-HTTPS with IP:
|
|
|
|
|
$c['inbounds'][0]['streamSettings']['realitySettings']['shortIds'][0] = $shortId;
|
|
|
|
|
$pac = $this->getPacConf();
|
|
|
|
|
$pac['xray'] = $public;
|
|
|
|
|
$pac['reality']['shortId'] = $shortId;
|
|
|
|
|
$pac['reality']['privateKey'] = $private;
|
|
|
|
|
$this->setPacConf($pac);
|
|
|
|
|
$this->restartXray($c);
|
|
|
|
|
}
|
|
|
|
@@ -5094,8 +5274,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') : '';
|
|
|
|
|
|
|
|
|
@@ -5105,6 +5291,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']) {
|
|
|
|
@@ -5383,8 +5573,12 @@ DNS-over-HTTPS with IP:
|
|
|
|
|
public function setFakeDomain($domain, $self = false)
|
|
|
|
|
{
|
|
|
|
|
$c = $this->getXray();
|
|
|
|
|
$p = $this->getPacConf();
|
|
|
|
|
$c['inbounds'][0]['streamSettings']['realitySettings']['serverNames'][0] = $domain;
|
|
|
|
|
$c['inbounds'][0]['streamSettings']['realitySettings']['dest'] = $self ? "10.10.1.2:443" : "$domain:443";
|
|
|
|
|
$p['reality']['domain'] = $domain;
|
|
|
|
|
$p['reality']['destination'] = $self ? "10.10.1.2:443" : "$domain:443";
|
|
|
|
|
$this->setPacConf($p);
|
|
|
|
|
$this->restartXray($c);
|
|
|
|
|
$this->setUpstreamDomain($domain);
|
|
|
|
|
$this->xray();
|
|
|
|
@@ -5400,6 +5594,58 @@ DNS-over-HTTPS with IP:
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function changeTransport($ws = null)
|
|
|
|
|
{
|
|
|
|
|
$p = $this->getPacConf();
|
|
|
|
|
$x = $this->getXray();
|
|
|
|
|
$p['transport'] = $ws ? 'Websocket' : 'Reality';
|
|
|
|
|
if (!empty($ws)) {
|
|
|
|
|
$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']);
|
|
|
|
|
}
|
|
|
|
|
$x['inbounds'][0]['streamSettings'] = [
|
|
|
|
|
"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';
|
|
|
|
|
}
|
|
|
|
|
$x['inbounds'][0]['streamSettings'] = [
|
|
|
|
|
"network" => "tcp",
|
|
|
|
|
"realitySettings" => [
|
|
|
|
|
"dest" => $p['reality']['destination'] ?: $x['inbounds'][0]['streamSettings']['realitySettings']['dest'],
|
|
|
|
|
"maxClientVer" => "",
|
|
|
|
|
"maxTimeDiff" => 0,
|
|
|
|
|
"minClientVer" => "",
|
|
|
|
|
"privateKey" => $p['reality']['privateKey'],
|
|
|
|
|
"serverNames" => [
|
|
|
|
|
$p['reality']['domain'] ?: $x['inbounds'][0]['streamSettings']['realitySettings']['serverNames'][0]
|
|
|
|
|
],
|
|
|
|
|
"shortIds" => [$p['reality']['shortId']] ?: $x['inbounds'][0]['streamSettings']['realitySettings']['shortIds'][0],
|
|
|
|
|
"show" => false,
|
|
|
|
|
"xver" => 0
|
|
|
|
|
],
|
|
|
|
|
"tcpSettings" => [
|
|
|
|
|
"acceptProxyProtocol" => true
|
|
|
|
|
],
|
|
|
|
|
"sockopt" => [
|
|
|
|
|
"acceptProxyProtocol" => true
|
|
|
|
|
],
|
|
|
|
|
"security" => "reality"
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
$this->setUpstreamDomain($ws ? 't' : ($p['reality']['domain'] ?: $x['inbounds'][0]['streamSettings']['realitySettings']['serverNames'][0]));
|
|
|
|
|
$this->setPacConf($p);
|
|
|
|
|
$this->restartXray($x);
|
|
|
|
|
$this->xray();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function setBackup($text)
|
|
|
|
|
{
|
|
|
|
|
$text = trim($text);
|
|
|
|
@@ -5544,7 +5790,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";
|
|
|
|
@@ -5703,6 +5949,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']);
|
|
|
|
|