mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-10-14 01:45:00 +03:00
fix(panel): default TLS ALPN to http/1.1 for WebSocket transport (#6787)
* fix(panel): default TLS ALPN to http/1.1 for WebSocket transport WebSocket bootstraps over HTTP/1.1: leaving ALPN at the schema default ['h2','http/1.1'] makes the server negotiate h2 and the WS handshake fails. See issue #6782. * style(frontend): keep comments within the two-line limit * style(frontend): keep comments within the two-line limit
This commit is contained in:
@@ -18,12 +18,16 @@ import {
|
||||
createDefaultVmessInboundSettings,
|
||||
createDefaultWireguardInboundSettings,
|
||||
} from '@/lib/xray/inbound-defaults';
|
||||
import { createHysteriaTlsSettingsWithDefaultCert } from '@/lib/xray/inbound-tls-defaults';
|
||||
import {
|
||||
createHysteriaTlsSettingsWithDefaultCert,
|
||||
createTlsSettingsWithDefaultCert,
|
||||
} from '@/lib/xray/inbound-tls-defaults';
|
||||
import { HttpInboundSettingsSchema } from '@/schemas/protocols/inbound/http';
|
||||
import {
|
||||
HysteriaClientSchema,
|
||||
HysteriaInboundSettingsSchema,
|
||||
} from '@/schemas/protocols/inbound/hysteria';
|
||||
import { TlsStreamSettingsSchema } from '@/schemas/protocols/security/tls';
|
||||
import { MixedInboundSettingsSchema } from '@/schemas/protocols/inbound/mixed';
|
||||
import {
|
||||
ShadowsocksClientSchema,
|
||||
@@ -234,3 +238,19 @@ describe('createHysteriaTlsSettingsWithDefaultCert', () => {
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('createTlsSettingsWithDefaultCert', () => {
|
||||
it('keeps the schema ALPN default for non-WebSocket transports', () => {
|
||||
for (const network of [undefined, '', 'tcp', 'kcp', 'grpc', 'httpupgrade', 'xhttp']) {
|
||||
const tls = createTlsSettingsWithDefaultCert(network);
|
||||
expect(tls.alpn).toEqual(['h2', 'http/1.1']);
|
||||
}
|
||||
});
|
||||
|
||||
it("defaults ALPN to http/1.1 for WebSocket (issue #6782)", () => {
|
||||
const tls = createTlsSettingsWithDefaultCert('ws');
|
||||
expect(tls.alpn).toEqual(['http/1.1']);
|
||||
// The overridden value must still satisfy the TLS settings schema.
|
||||
expect(TlsStreamSettingsSchema.parse(tls).alpn).toEqual(['http/1.1']);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user