From f5f90d81a3a0316eb787e2f23b5885e06a012a38 Mon Sep 17 00:00:00 2001 From: Alireza Ahmadi Date: Sun, 9 Apr 2023 12:58:11 +0200 Subject: [PATCH] [Feature] default cert from settings #155 --- web/controller/setting.go | 16 ++++++++++++++-- web/html/xui/form/tls_settings.html | 1 + web/html/xui/inbound_modal.html | 4 ++++ web/html/xui/inbounds.html | 12 ++++++++---- web/translation/translate.en_US.toml | 1 + web/translation/translate.fa_IR.toml | 1 + web/translation/translate.zh_Hans.toml | 1 + 7 files changed, 30 insertions(+), 6 deletions(-) diff --git a/web/controller/setting.go b/web/controller/setting.go index cfdfe5d6..261eeec8 100644 --- a/web/controller/setting.go +++ b/web/controller/setting.go @@ -33,7 +33,7 @@ func (a *SettingController) initRouter(g *gin.RouterGroup) { g = g.Group("/setting") g.POST("/all", a.getAllSetting) - g.POST("/thresholds", a.getThresholds) + g.POST("/defaultSettings", a.getDefaultSettings) g.POST("/update", a.updateSetting) g.POST("/updateUser", a.updateUser) g.POST("/restartPanel", a.restartPanel) @@ -48,7 +48,7 @@ func (a *SettingController) getAllSetting(c *gin.Context) { jsonObj(c, allSetting, nil) } -func (a *SettingController) getThresholds(c *gin.Context) { +func (a *SettingController) getDefaultSettings(c *gin.Context) { expireDiff, err := a.settingService.GetExpireDiff() if err != nil { jsonMsg(c, I18n(c, "pages.setting.toasts.getSetting"), err) @@ -59,9 +59,21 @@ func (a *SettingController) getThresholds(c *gin.Context) { jsonMsg(c, I18n(c, "pages.setting.toasts.getSetting"), err) return } + defaultCert, err := a.settingService.GetCertFile() + if err != nil { + jsonMsg(c, I18n(c, "pages.setting.toasts.getSetting"), err) + return + } + defaultKey, err := a.settingService.GetKeyFile() + if err != nil { + jsonMsg(c, I18n(c, "pages.setting.toasts.getSetting"), err) + return + } result := map[string]interface{}{ "expireDiff": expireDiff, "trafficDiff": trafficDiff, + "defaultCert": defaultCert, + "defaultKey": defaultKey, } jsonObj(c, result, nil) } diff --git a/web/html/xui/form/tls_settings.html b/web/html/xui/form/tls_settings.html index 16e94584..10b24aea 100644 --- a/web/html/xui/form/tls_settings.html +++ b/web/html/xui/form/tls_settings.html @@ -61,6 +61,7 @@ + {{ i18n "pages.inbounds.setDefaultCert" }}