fix ipv6 hostname #789

This commit is contained in:
Alireza Ahmadi
2025-09-09 22:30:07 +02:00
parent 6aba1354d5
commit 4aadee7ca0
2 changed files with 5 additions and 3 deletions
+4 -1
View File
@@ -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
}