net

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 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 CheckIsDefaultRoute

func CheckIsDefaultRoute(host net.IP) error

func CompareIP

func CompareIP(v1, v2 string) int

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 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 IsInIPList added in v0.9.0

func IsInIPList(key net.IP, slice []net.IP) 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 ParseCIDRString

func ParseCIDRString(s string) (string, error)

ParseCIDRString Parse CIDR Fix to Standard CIDR

func RemoveIPs added in v0.9.0

func RemoveIPs(clusterIPList []net.IP, toBeDeletedIPList []net.IP) (res []net.IP)

func SortIPList

func SortIPList(iplist []string)

func TransferToIPList added in v0.9.0

func TransferToIPList(ipStr string) (string, error)

TransferToIPList transfer network segment string to ip list string

Types

type CIDR

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

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