Documentation ¶
Index ¶
- Variables
- func CheckIP(ip []byte) bool
- func CheckPort(port int) bool
- func GetLocalAddress(iterfaceName string) (addr *net.IP, err error)
- func GetPid(addr int64) (pid string, err error)
- func GetSocketId(port string) (SocketId string, err error)
- func Icmp(addr net.IPAddr, opts ...ss)
- func ListenTcp(host string, portRange string) (net.Listener, error)
- func ListenTcpWithAll(portRange string) (net.Listener, error)
- func ListenTcpWithLoop(portRange string) (net.Listener, error)
- func ParseHttpHeadString(text string) map[string][]string
- func ParseIfaceAddrs(addr []net.Addr) (ipv4 *net.IPNet, ipv6 *net.IPNet, err error)
- func ParseIfaceAddrsOfIpv4(addr []net.Addr) (ipv4 *net.IPNet, err error)
- func ParseIfaceAddrsOfIpv6(addr []net.Addr) (ipv6 *net.IPNet, err error)
- func ParsePort(ports string) (uint16, error)
- func ParsePortRange(portRange string) (portsFunc portsFunc, err error)
- func PasrseTcpAddr(addr *net.TCPAddr) (ipv4 []byte, port int, err error)
- func RouteInterfaces() ([]*net.Interface, error)
- type Flag
- type HostAddr
- type IcmpOptions
- type IcmpRequest
- type IcmpResp
- type Iface
- type RouteInfo
- type RouteInfos
Constants ¶
This section is empty.
Variables ¶
View Source
var (
EmptyErr = fmt.Errorf("empty routeInfo result")
)
View Source
var (
EmptyInterface = []*net.Interface{}
)
View Source
var (
ErrLog io.Writer
)
View Source
var (
InvlidHostError = fmt.Errorf("invlid host")
)
Functions ¶
func GetLocalAddress ¶ added in v0.0.2
func GetSocketId ¶ added in v0.0.6
func ListenTcpWithAll ¶ added in v0.0.10
like xxnet.ListenTcp("0.0.0.0",portRange)
func ListenTcpWithLoop ¶ added in v0.0.10
like xxnet.ListenTcp("127.0.0.1",portRange)
func ParseHttpHeadString ¶ added in v0.0.2
func ParseIfaceAddrs ¶ added in v0.0.8
转换 net.Interface 系列api返回的 的接口下的ip列表为对应的网络ip结构体
func ParseIfaceAddrsOfIpv4 ¶ added in v0.0.8
func ParseIfaceAddrsOfIpv6 ¶ added in v0.0.8
func ParsePortRange ¶ added in v0.0.10
解析一个端口范围
func RouteInterfaces ¶ added in v0.0.8
获取当前本机网卡(包含物理网卡,虚拟网桥)具有静态路由的ip地址列表,
Types ¶
type Flag ¶ added in v0.0.8
type Flag uint16
const ( Flag_Up Flag = 1 << iota // U (route is up) Flag_Host // H (target is a host) Flag_Gateway // G (use gateway) Flag_R // R (reinstate route for dynamic routing) Flag_D // D (dynamically installed by daemon or redirect) Flag_M // M (modified from routing daemon or redirect) Flag_A // A (installed by addrconf) Flag_Cache // C (cache entry) Flag_Reject // ! (reject route) )
type HostAddr ¶ added in v0.0.2
func ParseHostAddr ¶ added in v0.0.2
type IcmpOptions ¶ added in v0.0.2
type IcmpOptions struct {
// contains filtered or unexported fields
}
func (*IcmpOptions) WithTimeout ¶ added in v0.0.2
func (i *IcmpOptions) WithTimeout(d time.Duration) ss
type IcmpRequest ¶ added in v0.0.2
type RouteInfo ¶ added in v0.0.8
type RouteInfo struct { Destination net.IP // 目标 The destination network or destination host. Gateway net.IP // 网关 The gateway address or '*' if none set Genmask net.IP // 子网掩码 The netmask for the destination net; '255.255.255.255' for a host destination and '0.0.0.0' for the default route. Flags Flag // 标志 Possible flags see Flag Metric int32 // 跃点 The 'distance' to the target (usually counted in hops). Ref int16 // 引用 Number of references to this route. (Not used in the Linux kernel.) Use int16 // 使用 Count of lookups for the route. Depending on the use of -F and -C this will be either routecache misses (-F) or hits (-C). NetInterface net.Interface Iface string // 接口 Interface to which packets for this route will be sent. MSS int16 // Default maximum segment size for TCP connections over this route. Window int16 // Default window size for TCP connections over this route. Irtt int16 // Initial RTT (Round Trip Time). The kernel uses this to guess about the best TCP protocolparameters without waiting on (possibly slow) answers. // contains filtered or unexported fields }
func FlushRouteInfoCache ¶ added in v0.0.8
todo 得到在系统网卡状态变化的事件,自动刷新
func GetCacheRouteInfo ¶ added in v0.0.8
优先获取当前缓存的.路由结果集, 如果结果集为空,则返回 错误
func GetDefalutRouteInfo ¶ added in v0.0.8
获取当前默认路由所在的网络ip,如果有多个,则按照 Metric值,优先获取值小的
func MustGetDefalutRouteInfo ¶ added in v0.0.8
func MustGetDefalutRouteInfo() RouteInfo
func ObtainRouteInfo ¶ added in v0.0.8
func (RouteInfo) GetIfaceIpv4 ¶ added in v0.0.8
获取当前路由信息的本地网卡地址
func (RouteInfo) IsDefaultRoute ¶ added in v0.0.8
默认路由就是 目的网络地址为 0.0.0.0, 且flag设置为gateway
func (RouteInfo) MustGetIfaceIpv4 ¶ added in v0.0.8
type RouteInfos ¶ added in v0.0.8
type RouteInfos []RouteInfo
func GetDefalutRouteInfos ¶ added in v0.0.8
func GetDefalutRouteInfos() (ri RouteInfos, err error)
获取当前默认路由所在的网络接口列表,默认路由就是 目的网络地址为 0.0.0.0, 且flag设置为gateway
func (RouteInfos) Len ¶ added in v0.0.8
func (r RouteInfos) Len() int
func (RouteInfos) Less ¶ added in v0.0.8
func (r RouteInfos) Less(i, j int) bool
func (RouteInfos) Swap ¶ added in v0.0.8
func (r RouteInfos) Swap(i, j int)
Click to show internal directories.
Click to hide internal directories.