diff options
| author | MHSanaei <ho3ein.sanaei@gmail.com> | 2023-05-22 17:36:34 +0300 |
|---|---|---|
| committer | MHSanaei <ho3ein.sanaei@gmail.com> | 2023-05-22 17:36:34 +0300 |
| commit | 769590d77993d8c26bfb9d056cb94d870cf6c745 (patch) | |
| tree | fb876b5b9d7eef99e814ebd9be94de8046334e3c /web/entity | |
| parent | 1fa9101b405ad1ba0127317ea4f8a151048b97ee (diff) | |
[feature] separate subscription service
Co-Authored-By: Alireza Ahmadi <alireza7@gmail.com>
Diffstat (limited to 'web/entity')
| -rw-r--r-- | web/entity/entity.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/web/entity/entity.go b/web/entity/entity.go index 52f26769..0bfbfd2a 100644 --- a/web/entity/entity.go +++ b/web/entity/entity.go @@ -45,6 +45,14 @@ type AllSetting struct { XrayTemplateConfig string `json:"xrayTemplateConfig" form:"xrayTemplateConfig"` TimeLocation string `json:"timeLocation" form:"timeLocation"` SecretEnable bool `json:"secretEnable" form:"secretEnable"` + SubEnable bool `json:"subEnable" form:"subEnable"` + SubListen string `json:"subListen" form:"subListen"` + SubPort int `json:"subPort" form:"subPort"` + SubPath string `json:"subPath" form:"subPath"` + SubDomain string `json:"subDomain" form:"subDomain"` + SubCertFile string `json:"subCertFile" form:"subCertFile"` + SubKeyFile string `json:"subKeyFile" form:"subKeyFile"` + SubUpdates int `json:"subUpdates" form:"subUpdates"` } func (s *AllSetting) CheckValid() error { @@ -55,10 +63,25 @@ func (s *AllSetting) CheckValid() error { } } + if s.SubListen != "" { + ip := net.ParseIP(s.SubListen) + if ip == nil { + return common.NewError("Sub listen is not valid ip:", s.SubListen) + } + } + if s.WebPort <= 0 || s.WebPort > 65535 { return common.NewError("web port is not a valid port:", s.WebPort) } + if s.SubPort <= 0 || s.SubPort > 65535 { + return common.NewError("Sub port is not a valid port:", s.SubPort) + } + + if s.SubPort == s.WebPort { + return common.NewError("Sub and Web could not use same port:", s.SubPort) + } + if s.WebCertFile != "" || s.WebKeyFile != "" { _, err := tls.LoadX509KeyPair(s.WebCertFile, s.WebKeyFile) if err != nil { @@ -66,6 +89,13 @@ func (s *AllSetting) CheckValid() error { } } + if s.SubCertFile != "" || s.SubKeyFile != "" { + _, err := tls.LoadX509KeyPair(s.SubCertFile, s.SubKeyFile) + if err != nil { + return common.NewErrorf("cert file <%v> or key file <%v> invalid: %v", s.SubCertFile, s.SubKeyFile, err) + } + } + if !strings.HasPrefix(s.WebBasePath, "/") { s.WebBasePath = "/" + s.WebBasePath } |
