net

package
v0.8.6 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2022 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RouteArg                    = "%s via %s dev %s metric 50"
	BackupAndDelStaticRouteFile = `` /* 207-byte string literal not displayed */

	AddStaticRouteFile = `cat /etc/sysconfig/network-scripts/route-%s|grep "%s" || echo "%s" >> /etc/sysconfig/network-scripts/route-%s`
)
View Source
const (
	RouteOK     = "ok"
	RouteFailed = "failed"
)

Variables

View Source
var ErrNotIPV4 = errors.New("IP addresses are not IPV4 rules")

Functions

func AssemblyIPList

func AssemblyIPList(ipStr string) (string, error)

func CheckIP

func CheckIP(i string) bool

func CheckIsDefaultRoute

func CheckIsDefaultRoute(host net.IP) error

func CompareIP

func CompareIP(v1, v2 string) int

func DisassembleIPList

func DisassembleIPList(arg string) []net.IP

func GetHostIP

func GetHostIP(host string) string

func GetHostIPSlice

func GetHostIPSlice(hosts []string) (res []string)

func GetHostNetInterface

func GetHostNetInterface(host net.IP) (string, error)

func GetLocalDefaultIP

func GetLocalDefaultIP() (string, error)

func GetLocalHostAddresses

func GetLocalHostAddresses() ([]net.Addr, error)

func GetLocalIP

func GetLocalIP(master0IPPort string) (net.IP, error)

func IPRangeToList

func IPRangeToList(inputStr string) (string, error)

IPRangeToList converts IP range to IP list format.

func IPStrsToIPs

func IPStrsToIPs(ipStrs []string) []net.IP

func IPToInt

func IPToInt(v string) *big.Int

func IPsToIPStrs

func IPsToIPStrs(ips []net.IP) []string

func IsHostPortExist

func IsHostPortExist(protocol string, hostname string, port int) bool

func IsIPList

func IsIPList(args string) bool

func IsIpv4

func IsIpv4(ip string) bool

func IsLocalIP

func IsLocalIP(ip net.IP, addrs []net.Addr) bool

func NextIP

func NextIP(ip string) net.IP

func NotInIPList

func NotInIPList(key net.IP, slice []net.IP) bool

func ParseCIDRString

func ParseCIDRString(s string) (string, error)

ParseCIDRString Parse CIDR Fix to Standard CIDR

func SortIPList

func SortIPList(iplist []string)

Types

type CIDR

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

https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing CIDR doc: IPv4 network Addr/prefixLength 192.168.1.0/24 IPv6 network Addr/prefixLength 2001:db8::/64

func ParseCIDR

func ParseCIDR(s string) (*CIDR, error)

ParseCIDR Parse CIDR net range

func (CIDR) CIDR

func (c CIDR) CIDR() string

CIDR get fixed CIDR String

func (CIDR) IP

func (c CIDR) IP() string

IP Get ip address

func (CIDR) IsIPv4

func (c CIDR) IsIPv4() bool

IsIPv4 check it is IPv4

func (CIDR) IsIPv6

func (c CIDR) IsIPv6() bool

IsIPv6 check it is IPv6

func (CIDR) Mask

func (c CIDR) Mask() string

Mask get subset mask

func (CIDR) MaskSize

func (c CIDR) MaskSize() (ones, bits int)

MaskSize Get mask Size

func (CIDR) Network

func (c CIDR) Network() string

Network Get Network Addr

type Route

type Route struct {
	Host    net.IP
	Gateway net.IP
}

func NewRouter

func NewRouter(host, gateway net.IP) *Route

func (*Route) DelRoute

func (r *Route) DelRoute() error

DelRoute ip route del $route

func (*Route) SetRoute

func (r *Route) SetRoute() error

SetRoute ip route add $route

Jump to

Keyboard shortcuts

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