Add to General: standard uri-scheme

This commit is contained in:
lotusproxy 2023-06-14 13:23:48 +00:00
parent 61f1d8a623
commit f1d55ae202
No known key found for this signature in database

View File

@ -33,6 +33,9 @@ class General
if ($item['type'] === 'trojan') {
$uri .= self::buildTrojan($user['uuid'], $item);
}
if ($item['type'] === 'hysteria') {
$uri .= self::buildHysteria($user['uuid'], $item);
}
}
return base64_encode($uri);
}
@ -110,4 +113,22 @@ class General
return $uri;
}
public static function buildHysteria($password, $server)
{
$name = rawurlencode($server['name']);
$query = http_build_query([
'protocol' => 'udp',
'auth' => $password,
'insecure' => $server['insecure'],
'peer' => $server['server_name'],
'upmbps' => $server['up_mbps'],
'downmbps' => $server['up_mbps'],
'alpn' => 'h3',
'obfsParam' => $server['server_key']
]);
$uri = "hysteria://{$server['host']}:{$server['port']}?{$query}#{$name}";
$uri .= "\r\n";
return $uri;
}
}