Skip to content

Commit

Permalink
fix v2ray links
Browse files Browse the repository at this point in the history
  • Loading branch information
mercurykd committed Sep 3, 2024
1 parent e3ddb64 commit c7cc0f3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
30 changes: 21 additions & 9 deletions app/bot.php
Original file line number Diff line number Diff line change
Expand Up @@ -3771,14 +3771,22 @@ public function linkXray($i, $s = false)
'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']}";
}
}
Expand Down Expand Up @@ -4469,16 +4477,16 @@ public function userXr($i)
$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>";
$text[] = "<a href='$scheme://{$domain}/pac?h=$hash&t=si&r=si&s={$c['id']}#{$c['email']}'>sing-box</a>";
$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[] = [
Expand Down Expand Up @@ -4620,19 +4628,23 @@ public function subscription()
'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');
Expand Down Expand Up @@ -5505,7 +5517,7 @@ public function changeTransport($ws = null)
$x = $this->getXray();
$p['transport'] = $ws ? 'Websocket' : 'Reality';
if (!empty($ws)) {
$this->setUpstreamDomain('');
$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];
Expand Down
2 changes: 2 additions & 0 deletions version
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
03.09.2024 v1.46.2
- fix link v2ray
03.09.2024 v1.46.1
- fix import
- fix websocket domain
Expand Down

0 comments on commit c7cc0f3

Please sign in to comment.