mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-07-17 18:16:08 +00:00
fix: default hysteria tls to no utls fingerprint
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import { TlsStreamSettingsSchema } from '@/schemas/protocols/security/tls';
|
||||
|
||||
function defaultCertificate(): Record<string, unknown> {
|
||||
return {
|
||||
useFile: true,
|
||||
certificateFile: '',
|
||||
keyFile: '',
|
||||
certificate: [],
|
||||
key: [],
|
||||
ocspStapling: 3600,
|
||||
oneTimeLoading: false,
|
||||
usage: 'encipherment',
|
||||
buildChain: false,
|
||||
};
|
||||
}
|
||||
|
||||
export function createTlsSettingsWithDefaultCert(): Record<string, unknown> {
|
||||
const tls = TlsStreamSettingsSchema.parse({}) as Record<string, unknown>;
|
||||
tls.certificates = [defaultCertificate()];
|
||||
return tls;
|
||||
}
|
||||
|
||||
export function createHysteriaTlsSettingsWithDefaultCert(): Record<string, unknown> {
|
||||
const tls = createTlsSettingsWithDefaultCert();
|
||||
tls.alpn = ['h3'];
|
||||
|
||||
const settings = tls.settings && typeof tls.settings === 'object' && !Array.isArray(tls.settings)
|
||||
? { ...(tls.settings as Record<string, unknown>) }
|
||||
: {};
|
||||
settings.fingerprint = '';
|
||||
tls.settings = settings;
|
||||
|
||||
return tls;
|
||||
}
|
||||
@@ -95,6 +95,20 @@ function dropZeroNumbers(obj: Record<string, unknown>, keys: readonly string[]):
|
||||
}
|
||||
}
|
||||
|
||||
function normalizeTlsForWire(raw: Record<string, unknown>): Record<string, unknown> {
|
||||
const out: Record<string, unknown> = { ...raw };
|
||||
if (out.fingerprint === '') delete out.fingerprint;
|
||||
|
||||
const settings = out.settings;
|
||||
if (isRecord(settings)) {
|
||||
const settingsOut: Record<string, unknown> = { ...settings };
|
||||
if (settingsOut.fingerprint === '') delete settingsOut.fingerprint;
|
||||
out.settings = settingsOut;
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
export function normalizeXhttpForWire(
|
||||
raw: Record<string, unknown>,
|
||||
side: StreamWireSide,
|
||||
@@ -211,6 +225,11 @@ export function normalizeStreamSettingsForWire(
|
||||
out.xhttpSettings = normalizeXhttpForWire(xhttp, opts.side);
|
||||
}
|
||||
|
||||
const tls = out.tlsSettings;
|
||||
if (isRecord(tls)) {
|
||||
out.tlsSettings = normalizeTlsForWire(tls);
|
||||
}
|
||||
|
||||
const sockopt = out.sockopt;
|
||||
if (isRecord(sockopt)) {
|
||||
const normalized = normalizeSockoptForWire(sockopt);
|
||||
|
||||
Reference in New Issue
Block a user