realip

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2021 License: MIT Imports: 5 Imported by: 0

README

FastHTTP RealIP

Go package that can be used to get client's real public IP from Fast HTTP request.

License Build

Example

package main

import (
    "log"
    "github.com/valyala/fasthttp"
    "github.com/zhooravell/fasthttp-realip"
)

func main() {
	if err := fasthttp.ListenAndServe(":8080", requestHandler); err != nil {
		log.Fatalf("Error in ListenAndServe: %s", err)
	}
}

func requestHandler(ctx *fasthttp.RequestCtx) {
    log.Println("Client IP: " + realip.FromRequest(ctx))
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromRequest

func FromRequest(ctx *fasthttp.RequestCtx) string

func IsIPv6

func IsIPv6(ip net.IP) bool

func IsPrivateIp

func IsPrivateIp(ip net.IP) bool

IsPrivateIp test is IP local (private)

func IsStringIPv6

func IsStringIPv6(ip string) bool

Types

This section is empty.

Jump to

Keyboard shortcuts

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