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/entity/entity.go')
-rw-r--r--web/entity/entity.go30
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
}