exnet

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2021 License: MIT Imports: 5 Imported by: 32

Documentation

Overview

Package exnet 收集一些网络模块函数

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClientIP

func ClientIP(r *http.Request) string

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

func ClientPublicIP

func ClientPublicIP(r *http.Request) string

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

func HasLocalIP

func HasLocalIP(ip net.IP) bool

HasLocalIP 检测 IP 地址是否是内网地址 通过直接对比ip段范围效率更高,详见:https://github.com/thinkeridea/go-extend/issues/2

func HasLocalIPAddr added in v1.3.0

func HasLocalIPAddr(ip string) bool

HasLocalIPAddr 检测 IP 地址字符串是否是内网地址

func HasLocalIPddr

func HasLocalIPddr(ip string) bool

HasLocalIPddr 检测 IP 地址字符串是否是内网地址 Deprecated: 此为一个错误名称错误拼写的函数,计划在将来移除,请使用 HasLocalIPAddr 函数

func IP2Long

func IP2Long(ip net.IP) (uint, error)

IP2Long 把net.IP转为数值

func IPString2Long

func IPString2Long(ip string) (uint, error)

IPString2Long 把ip字符串转为数值

func Long2IP

func Long2IP(i uint) (net.IP, error)

Long2IP 把数值转为net.IP

func Long2IPString

func Long2IPString(i uint) (string, error)

Long2IPString 把数值转为ip字符串

func RemoteIP

func RemoteIP(r *http.Request) string

RemoteIP 通过 RemoteAddr 获取 IP 地址, 只是一个快速解析方法。

Types

This section is empty.

Directories

Path Synopsis
exhttp
expprof
Package expprof 这是从 net/http/pprof 包复制过来的,做了一些调整 我希望核心的逻辑不变,保持和标准库一致的功能,会调整使用的接口,使之易于控制。
Package expprof 这是从 net/http/pprof 包复制过来的,做了一些调整 我希望核心的逻辑不变,保持和标准库一致的功能,会调整使用的接口,使之易于控制。

Jump to

Keyboard shortcuts

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