realip

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2023 License: MIT Imports: 6 Imported by: 3

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 County added in v0.0.2

func County(c *atreugo.RequestCtx) string

Only works when using Cloudflare as CDN!

func FromRequest

func FromRequest(c *atreugo.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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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