netutil

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2022 License: MIT Imports: 5 Imported by: 2

Documentation

Overview

Package netutil implements some network utility functions.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidIPv4CIDR = errors.New("invalid IPv4 CIDR")

Functions

func FirstIP added in v0.0.5

func FirstIP(cidr *net.IPNet) net.IP

FirstIP returns the start IP of specified CIDR.

func GetOutBoundIP

func GetOutBoundIP() (net.IP, error)

GetOutBoundIP get preferred outbound ip of current process.

https://stackoverflow.com/a/37382208

func LastIP added in v0.0.5

func LastIP(cidr *net.IPNet) net.IP

LastIP returns the end IP of specified CIDR.

Types

type IPv4Filter added in v1.0.0

type IPv4Filter struct {
	// contains filtered or unexported fields
}

func NewIPv4Filter added in v1.0.0

func NewIPv4Filter() *IPv4Filter

func (*IPv4Filter) Add added in v1.0.0

func (f *IPv4Filter) Add(cidr *net.IPNet) error

func (*IPv4Filter) Contains added in v1.0.0

func (f *IPv4Filter) Contains(ip net.IP) bool

func (*IPv4Filter) Remove added in v1.0.0

func (f *IPv4Filter) Remove(cidr *net.IPNet) error

Jump to

Keyboard shortcuts

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