From 18617afd43fd8e1734053bb867234018cd361503 Mon Sep 17 00:00:00 2001
From: MHSanaei <ho3ein.sanaei@gmail.com>
Date: Sat, 26 Aug 2023 18:52:38 +0330
Subject: [PATCH] add tls ocspStapling

Co-Authored-By: Alireza Ahmadi <alireza7@gmail.com>
---
 web/assets/js/model/xray.js         | 11 ++++++++---
 web/html/xui/form/tls_settings.html |  4 ++++
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/web/assets/js/model/xray.js b/web/assets/js/model/xray.js
index ccf9505e..9027e6b7 100644
--- a/web/assets/js/model/xray.js
+++ b/web/assets/js/model/xray.js
@@ -541,13 +541,14 @@ class TlsStreamSettings extends XrayCommonClass {
 }
 
 TlsStreamSettings.Cert = class extends XrayCommonClass {
-    constructor(useFile=true, certificateFile='', keyFile='', certificate='', key='') {
+    constructor(useFile=true, certificateFile='', keyFile='', certificate='', key='', ocspStapling=3600) {
         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;
     }
 
     static fromJson(json={}) {
@@ -555,13 +556,15 @@ TlsStreamSettings.Cert = class extends XrayCommonClass {
             return new TlsStreamSettings.Cert(
                 true,
                 json.certificateFile,
-                json.keyFile,
+                json.keyFile, '', '',
+                json.ocspStapling,
             );
         } else {
             return new TlsStreamSettings.Cert(
                 false, '', '',
                 json.certificate.join('\n'),
                 json.key.join('\n'),
+                json.ocspStapling,
             );
         }
     }
@@ -571,11 +574,13 @@ TlsStreamSettings.Cert = class extends XrayCommonClass {
             return {
                 certificateFile: this.certFile,
                 keyFile: this.keyFile,
+                ocspStapling: this.ocspStapling,
             };
         } else {
             return {
                 certificate: this.cert.split('\n'),
                 key: this.key.split('\n'),
+                ocspStapling: this.ocspStapling,
             };
         }
     }
@@ -1104,7 +1109,7 @@ class Inbound extends XrayCommonClass {
         } else if (this.isWs) {
             return this.stream.ws.path;
         } else if (this.isH2) {
-            return this.stream.http.path[0];
+            return this.stream.http.path;
         }
         return null;
     }
diff --git a/web/html/xui/form/tls_settings.html b/web/html/xui/form/tls_settings.html
index 28f61916..ce3e0fe4 100644
--- a/web/html/xui/form/tls_settings.html
+++ b/web/html/xui/form/tls_settings.html
@@ -122,6 +122,10 @@
                 <a-input type="textarea" :rows="3" style="width:300px;" v-model="cert.key"></a-input>
             </a-form-item>
         </template>
+        <br>
+        <a-form-item label="ocspStapling">
+            <a-input-number v-model.number="cert.ocspStapling" :min="0"></a-input-number>
+        </a-form-item>
     </template>
 </a-form>