quantumultx: fix wss

This commit is contained in:
Tokumeikoi 2020-07-25 15:34:25 +08:00
parent fb732a8307
commit 1b4d03044d

View File

@ -7,26 +7,43 @@ class QuantumultX
{ {
public static function buildVmess($uuid, $server) public static function buildVmess($uuid, $server)
{ {
$uri = "vmess=" . $server->host . ":" . $server->port . ", method=none, password=" . $uuid . ", fast-open=false, udp-relay=false, tag=" . $server->name; $config = [
if ($server->tls) { "vmess={$server->host}:{$server->port}",
$tlsSettings = json_decode($server->tlsSettings); "method=chacha20-poly1305",
if ($server->network === 'tcp') $uri .= ', obfs=over-tls'; "password={$uuid}",
if (isset($tlsSettings->allowInsecure)) { "tag={$server->name}"
// Default: tls-verification=true ];
$uri .= ', tls-verification=' . ($tlsSettings->allowInsecure ? "false" : "true"); if ($server->network === 'tcp') {
} if ($server->tls) {
if (isset($tlsSettings->serverName)) { $tlsSettings = json_decode($server->tlsSettings);
$uri .= ', obfs-host=' . $tlsSettings->serverName; array_push($config, 'obfs=over-tls');
if (isset($tlsSettings->allowInsecure)) {
array_push($config, $server->allow_insecure ? 'tls-verification=true' : 'tls-verification=false');
}
if (isset($tlsSettings->serverName)) {
array_push($config, "obfs-host={$tlsSettings->serverName}");
}
} }
} }
if ($server->network === 'ws') { if ($server->network === 'ws') {
$uri .= ', obfs=' . ($server->tls ? 'wss' : 'ws'); if ($server->tls) {
$tlsSettings = json_decode($server->tlsSettings);
array_push($config, 'obfs=wss');
if (isset($tlsSettings->allowInsecure)) {
array_push($config, $server->allow_insecure ? 'tls-verification=true' : 'tls-verification=false');
}
} else {
array_push($config, 'obfs=ws');
}
if ($server->networkSettings) { if ($server->networkSettings) {
$wsSettings = json_decode($server->networkSettings); $wsSettings = json_decode($server->networkSettings);
if (isset($wsSettings->path)) $uri .= ', obfs-uri=' . $wsSettings->path; if (isset($wsSettings->path)) array_push($config, "obfs-uri={$wsSettings->path}");
if (isset($wsSettings->headers->Host)) $uri .= ', obfs-host=' . $wsSettings->headers->Host; if (isset($wsSettings->headers->Host)) array_push($config, "obfs-host={$wsSettings->headers->Host}");
} }
} }
$uri = implode($config, ',');
$uri .= "\r\n"; $uri .= "\r\n";
return $uri; return $uri;
} }