|
|
|
@@ -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');
|
|
|
|
|
}
|
|
|
|
@@ -4023,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);
|
|
|
|
@@ -4215,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[] = [
|
|
|
|
|
[
|
|
|
|
@@ -4682,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',
|
|
|
|
@@ -4696,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" => [
|
|
|
|
@@ -4734,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']);
|
|
|
|
@@ -4743,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';
|
|
|
|
@@ -4912,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);
|
|
|
|
|
}
|
|
|
|
@@ -5197,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') : '';
|
|
|
|
|
|
|
|
|
@@ -5209,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',
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
@@ -5517,10 +5533,9 @@ DNS-over-HTTPS with IP:
|
|
|
|
|
$x = $this->getXray();
|
|
|
|
|
$p['transport'] = $ws ? 'Websocket' : 'Reality';
|
|
|
|
|
if (!empty($ws)) {
|
|
|
|
|
$this->setUpstreamDomain('t');
|
|
|
|
|
$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']);
|
|
|
|
|
}
|
|
|
|
@@ -5528,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';
|
|
|
|
@@ -5537,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
|
|
|
|
|
],
|
|
|
|
@@ -5558,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();
|
|
|
|
|