Documentation ¶
Index ¶
- func ClientIP(r *http.Request) string
- func ClientPublicIP(r *http.Request) string
- func ExtractIP(addr net.Addr) net.IP
- func ExtractPort(addr net.Addr) int
- func GlobalUnicastIP() (net.IP, error)
- func GlobalUnicastIPString() (string, error)
- func IP2Long(ip net.IP) (uint, error)
- func IPString2Long(ip string) (uint, error)
- func IPs() []net.IP
- func InterfaceIPs(name string) ([]net.IP, error)
- func InterfaceIPv4(name string) (net.IP, error)
- func IsLocalIP(ip net.IP) bool
- func IsLocalIPAddr(ip string) bool
- func Long2IP(i uint) (net.IP, error)
- func Long2IPString(i uint) (string, error)
- func PickFreePort() (int, error)
- func RemoteIP(r *http.Request) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClientIP ¶
ClientIP 尽最大努力实现获取客户端 IP 的算法。 解析 X-Real-IP 和 X-Forwarded-For 以便于反向代理(nginx 或 haproxy)可以正常工作。
func ClientPublicIP ¶ added in v1.0.5
ClientPublicIP 尽最大努力实现获取客户端公网 IP 的算法。 解析 X-Real-IP 和 X-Forwarded-For 以便于反向代理(nginx 或 haproxy)可以正常工作。
func GlobalUnicastIP ¶
GlobalUnicastIP get a global unicast IP address
func GlobalUnicastIPString ¶
GlobalUnicastIPString get a global unicast IP address string
func IPString2Long ¶ added in v1.0.5
IPString2Long 把ip字符串转为数值
func InterfaceIPs ¶
InterfaceIPs get public IP addresses by interface name
func InterfaceIPv4 ¶
InterfaceIPv4 get a public IPv4 address
func IsLocalIPAddr ¶ added in v1.0.5
IsLocalIPAddr 检测 IP 地址字符串是否是内网地址
func Long2IPString ¶ added in v1.0.5
Long2IPString 把数值转为ip字符串
func PickFreePort ¶
PickFreePort automatically chose a free port and return it
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.