fix ipv6 hostname #789
This commit is contained in:
+1
-2
@@ -7,7 +7,6 @@ import (
|
||||
"s-ui/service"
|
||||
"s-ui/util"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -86,7 +85,7 @@ func (a *ApiService) getData(c *gin.Context) (interface{}, error) {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
subURI, err := a.SettingService.GetFinalSubURI(strings.Split(c.Request.Host, ":")[0])
|
||||
subURI, err := a.SettingService.GetFinalSubURI(getHostname(c))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
+4
-1
@@ -29,8 +29,11 @@ func getRemoteIp(c *gin.Context) string {
|
||||
|
||||
func getHostname(c *gin.Context) string {
|
||||
host := c.Request.Host
|
||||
if colonIndex := strings.LastIndex(host, ":"); colonIndex != -1 {
|
||||
if strings.Contains(host, ":") {
|
||||
host, _, _ = net.SplitHostPort(c.Request.Host)
|
||||
if strings.Contains(host, ":") {
|
||||
host = "[" + host + "]"
|
||||
}
|
||||
}
|
||||
return host
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user