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
path: root/sub
diff options
context:
space:
mode:
authorHo3ein <ho3ein.sanaei@gmail.com>2023-05-31 09:17:02 +0300
committerGitHub <noreply@github.com>2023-05-31 09:17:02 +0300
commit94fad02737d82817ca69f1f05872b49e769a0cb4 (patch)
tree55e7ead217c5a3e82791c0edae6ad44de1ba524f /sub
parent8442836512d82b705e404bc1749e3000115ba550 (diff)
parentd694e6eafccad246c63264714897316f671d6428 (diff)
Merge pull request #545 from hamid-gh98/main
🔀 New Feature + Fix URLs + Some Improvements 🛠️🌐
Diffstat (limited to 'sub')
-rw-r--r--sub/sub.go19
1 files changed, 5 insertions, 14 deletions
diff --git a/sub/sub.go b/sub/sub.go
index f7353cc2..b642f7f2 100644
--- a/sub/sub.go
+++ b/sub/sub.go
@@ -7,10 +7,10 @@ import (
"net"
"net/http"
"strconv"
- "strings"
"x-ui/config"
"x-ui/logger"
"x-ui/util/common"
+ "x-ui/web/middleware"
"x-ui/web/network"
"x-ui/web/service"
@@ -58,18 +58,7 @@ func (s *Server) initRouter() (*gin.Engine, error) {
}
if subDomain != "" {
- validateDomain := func(c *gin.Context) {
- host := strings.Split(c.Request.Host, ":")[0]
-
- if host != subDomain {
- c.AbortWithStatus(http.StatusForbidden)
- return
- }
-
- c.Next()
- }
-
- engine.Use(validateDomain)
+ engine.Use(middleware.DomainValidatorMiddleware(subDomain))
}
g := engine.Group(subPath)
@@ -116,11 +105,13 @@ func (s *Server) Start() (err error) {
if err != nil {
return err
}
+
listenAddr := net.JoinHostPort(listen, strconv.Itoa(port))
listener, err := net.Listen("tcp", listenAddr)
if err != nil {
return err
}
+
if certFile != "" || keyFile != "" {
cert, err := tls.LoadX509KeyPair(certFile, keyFile)
if err != nil {
@@ -168,4 +159,4 @@ func (s *Server) Stop() error {
func (s *Server) GetCtx() context.Context {
return s.ctx
-} \ No newline at end of file
+}