netutils

package module
v0.0.0-...-b504bbc Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2024 License: MIT Imports: 13 Imported by: 0

README

netutils

golang 's network utilities

Documentation

Index

Constants

View Source
const (
	IfaceIname int = iota
	IfaceMacddr
	IfaceCidr
	IfaceIp4
	IfaceIp6
	IfaceMask
)
View Source
const (
	// Stolen from https://godoc.org/golang.org/x/net/internal/iana,
	// can't import "internal" packages
	ProtocolICMP = 1
)

Variables

This section is empty.

Functions

func NetCheckConectionToServer

func NetCheckConectionToServer(domain string, ifacenames ...string) error
Check connection to http/https server

return nil if cant connect to server through interface

func NetDiscoveryQueryServiceEntry

func NetDiscoveryQueryServiceEntry(serviceName, domain string, timeout time.Duration, ifaceNames ...string) []*mdns.ServiceEntry

func NetGetInterfaceIpv4Addr

func NetGetInterfaceIpv4Addr(interfaceName string) (addr string, err error)

Get first finded IPv4 address of Linux network interface.

func NetIfaceHasIpv4

func NetIfaceHasIpv4(interfaceName string) bool

Check if Network Interface has any IPv4 address.

func NetInitDiscoveryServer

func NetInitDiscoveryServer(ipService interface{}, serviceport interface{}, id, serviceName string, info interface{}, ifaceName ...interface{}) (s *mdns.Server, err error)

id is instance in mdns

func NetIsOnlinePing

func NetIsOnlinePing(times, intervalsecs int, ifacenames ...string) bool

Check if host machine have internet (check by ping(imcp) to dns servers)

func NetIsOnlineTcp

func NetIsOnlineTcp(times, intervalsecs int, ifacenames ...string) bool

Check if host machine have internet (check http connection to DNS server )

func NetListAllRealIface

func NetListAllRealIface() ([]string, error)

list all real network iface, include ethernet, wlan, docker network

func Ping

func Ping(addr, iface string, timeouts ...time.Duration) (*net.IPAddr, time.Duration, error)

func ResolverDomain

func ResolverDomain(domain string, debugflag ...bool) (addrs []string, err error)

Convert Domain to IP

func ResolverDomain2Ip4

func ResolverDomain2Ip4(domain string, debugflag ...bool) (addr string, err error)

func ServerIsLive

func ServerIsLive(domain string, ifacenames ...string) bool

Check if server is alive, timeout check is 666ms

Types

type DiscoveryInfo

type DiscoveryInfo struct {
	Name string
	Host string
	Ip4  string
	Port int
	Info []string
}

Jump to

Keyboard shortcuts

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