From 9d6ff7803afee0d544f0e99f73131c521e84cc0e Mon Sep 17 00:00:00 2001 From: George Shammas Date: Tue, 19 Jul 2016 23:00:05 +0000 Subject: [PATCH] Allow the use of cloudflare IP --- main.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/main.go b/main.go index 563b738..0a3f842 100644 --- a/main.go +++ b/main.go @@ -25,6 +25,10 @@ func Logger() gin.HandlerFunc { if err != nil { c.Abort() } + cfIP := net.ParseIP(c.Request.Header.Get("CF-Connecting-IP")) + if cfIP != nil { + ip.IP = cfIP + } // before request c.Next()