From 3416cda8264992fd54e877e8a7e7f71e5ee78882 Mon Sep 17 00:00:00 2001 From: mercury Date: Sun, 25 Aug 2024 23:30:19 +0400 Subject: [PATCH 1/3] qr for singbox --- app/bot.php | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/app/bot.php b/app/bot.php index eafe572..1c7407b 100644 --- a/app/bot.php +++ b/app/bot.php @@ -353,8 +353,8 @@ class Bot case preg_match('~^/qrSS$~', $this->input['callback'], $m): $this->qrSS(); break; - case preg_match('~^/qrXray (\d+)$~', $this->input['callback'], $m): - $this->qrXray($m[1]); + case preg_match('~^/qrXray (\d+)(?:_(\d+))?$~', $this->input['callback'], $m): + $this->qrXray($m[1], $m[2] ?: false); break; case preg_match('~^/qrMtproto$~', $this->input['callback'], $m): $this->qrMtproto(); @@ -1604,9 +1604,9 @@ class Bot } } - public function qrXray($i) + public function qrXray($i, $s = false) { - $link = $this->linkXray($i); + $link = $this->linkXray($i, $s); $qr_file = __DIR__ . "/qr/xray.png"; exec("qrencode -t png -o $qr_file '$link'"); $r = $this->sendPhoto( @@ -3734,12 +3734,28 @@ DNS-over-HTTPS with IP: $this->answer($this->input['callback_id'], 'in developing...'); } - public function linkXray($i) + public function linkXray($i, $s = false) { $c = $this->getXray(); $pac = $this->getPacConf(); $domain = $pac['domain'] ?: $this->ip; - 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']}"; + $scheme = empty($this->nginxGetTypeCert()) ? 'http' : 'https'; + $hash = substr(md5($this->key), 0, 8); + $si = "$scheme://{$domain}/pac/" . base64_encode(serialize([ + 'h' => $hash, + 't' => 'si', + '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']}"; + case 2: + return "sing-box://import-remote-profile/?url={$si}#{$c['inbounds'][0]['settings']['clients'][$i]['email']}"; + + default: + 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']}"; + } } public function dockerApi($url, $method = 'GET', $data = []) @@ -4459,9 +4475,17 @@ DNS-over-HTTPS with IP: ]; $data[] = [ [ - 'text' => $this->i18n('show QR'), + 'text' => $this->i18n('qr short'), 'callback_data' => "/qrXray $i", ], + [ + 'text' => $this->i18n('qr v2ray'), + 'callback_data' => "/qrXray {$i}_1", + ], + [ + 'text' => $this->i18n('qr singbox'), + 'callback_data' => "/qrXray {$i}_2", + ], ]; $data[] = [ [ From 6bd21d06c0dd50704f2dcead2ed2350f2490ab43 Mon Sep 17 00:00:00 2001 From: mercury Date: Mon, 26 Aug 2024 23:19:31 +0400 Subject: [PATCH 2/3] fix list actions --- app/bot.php | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/app/bot.php b/app/bot.php index 1c7407b..b5c9f7b 100644 --- a/app/bot.php +++ b/app/bot.php @@ -3458,11 +3458,11 @@ DNS-over-HTTPS with IP: $data[] = [ [ 'text' => $this->i18n($v ? 'on' : 'off') . ' ' . ($basename ? basename($k) . ' ' : '') . idn_to_utf8($k), - 'callback_data' => "/change$type $i", + 'callback_data' => "/change$type " . ($i + $page * $this->limit), ], [ 'text' => 'delete', - 'callback_data' => "/delete$type $i", + 'callback_data' => "/delete$type " . ($i + $page * $this->limit), ], ]; $i++; @@ -3729,11 +3729,6 @@ DNS-over-HTTPS with IP: } } - public function geodb() - { - $this->answer($this->input['callback_id'], 'in developing...'); - } - public function linkXray($i, $s = false) { $c = $this->getXray(); @@ -3741,7 +3736,7 @@ DNS-over-HTTPS with IP: $domain = $pac['domain'] ?: $this->ip; $scheme = empty($this->nginxGetTypeCert()) ? 'http' : 'https'; $hash = substr(md5($this->key), 0, 8); - $si = "$scheme://{$domain}/pac/" . base64_encode(serialize([ + $si = "$scheme://{$domain}/pac/" . base64_encode(serialize([ 'h' => $hash, 't' => 'si', 's' => $c['inbounds'][0]['settings']['clients'][$i]['id'], From a82147eeda726b28816f4c8675224e6026cb7042 Mon Sep 17 00:00:00 2001 From: mercury Date: Mon, 26 Aug 2024 23:23:09 +0400 Subject: [PATCH 3/3] update version --- version | 3 +++ 1 file changed, 3 insertions(+) diff --git a/version b/version index 443673b..b7ec6fa 100644 --- a/version +++ b/version @@ -1,3 +1,6 @@ +26.08.2024 v1.44 +- qr для xtls +- фикс действий на элементом списков 21.08.2024 v1.43 - singbox:поддержка кастомных outbound для ruleset 16.08.2024 v1.42.1