Compare commits

...

3 Commits

Author SHA1 Message Date
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 44 additions and 7 deletions
+39 -7
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,9 @@ 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']}" : '';
$custom = $conf['subdomain'] ? "-d {$conf['subdomain']}.{$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 $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 +2057,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'] = $text;
$this->setPacConf($c);
$this->menu('config');
}
public function enterPage()
{
$r = $this->send(
@@ -3683,7 +3710,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'),
@@ -5159,7 +5186,7 @@ DNS-over-HTTPS with IP:
{
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');
$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');
$ssl = $this->expireCert();
$text[] = $conf['domain'] ? "\nSSL: " . ($ssl ? date('Y-m-d H:i:s', $this->expireCert()) : 'none') : '';
@@ -5169,6 +5196,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') . ($conf['subdomain'] ? ": {$conf['subdomain']}" : ''),
'callback_data' => '/addSubdomain',
],
],
];
if ($conf['domain']) {
@@ -5474,6 +5505,7 @@ 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];
+5
View File
@@ -1,3 +1,8 @@
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