realip

package module
Version: v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2019 License: MIT Imports: 4 Imported by: 0

README

RealIP

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 "go.ajitem.com/realip"

func (h *Handler) ServeIndexPage(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
	clientIP := realip.FromRequest(r)
	log.Println("GET / from", clientIP)
}

Developing

Commited code must pass:

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromRequest

func FromRequest(r *http.Request) string

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

func RealIP deprecated

This function has been deprecated.
func RealIP(r *http.Request) string

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

Deprecated: Use FromRequest instead.

Types

This section is empty.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL