From 70f9e32f28b1f24f7a5c60f53941cde5ebfd3978 Mon Sep 17 00:00:00 2001 From: mhsanaei Date: Wed, 22 May 2024 17:12:37 +0200 Subject: [PATCH] new - Cert (TLS-XTLS) - oneTimeLoading , usage --- web/assets/js/model/xray.js | 39 ++++++++++++++++++++++++++--- web/html/xui/form/tls_settings.html | 19 ++++++++++++++ 2 files changed, 55 insertions(+), 3 deletions(-) diff --git a/web/assets/js/model/xray.js b/web/assets/js/model/xray.js index 988adabf..ec0b03e6 100644 --- a/web/assets/js/model/xray.js +++ b/web/assets/js/model/xray.js @@ -84,14 +84,22 @@ const SNIFFING_OPTION = { FAKEDNS: "fakedns" }; +const USAGE_OPTION = { + ENCIPHERMENT: "encipherment", + VERIFY: "verify", + ISSUE: "issue", +}; + Object.freeze(Protocols); Object.freeze(SSMethods); Object.freeze(XTLS_FLOW_CONTROL); Object.freeze(TLS_FLOW_CONTROL); Object.freeze(TLS_VERSION_OPTION); Object.freeze(TLS_CIPHER_OPTION); +Object.freeze(UTLS_FINGERPRINT); Object.freeze(ALPN_OPTION); Object.freeze(SNIFFING_OPTION); +Object.freeze(USAGE_OPTION); class XrayCommonClass { @@ -585,7 +593,7 @@ class TlsStreamSettings extends XrayCommonClass { } TlsStreamSettings.Cert = class extends XrayCommonClass { - constructor(useFile=true, certificateFile='', keyFile='', certificate='', key='', ocspStapling=3600) { + constructor(useFile=true, certificateFile='', keyFile='', certificate='', key='', ocspStapling=3600, oneTimeLoading=false, usage=USAGE_OPTION.ENCIPHERMENT) { super(); this.useFile = useFile; this.certFile = certificateFile; @@ -593,6 +601,8 @@ TlsStreamSettings.Cert = class extends XrayCommonClass { this.cert = certificate instanceof Array ? certificate.join('\n') : certificate; this.key = key instanceof Array ? key.join('\n') : key; this.ocspStapling = ocspStapling; + this.oneTimeLoading = oneTimeLoading; + this.usage = usage; } static fromJson(json={}) { @@ -602,6 +612,8 @@ TlsStreamSettings.Cert = class extends XrayCommonClass { json.certificateFile, json.keyFile, '', '', json.ocspStapling, + json.oneTimeLoading, + json.usage, ); } else { return new TlsStreamSettings.Cert( @@ -609,6 +621,8 @@ TlsStreamSettings.Cert = class extends XrayCommonClass { json.certificate.join('\n'), json.key.join('\n'), json.ocspStapling, + json.oneTimeLoading, + json.usage, ); } } @@ -619,12 +633,16 @@ TlsStreamSettings.Cert = class extends XrayCommonClass { certificateFile: this.certFile, keyFile: this.keyFile, ocspStapling: this.ocspStapling, + oneTimeLoading: this.oneTimeLoading, + usage: this.usage, }; } else { return { certificate: this.cert.split('\n'), key: this.key.split('\n'), ocspStapling: this.ocspStapling, + oneTimeLoading: this.oneTimeLoading, + usage: this.usage, }; } } @@ -698,13 +716,16 @@ class XtlsStreamSettings extends XrayCommonClass { } XtlsStreamSettings.Cert = class extends XrayCommonClass { - constructor(useFile=true, certificateFile='', keyFile='', certificate='', key='') { + constructor(useFile=true, certificateFile='', keyFile='', certificate='', key='', ocspStapling=3600, oneTimeLoading=false, usage=USAGE_OPTION.ENCIPHERMENT) { super(); this.useFile = useFile; this.certFile = certificateFile; this.keyFile = keyFile; this.cert = certificate instanceof Array ? certificate.join('\n') : certificate; this.key = key instanceof Array ? key.join('\n') : key; + this.ocspStapling = ocspStapling; + this.oneTimeLoading = oneTimeLoading; + this.usage = usage; } static fromJson(json={}) { @@ -712,13 +733,19 @@ XtlsStreamSettings.Cert = class extends XrayCommonClass { return new XtlsStreamSettings.Cert( true, json.certificateFile, - json.keyFile, + json.keyFile, '', '', + json.ocspStapling, + json.oneTimeLoading, + json.usage, ); } else { return new XtlsStreamSettings.Cert( false, '', '', json.certificate.join('\n'), json.key.join('\n'), + json.ocspStapling, + json.oneTimeLoading, + json.usage, ); } } @@ -728,11 +755,17 @@ XtlsStreamSettings.Cert = class extends XrayCommonClass { return { certificateFile: this.certFile, keyFile: this.keyFile, + ocspStapling: this.ocspStapling, + oneTimeLoading: this.oneTimeLoading, + usage: this.usage, }; } else { return { certificate: this.cert.split('\n'), key: this.key.split('\n'), + ocspStapling: this.ocspStapling, + oneTimeLoading: this.oneTimeLoading, + usage: this.usage, }; } } diff --git a/web/html/xui/form/tls_settings.html b/web/html/xui/form/tls_settings.html index cfbda0f2..e4edb756 100644 --- a/web/html/xui/form/tls_settings.html +++ b/web/html/xui/form/tls_settings.html @@ -90,6 +90,14 @@ + + + + + + [[ key ]] + + @@ -134,6 +142,17 @@ + + + + + + + + + [[ key ]] + +