diff --git a/app/bot.php b/app/bot.php
index 9480a30..2610674 100644
--- a/app/bot.php
+++ b/app/bot.php
@@ -269,6 +269,9 @@ class Bot
case preg_match('~^/generateSecretXray$~', $this->input['callback'], $m):
$this->generateSecretXray();
break;
+ case preg_match('~^/changeFakeDomain$~', $this->input['callback'], $m):
+ $this->changeFakeDomain();
+ break;
case preg_match('~^/include (\d+)$~', $this->input['callback'], $m):
$this->include($m[1]);
break;
@@ -830,6 +833,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]);
}
// nginx
$out[] = 'reset nginx';
@@ -2535,13 +2539,14 @@ DNS-over-HTTPS with IP:
public function xray()
{
- $c = json_decode(file_get_contents('/config/xray.json'), true);
+ $c = $this->getXray();
$pac = $this->getPacConf();
$st = $this->ssh('pgrep xray', 'xr') ? 'on' : 'off';
$text[] = "Menu -> " . $this->i18n('xray') . "\n";
$text[] = "uuid: {$c['inbounds'][0]['settings']['clients'][0]['id']}";
$text[] = "shortId: {$c['inbounds'][0]['streamSettings']['realitySettings']['shortIds'][0]}";
$text[] = "pubkey: {$pac['xray']}";
+ $text[] = "fake domain: {$c['inbounds'][0]['streamSettings']['realitySettings']['serverNames'][0]}";
$text[] = "\nstatus: $st";
$data[] = [
@@ -2550,6 +2555,12 @@ DNS-over-HTTPS with IP:
'callback_data' => "/generateSecretXray",
],
];
+ $data[] = [
+ [
+ 'text' => $this->i18n('changeFakeDomain'),
+ 'callback_data' => "/changeFakeDomain",
+ ],
+ ];
$data[] = [
[
'text' => $this->i18n('back'),
@@ -2564,9 +2575,14 @@ DNS-over-HTTPS with IP:
);
}
+ public function getXray()
+ {
+ return json_decode(file_get_contents('/config/xray.json'), true);
+ }
+
public function generateSecretXray()
{
- $c = json_decode(file_get_contents('/config/xray.json'), true);
+ $c = $this->getXray();
$uuid = trim($this->ssh('xray uuid', 'xr'));
$shortId = trim($this->ssh('openssl rand -hex 8', 'xr'));
$keys = $this->ssh('xray x25519', 'xr');
@@ -2584,6 +2600,14 @@ DNS-over-HTTPS with IP:
$this->xray();
}
+ public function setUpstreamDomain($domain)
+ {
+ $nginx = file_get_contents('/config/upstream.conf');
+ $t = preg_replace('~#domain.+#domain~s', "#domain\n$domain reality;\n#domain", $nginx);
+ file_put_contents('/config/upstream.conf', $t);
+ $this->ssh("nginx -s reload 2>&1", 'up');
+ }
+
public function addWg($page)
{
$text = "Menu -> Wireguard -> Add peer\n\n";
@@ -2906,6 +2930,32 @@ DNS-over-HTTPS with IP:
];
}
+ public function changeFakeDomain()
+ {
+ $r = $this->send(
+ $this->input['chat'],
+ "@{$this->input['username']} enter domain",
+ $this->input['message_id'],
+ reply: 'enter domain',
+ );
+ $_SESSION['reply'][$r['result']['message_id']] = [
+ 'start_message' => $this->input['message_id'],
+ 'start_callback' => $this->input['callback_id'],
+ 'callback' => 'setFakeDomain',
+ 'args' => [],
+ ];
+ }
+
+ public function setFakeDomain($domain)
+ {
+ $c = $this->getXray();
+ $c['inbounds'][0]['streamSettings']['realitySettings']['serverNames'][0] = $domain;
+ $c['inbounds'][0]['streamSettings']['realitySettings']['dest'] = "$domain:443";
+ $this->restartXray($c);
+ $this->setUpstreamDomain($domain);
+ $this->xray();
+ }
+
public function setBackup($text)
{
$text = trim($text);
diff --git a/app/i18n.php b/app/i18n.php
index b1941e5..970cee8 100644
--- a/app/i18n.php
+++ b/app/i18n.php
@@ -261,4 +261,8 @@ $i = [
'en' => 'GeoIp/GeoSite',
'ru' => 'GeoIp/GeoSite',
],
+ 'changeFakeDomain' => [
+ 'en' => 'changeFakeDomain',
+ 'ru' => 'установить фейковый домен',
+ ],
];
diff --git a/docker-compose.yml b/docker-compose.yml
index 08335a4..8a54aa8 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -84,6 +84,7 @@ services:
- ./config/unit.json:/config/unit.json
- ./config/AdGuardHome.yaml:/config/AdGuardHome.yaml
- ./config/nginx.conf:/config/nginx.conf
+ - ./config/upstream.conf:/config/upstream.conf
- ./config/nginx_default.conf:/config/nginx_default.conf
- ./config/ssserver.json:/config/ssserver.json
- ./config/sslocal.json:/config/sslocal.json