Go package that can be used to get client's real public IP, which usually useful for logging HTTP server.
- Follows the rule of X-Real-IP
- Follows the rule of X-Forwarded-For
- Exclude local or private address
package main
import "github.com/krecu/fasthttp-realip"
func RealIpHandler(ctx *fasthttp.RequestCtx) {
clientIP := realip.FromRequest(ctx)
log.Println("GET / from", clientIP)
}
Commited code must pass: