Skip to content

Commit

Permalink
Add encrypt subscription ON/OFF switch
Browse files Browse the repository at this point in the history
Co-Authored-By: SudoSpace <79229394+sudospaes@users.noreply.github.com>
  • Loading branch information
MHSanaei and sudospaes committed Aug 26, 2023
1 parent 8489f5f commit 1c1f532
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 1 deletion.
7 changes: 6 additions & 1 deletion sub/subController.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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)
}
}
}
1 change: 1 addition & 0 deletions web/assets/js/model/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ class AllSetting {
this.subCertFile = "";
this.subKeyFile = "";
this.subUpdates = 0;
this.subEncrypt = true;
this.subShowInfo = true;

this.timeLocation = "Asia/Tehran";
Expand Down
1 change: 1 addition & 0 deletions web/controller/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() },
}

Expand Down
1 change: 1 addition & 0 deletions web/entity/entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}

Expand Down
1 change: 1 addition & 0 deletions web/html/xui/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ <h2 class="alert-msg">
</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>
Expand Down
5 changes: 5 additions & 0 deletions web/service/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ var defaultValueMap = map[string]string{
"subCertFile": "",
"subKeyFile": "",
"subUpdates": "12",
"subEncrypt": "true",
"subShowInfo": "true",
}

Expand Down Expand Up @@ -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")
}
Expand Down
2 changes: 2 additions & 0 deletions web/translation/translate.en_US.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 2 additions & 0 deletions web/translation/translate.fa_IR.toml
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,8 @@
"subDomainDesc" = "برای نظارت بر همه دامنه ها و آی‌پی ها به طور پیش فرض خالی بگذارید"
"subUpdates" = "فاصله به روز رسانی های سابسکریپشن"
"subUpdatesDesc" = "ساعت های فاصله بین به روز رسانی در برنامه کاربر"
"subEncrypt" = "رمزگذاری کانفیگ ها"
"subEncryptDesc" = "رمزگذاری کانفیگ های بازگشتی سابسکریپشن"
"subShowInfo" = "نمایش اطلاعات مصرف"
"subShowInfoDesc" = "ترافیک و زمان باقیمانده را در هر کانفیگ نمایش میدهد"

Expand Down
2 changes: 2 additions & 0 deletions web/translation/translate.ru_RU.toml
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,8 @@
"subDomainDesc" = "Оставьте пустым по умолчанию, чтобы отслеживать все домены и IP-адреса"
"subUpdates" = "Интервалы обновления подписки"
"subUpdatesDesc" = "Часовой интервал между обновлениями в клиентском приложении"
"subEncrypt" = "Шифровать конфиги"
"subEncryptDesc" = "Шифровать возвращенные конфиги в подписке"
"subShowInfo" = "Показать информацию об использовании"
"subShowInfoDesc" = "Показывать восстановленный трафик и дату после имени конфигурации"

Expand Down
2 changes: 2 additions & 0 deletions web/translation/translate.vi_VN.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 2 additions & 0 deletions web/translation/translate.zh_Hans.toml
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,8 @@
"subDomainDesc" = "留空默认监控所有域名和IP"
"subUpdates" = "订阅更新间隔"
"subUpdatesDesc" = "客户端应用程序更新之间的间隔时间"
"subEncrypt" = "加密配置"
"subEncryptDesc" = "在订阅中加密返回的配置"
"subShowInfo" = "显示使用信息"
"subShowInfoDesc" = "在配置名称后显示剩余流量和日期"

Expand Down

0 comments on commit 1c1f532

Please sign in to comment.