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:
Diffstat (limited to 'web/service')
-rw-r--r--web/service/setting.go45
1 files changed, 26 insertions, 19 deletions
diff --git a/web/service/setting.go b/web/service/setting.go
index 89c78662..3c7b18fe 100644
--- a/web/service/setting.go
+++ b/web/service/setting.go
@@ -57,6 +57,9 @@ var defaultValueMap = map[string]string{
"subEncrypt": "true",
"subShowInfo": "true",
"subURI": "",
+ "subJsonPath": "/json/",
+ "subJsonURI": "",
+ "subJsonFragment": "",
"datepicker": "gregorian",
"warp": "",
}
@@ -387,17 +390,11 @@ func (s *SettingService) GetSubPort() (int, error) {
}
func (s *SettingService) GetSubPath() (string, error) {
- subPath, err := s.getString("subPath")
- if err != nil {
- return "", err
- }
- if !strings.HasPrefix(subPath, "/") {
- subPath = "/" + subPath
- }
- if !strings.HasSuffix(subPath, "/") {
- subPath += "/"
- }
- return subPath, nil
+ return s.getString("subPath")
+}
+
+func (s *SettingService) GetSubJsonPath() (string, error) {
+ return s.getString("subJsonPath")
}
func (s *SettingService) GetSubDomain() (string, error) {
@@ -412,8 +409,8 @@ func (s *SettingService) GetSubKeyFile() (string, error) {
return s.getString("subKeyFile")
}
-func (s *SettingService) GetSubUpdates() (int, error) {
- return s.getInt("subUpdates")
+func (s *SettingService) GetSubUpdates() (string, error) {
+ return s.getString("subUpdates")
}
func (s *SettingService) GetSubEncrypt() (bool, error) {
@@ -432,6 +429,14 @@ func (s *SettingService) GetSubURI() (string, error) {
return s.getString("subURI")
}
+func (s *SettingService) GetSubJsonURI() (string, error) {
+ return s.getString("subJsonURI")
+}
+
+func (s *SettingService) GetSubJsonFragment() (string, error) {
+ return s.getString("subJsonFragment")
+}
+
func (s *SettingService) GetDatepicker() (string, error) {
return s.getString("datepicker")
}
@@ -484,6 +489,7 @@ func (s *SettingService) GetDefaultSettings(host string) (interface{}, error) {
"tgBotEnable": func() (interface{}, error) { return s.GetTgbotenabled() },
"subEnable": func() (interface{}, error) { return s.GetSubEnable() },
"subURI": func() (interface{}, error) { return s.GetSubURI() },
+ "subJsonURI": func() (interface{}, error) { return s.GetSubJsonURI() },
"remarkModel": func() (interface{}, error) { return s.GetRemarkModel() },
"datepicker": func() (interface{}, error) { return s.GetDatepicker() },
}
@@ -498,10 +504,11 @@ func (s *SettingService) GetDefaultSettings(host string) (interface{}, error) {
result[key] = value
}
- if result["subEnable"].(bool) && result["subURI"].(string) == "" {
+ if result["subEnable"].(bool) && (result["subURI"].(string) == "" || result["subJsonURI"].(string) == "") {
subURI := ""
subPort, _ := s.GetSubPort()
subPath, _ := s.GetSubPath()
+ subJsonPath, _ := s.GetSubJsonPath()
subDomain, _ := s.GetSubDomain()
subKeyFile, _ := s.GetSubKeyFile()
subCertFile, _ := s.GetSubCertFile()
@@ -522,12 +529,12 @@ func (s *SettingService) GetDefaultSettings(host string) (interface{}, error) {
} else {
subURI += fmt.Sprintf("%s:%d", subDomain, subPort)
}
- if subPath[0] == byte('/') {
- subURI += subPath
- } else {
- subURI += "/" + subPath
+ if result["subURI"].(string) == "" {
+ result["subURI"] = subURI + subPath
+ }
+ if result["subJsonURI"].(string) == "" {
+ result["subJsonURI"] = subURI + subJsonPath
}
- result["subURI"] = subURI
}
return result, nil