Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMHSanaei <ho3ein.sanaei@gmail.com>2023-08-26 16:24:01 +0300
committerMHSanaei <ho3ein.sanaei@gmail.com>2023-08-26 16:24:01 +0300
commit1c1f53267ad65b11c849c1c339c78b8c6daf78cb (patch)
tree96657ca8414a83d74c6e385506c5bf266788e704
parent8489f5f528ea77fec9d6c2102251da9d16e95780 (diff)
Add encrypt subscription ON/OFF switch
Co-Authored-By: SudoSpace <79229394+sudospaes@users.noreply.github.com>
-rw-r--r--sub/subController.go7
-rw-r--r--web/assets/js/model/models.js1
-rw-r--r--web/controller/setting.go1
-rw-r--r--web/entity/entity.go1
-rw-r--r--web/html/xui/settings.html1
-rw-r--r--web/service/setting.go5
-rw-r--r--web/translation/translate.en_US.toml2
-rw-r--r--web/translation/translate.fa_IR.toml2
-rw-r--r--web/translation/translate.ru_RU.toml2
-rw-r--r--web/translation/translate.vi_VN.toml2
-rw-r--r--web/translation/translate.zh_Hans.toml2
11 files changed, 25 insertions, 1 deletions
diff --git a/sub/subController.go b/sub/subController.go
index b0e62ecf..5f7c69cf 100644
--- a/sub/subController.go
+++ b/sub/subController.go
@@ -26,6 +26,7 @@ func (a *SUBController) initRouter(g *gin.RouterGroup) {
}
func (a *SUBController) subs(c *gin.Context) {
+ subEncrypt, _ := a.settingService.GetSubEncrypt()
subShowInfo, _ := a.settingService.GetSubShowInfo()
subId := c.Param("subid")
host := strings.Split(c.Request.Host, ":")[0]
@@ -43,6 +44,10 @@ func (a *SUBController) subs(c *gin.Context) {
c.Writer.Header().Set("Profile-Update-Interval", headers[1])
c.Writer.Header().Set("Profile-Title", headers[2])
- c.String(200, base64.StdEncoding.EncodeToString([]byte(result)))
+ if subEncrypt {
+ c.String(200, base64.StdEncoding.EncodeToString([]byte(result)))
+ } else {
+ c.String(200, result)
+ }
}
}
diff --git a/web/assets/js/model/models.js b/web/assets/js/model/models.js
index 1accec71..122145fb 100644
--- a/web/assets/js/model/models.js
+++ b/web/assets/js/model/models.js
@@ -194,6 +194,7 @@ class AllSetting {
this.subCertFile = "";
this.subKeyFile = "";
this.subUpdates = 0;
+ this.subEncrypt = true;
this.subShowInfo = true;
this.timeLocation = "Asia/Tehran";
diff --git a/web/controller/setting.go b/web/controller/setting.go
index d991633a..32eccefe 100644
--- a/web/controller/setting.go
+++ b/web/controller/setting.go
@@ -79,6 +79,7 @@ func (a *SettingController) getDefaultSettings(c *gin.Context) {
"subDomain": func() (interface{}, error) { return a.settingService.GetSubDomain() },
"subKeyFile": func() (interface{}, error) { return a.settingService.GetSubKeyFile() },
"subCertFile": func() (interface{}, error) { return a.settingService.GetSubCertFile() },
+ "subEncrypt": func() (interface{}, error) { return a.settingService.GetSubEncrypt() },
"subShowInfo": func() (interface{}, error) { return a.settingService.GetSubShowInfo() },
}
diff --git a/web/entity/entity.go b/web/entity/entity.go
index 10a6a97d..1428abe0 100644
--- a/web/entity/entity.go
+++ b/web/entity/entity.go
@@ -55,6 +55,7 @@ type AllSetting struct {
SubCertFile string `json:"subCertFile" form:"subCertFile"`
SubKeyFile string `json:"subKeyFile" form:"subKeyFile"`
SubUpdates int `json:"subUpdates" form:"subUpdates"`
+ SubEncrypt bool `json:"subEncrypt" form:"subEncrypt"`
SubShowInfo bool `json:"subShowInfo" form:"subShowInfo"`
}
diff --git a/web/html/xui/settings.html b/web/html/xui/settings.html
index e1741302..b31ad04f 100644
--- a/web/html/xui/settings.html
+++ b/web/html/xui/settings.html
@@ -406,6 +406,7 @@
</a-row>
<a-list item-layout="horizontal" :style="themeSwitcher.textStyle">
<setting-list-item type="switch" title='{{ i18n "pages.settings.subEnable"}}' desc='{{ i18n "pages.settings.subEnableDesc"}}' v-model="allSetting.subEnable"></setting-list-item>
+ <setting-list-item type="switch" title='{{ i18n "pages.settings.subEncrypt"}}' desc='{{ i18n "pages.settings.subEncryptDesc"}}' v-model="allSetting.subEncrypt"></setting-list-item>
<setting-list-item type="switch" title='{{ i18n "pages.settings.subShowInfo"}}' desc='{{ i18n "pages.settings.subShowInfoDesc"}}' v-model="allSetting.subShowInfo"></setting-list-item>
<setting-list-item type="text" title='{{ i18n "pages.settings.subListen"}}' desc='{{ i18n "pages.settings.subListenDesc"}}' v-model="allSetting.subListen"></setting-list-item>
<setting-list-item type="text" title='{{ i18n "pages.settings.subDomain"}}' desc='{{ i18n "pages.settings.subDomainDesc"}}' v-model="allSetting.subDomain"></setting-list-item>
diff --git a/web/service/setting.go b/web/service/setting.go
index 6f38f1ef..b1565e1f 100644
--- a/web/service/setting.go
+++ b/web/service/setting.go
@@ -51,6 +51,7 @@ var defaultValueMap = map[string]string{
"subCertFile": "",
"subKeyFile": "",
"subUpdates": "12",
+ "subEncrypt": "true",
"subShowInfo": "true",
}
@@ -397,6 +398,10 @@ func (s *SettingService) GetSubUpdates() (int, error) {
return s.getInt("subUpdates")
}
+func (s *SettingService) GetSubEncrypt() (bool, error) {
+ return s.getBool("subEncrypt")
+}
+
func (s *SettingService) GetSubShowInfo() (bool, error) {
return s.getBool("subShowInfo")
}
diff --git a/web/translation/translate.en_US.toml b/web/translation/translate.en_US.toml
index 5ac63f57..edf5510d 100644
--- a/web/translation/translate.en_US.toml
+++ b/web/translation/translate.en_US.toml
@@ -274,6 +274,8 @@
"subDomainDesc" = "Leave blank by default to monitor all domains and IPs"
"subUpdates" = "Subscription update intervals"
"subUpdatesDesc" = "Interval hours between updates in client application"
+"subEncrypt" = "Encrypt configs"
+"subEncryptDesc" = "Encrypt the returned configs in subscription"
"subShowInfo" = "Show usage info"
"subShowInfoDesc" = "Show remianed traffic and date after config name"
diff --git a/web/translation/translate.fa_IR.toml b/web/translation/translate.fa_IR.toml
index a145965d..02862c2f 100644
--- a/web/translation/translate.fa_IR.toml
+++ b/web/translation/translate.fa_IR.toml
@@ -274,6 +274,8 @@
"subDomainDesc" = "برای نظارت بر همه دامنه ها و آی‌پی ها به طور پیش فرض خالی بگذارید"
"subUpdates" = "فاصله به روز رسانی های سابسکریپشن"
"subUpdatesDesc" = "ساعت های فاصله بین به روز رسانی در برنامه کاربر"
+"subEncrypt" = "رمزگذاری کانفیگ ها"
+"subEncryptDesc" = "رمزگذاری کانفیگ های بازگشتی سابسکریپشن"
"subShowInfo" = "نمایش اطلاعات مصرف"
"subShowInfoDesc" = "ترافیک و زمان باقیمانده را در هر کانفیگ نمایش میدهد"
diff --git a/web/translation/translate.ru_RU.toml b/web/translation/translate.ru_RU.toml
index 53b6fedd..8587a585 100644
--- a/web/translation/translate.ru_RU.toml
+++ b/web/translation/translate.ru_RU.toml
@@ -274,6 +274,8 @@
"subDomainDesc" = "Оставьте пустым по умолчанию, чтобы отслеживать все домены и IP-адреса"
"subUpdates" = "Интервалы обновления подписки"
"subUpdatesDesc" = "Часовой интервал между обновлениями в клиентском приложении"
+"subEncrypt" = "Шифровать конфиги"
+"subEncryptDesc" = "Шифровать возвращенные конфиги в подписке"
"subShowInfo" = "Показать информацию об использовании"
"subShowInfoDesc" = "Показывать восстановленный трафик и дату после имени конфигурации"
diff --git a/web/translation/translate.vi_VN.toml b/web/translation/translate.vi_VN.toml
index 8ea0bfd2..691804e9 100644
--- a/web/translation/translate.vi_VN.toml
+++ b/web/translation/translate.vi_VN.toml
@@ -274,6 +274,8 @@
"subDomainDesc" = "Mặc định để trống để nghe tất cả các tên miền và IP"
"subUpdates" = "Khoảng thời gian cập nhật đăng ký"
"subUpdatesDesc" = "Số giờ giữa các cập nhật trong ứng dụng khách"
+"subEncrypt" = "Mã hóa cấu hình"
+"subEncryptDesc" = "Mã hóa các cấu hình được trả về trong đăng ký"
"subShowInfo" = "Hiển thị thông tin sử dụng"
"subShowInfoDesc" = "Hiển thị lưu lượng truy cập còn lại và ngày sau tên cấu hình"
diff --git a/web/translation/translate.zh_Hans.toml b/web/translation/translate.zh_Hans.toml
index fa9b84a3..581e67ee 100644
--- a/web/translation/translate.zh_Hans.toml
+++ b/web/translation/translate.zh_Hans.toml
@@ -274,6 +274,8 @@
"subDomainDesc" = "留空默认监控所有域名和IP"
"subUpdates" = "订阅更新间隔"
"subUpdatesDesc" = "客户端应用程序更新之间的间隔时间"
+"subEncrypt" = "加密配置"
+"subEncryptDesc" = "在订阅中加密返回的配置"
"subShowInfo" = "显示使用信息"
"subShowInfoDesc" = "在配置名称后显示剩余流量和日期"