mirror of
https://github.com/alireza0/x-ui.git
synced 2026-03-14 05:23:09 +00:00
Ensure IPv6 compliant host (#1252)
* Ensure IPv6 compliant host in sub/subController * Ensure IPv6 compliant host in web/controller/util * Ensure IPv6 compliant host in web/middleware/domainValidator
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"net"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func DomainValidatorMiddleware(domain string) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
host := strings.Split(c.Request.Host, ":")[0]
|
||||
host, _, _ := net.SplitHostPort(c.Request.Host)
|
||||
|
||||
if host != domain {
|
||||
c.AbortWithStatus(http.StatusForbidden)
|
||||
|
||||
Reference in New Issue
Block a user