Documentation
¶
Index ¶
- func Addrs() ([]net.Addr, error)
- func ClientIP(r *http.Request) string
- func ClientPublicIP(r *http.Request) string
- func GlobalUnicastAddr(address net.Addr) (net.IP, int, error)
- func GlobalUnicastIPString() (string, error)
- func GlobalUnicastIPs() ([]net.IP, error)
- func IP2Long(ip net.IP) (uint, error)
- func IPString2Long(ip string) (uint, error)
- func IPs() ([]net.IP, error)
- func InterfaceIPs(name string) ([]net.IP, error)
- func InterfaceIPv4(name string) ([]net.IP, error)
- func IsGlobalUnicastIP(ip net.IP) bool
- 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
- func SplitHostPort(addr net.Addr) (net.IP, int, error)
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 ¶
ClientPublicIP 尽最大努力实现获取客户端公网 IP 的算法。 解析 X-Real-IP 和 X-Forwarded-For 以便于反向代理(nginx 或 haproxy)可以正常工作。
func GlobalUnicastIPString ¶
GlobalUnicastIPString get a global unicast IP address string
func GlobalUnicastIPs ¶
GlobalUnicastIPs returns a list of global unicast IPs for all interface.
func InterfaceIPs ¶
InterfaceIPs get public IP addresses by interface name
func InterfaceIPv4 ¶
InterfaceIPv4 get a public IPv4 address
func IsGlobalUnicastIP ¶
IsGlobalUnicastIP check whether the IP is a global unicast 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.