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/middleware')
-rw-r--r--web/middleware/domainValidator.go16
1 files changed, 10 insertions, 6 deletions
diff --git a/web/middleware/domainValidator.go b/web/middleware/domainValidator.go
index 2beecfdb..26a23895 100644
--- a/web/middleware/domainValidator.go
+++ b/web/middleware/domainValidator.go
@@ -9,13 +9,17 @@ import (
func DomainValidatorMiddleware(domain string) gin.HandlerFunc {
return func(c *gin.Context) {
- host, _, _ := net.SplitHostPort(c.Request.Host)
-
- if host != domain {
- c.AbortWithStatus(http.StatusForbidden)
- return
+ host := c.GetHeader("X-Forwarded-Host")
+ if host == "" {
+ host = c.GetHeader("X-Real-IP")
}
-
+ if host == "" {
+ host, _, _ := net.SplitHostPort(c.Request.Host)
+ if host != domain {
+ c.AbortWithStatus(http.StatusForbidden)
+ return
+ }
c.Next()
+ }
}
}