小火箭hy2订阅

This commit is contained in:
root 2023-10-01 19:51:40 +09:00
parent 21c03fc1e1
commit 53106a5f8a

View File

@ -41,6 +41,9 @@ class Shadowrocket
if ($item['type'] === 'trojan') { if ($item['type'] === 'trojan') {
$uri .= self::buildTrojan($user['uuid'], $item); $uri .= self::buildTrojan($user['uuid'], $item);
} }
if ($item['type'] === 'hysteria') {
$uri .= self::buildHysteria($user['uuid'], $item);
}
} }
return base64_encode($uri); return base64_encode($uri);
} }
@ -122,7 +125,7 @@ class Shadowrocket
$uri .= "\r\n"; $uri .= "\r\n";
return $uri; return $uri;
} }
public static function buildVless($uuid, $server) public static function buildVless($uuid, $server)
{ {
$config = [ $config = [
@ -216,4 +219,33 @@ class Shadowrocket
$uri .= "\r\n"; $uri .= "\r\n";
return $uri; return $uri;
} }
public static function buildHysteria($password, $server)
{
$remote = filter_var($server['host'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) ? '[' . $server['host'] . ']' : $server['host'];
$name = Helper::encodeURIComponent($server['name']);
if ($server['version'] == 2) {
$uri = "hysteria2://{$password}@{$remote}:{$server['port']}/?insecure={$server['insecure']}&sni={$server['server_name']}";
if (isset($server['obfs']) && isset($server['obfs_password'])) {
$uri .= "&obfs={$server['obfs']}&obfs-password={$server['obfs_password']}";
}
} else {
$uri = "hysteria://{$remote}:{$server['port']}/?";
$query = http_build_query([
'protocol' => 'udp',
'auth' => $password,
'insecure' => $server['insecure'],
'peer' => $server['server_name']
//'upmbps' => $server['up_mbps'],
//'downmbps' => $server['up_mbps']
]);
$uri .= $query;
if (isset($server['obfs']) && isset($server['obfs_password'])) {
$uri .= "&obfs={$server['obfs']}&obfsParam{$server['obfs_password']}";
}
}
$uri .= "#{$name}\r\n";
return $uri;
}
} }