Merge f1d55ae202db6d7be9b36349490a570d1c77f18f into 31c5cf1c2b404ddf8ae4fbf743182524f3869f64

This commit is contained in:
LotusLab 2023-08-02 17:51:33 +08:00 committed by GitHub
commit 5fd12f8e5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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;
}
}