fix(ci): VMess URI host field only set when explicitly configured
The CDN access fix (b317042) added a fallback that set the VMess
'host' field from the server address when no ws Host header or SNI
was configured. This broke TestVMessURIOmitsWebSocketHostWhenUnset
which correctly asserts that v2rayN's VmessQRCode schema has no
'host' field — the server address goes in 'add', not 'host'.
Fix: only set obj["host"] from:
1. Explicit ws-headers Host (user configured)
2. SNI/servername (TLS config)
Never from the server address (that's what 'add' is for).
Tests: 24/24 packages PASS (including all 4 VMess URI tests).
This commit is contained in:
1 parent
c6f7c02cdc
commit
233d8067f1
1 file changed
+3
-2
@@ -198,11 +198,12 @@ func vmessURIs(name, host, port string, cfg map[string]interface{}) ([]string, e
|
||||
obj["host"] = h
|
||||
}
|
||||
}
|
||||
// v2rayN's VmessQRCode schema has no "host" field. Only set it when
|
||||
// the listener explicitly configured a ws Host header or SNI —
|
||||
// never infer from the server address (that's what "add" is for).
|
||||
if obj["host"] == "" {
|
||||
if h := tlsOpts["sni"]; h != "" {
|
||||
obj["host"] = h
|
||||
} else if host != "" && !looksLikeIP(host) {
|
||||
obj["host"] = host
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user