realip

package module
v0.0.0-...-10c77f4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 16, 2020 License: MIT Imports: 4 Imported by: 0

README

RealIP [fasthttp]

GoDoc

Go package that can be used to get client's real public IP, which usually useful for logging HTTP server.

Feature
  • Follows the rule of X-Real-IP
  • Follows the rule of X-Forwarded-For
  • Exclude local or private address

Example

package main

import "github.com/krecu/fasthttp-realip"

func RealIpHandler(ctx *fasthttp.RequestCtx) {
	clientIP := realip.FromRequest(ctx)
	log.Println("GET / from", clientIP)
}

Developing

Commited code must pass:

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromHeader

func FromHeader(req fasthttp.Request) string

FromHeader return client's real public IP address from http request headers.

func FromRequest

func FromRequest(ctx *fasthttp.RequestCtx) string

FromRequest return client's real public IP address from http request headers.

func RealIP

func RealIP(ctx *fasthttp.RequestCtx) string

RealIP is depreciated, use FromRequest instead

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL