ip

package
v0.0.0-...-512269d Latest Latest
Warning

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

Go to latest
Published: May 29, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLocalIP

func GetLocalIP() (ip string, error error)

GetLocalIP 获取本机IP地址 本代码未考虑IPv6

func GetRequestIP

func GetRequestIP(r *http.Request) string

GetRequestIP 尽最大努力实现获取客户端 IP 的算法 解析 X-Real-IP 和 X-Forwarded-For 以便于反向代理(nginx 或 haproxy)可以正常工作

func InitIpLocator

func InitIpLocator(dbPath string)

InitIpLocator 使用时,需要加载xdb文件 github.com/lionsoul2014/ip2region/data/ip2region.xdb

func IpLocation

func IpLocation(ip string) string

func IsLocalIP

func IsLocalIP(ip net.IP) bool

IsLocalIP 判断是否是内网ip 关于内网地址的判断,请不要忽略IPv6的回环地址和IPv6的唯一本地地址 因为URL形式多样,可以使用DNS解析获取规范的IP,从而判断是否是内网资源。

func Search(ip string) string

Types

This section is empty.

Jump to

Keyboard shortcuts

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