From 6036c6e4e3da4d5e4bd5b76c231064e7c43a3bb2 Mon Sep 17 00:00:00 2001 From: Akiraka Date: Fri, 14 Apr 2023 19:07:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A5=E5=8F=97=E5=8F=82=E6=95=B0=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/ip.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/ip.go b/common/ip.go index ab341483..bc4d9ef4 100644 --- a/common/ip.go +++ b/common/ip.go @@ -8,7 +8,7 @@ import ( func GetClientIP(c *gin.Context) string { ClientIP := c.ClientIP() //fmt.Println("ClientIP:", ClientIP) - RemoteIP, _ := c.RemoteIP() + RemoteIP := c.RemoteIP() //fmt.Println("RemoteIP:", RemoteIP) ip := c.Request.Header.Get("X-Forwarded-For") if strings.Contains(ip, "127.0.0.1") || ip == "" { @@ -17,8 +17,8 @@ func GetClientIP(c *gin.Context) string { if ip == "" { ip = "127.0.0.1" } - if RemoteIP.String() != "127.0.0.1" { - ip = RemoteIP.String() + if RemoteIP != "127.0.0.1" { + ip = RemoteIP } if ClientIP != "127.0.0.1" { ip = ClientIP