瀏覽代碼

Check existence of X-Forwarded-For by comparing the length

Manu Mtz-Almeida 12 年之前
父節點
當前提交
78c7101ff6
共有 1 個文件被更改,包括 2 次插入 和 2 次删除
  1. 2 2
      logger.go

+ 2 - 2
logger.go

@@ -44,12 +44,12 @@ func Logger() HandlerFunc {
 		// save the IP of the requester
 		requester := c.Request.Header.Get("X-Real-IP")
 		// if the requester-header is empty, check the forwarded-header
-		if requester == "" {
+		if len(requester) == 0 {
 			requester = c.Request.Header.Get("X-Forwarded-For")
 		}
 
 		// if the requester is still empty, use the hard-coded address from the socket
-		if requester == "" {
+		if len(requester) == 0 {
 			requester = c.Request.RemoteAddr
 		}