Documentation
¶
Index ¶
- Constants
- func DialExpec(addr, expect string, timeouts ...time.Duration) bool
- func GetDefaultIface() (string, error)
- func GetFreePort(isUdp ...bool) (int, error)
- func GetFreePorts(count int, isUdp ...bool) ([]int, error)
- func GetFreeTcpPort() (int, error)
- func GetFreeTcpPorts(count int) ([]int, error)
- func GetFreeUdpPort() (int, error)
- func GetFreeUdpPorts(count int) ([]int, error)
- func GetIfaceRouteDefault() (ifacename string)
- func GetNetworkTime(ntpserver string, port int) (t *time.Time, err error)
- func GetOutboundIP(iface ...string) (string, error)
- func GetPublicIp() string
- func HABuildErrorResponseStr(errors []HAErrorCode, messages []HAMessages) (response string)
- func HABuildSuccessResponeStr(result HAResult, messages []HAMessages, result_info ...HAResultInfo) (response string)
- func HttpClientFlush()
- func HttpClientNewTransPort() *http.Transport
- func HttpClientReset()
- func IfaceGetAllName(noLocalhosts ...bool) (ifaces []string)
- func IfaceIsPluged(ifacename string) bool
- func IfaceListAll()
- func IfaceListHasInternet() (ifaces []string)
- func IfaceRestart(ifacname string) bool
- func IpBetween(from net.IP, to net.IP, test net.IP) bool
- func IpConfig(ipstr, maskstr, gwipstr string, ifaces ...string) error
- func IpConfigAuto(ipcidr string, ifaces ...string) error
- func IpDhcpRenew(ifi string, timeouts ...time.Duration) error
- func IpFlush(ifi string) error
- func IpGetDefault(ipstr string) (mask, gw string, err error)
- func IpInc(ip net.IP)
- func IpIsPrivate(ip string) bool
- func IpParserCIDR(cidr string) (maskip, defaultgateway string, err error)
- func IsOnline(times, intervalsecs int) bool
- func IsPortAvailable(ip string, port int, timeouts ...time.Duration) bool
- func IsPortOpen(addr string, port int, proto string, timeouts ...time.Duration) bool
- func IsPortOpen1(addr string, port int, proto string, timeouts ...time.Duration) bool
- func IsPortTcpAvailable(ip string, port int, timeouts ...time.Duration) bool
- func IsPortTcpUsed(ip string, port int, timeouts ...time.Duration) bool
- func IsPortUdpAvailable(ip string, port int, timeouts ...time.Duration) bool
- func IsPortUdpUsed(ip string, port int, timeouts ...time.Duration) bool
- func IsPortUsed(ip string, port int, timeouts ...time.Duration) bool
- func IsPublicIP(IP net.IP) bool
- func IsSsh(addr string, timeouts ...time.Duration) bool
- func IsVnc(addr string, timeouts ...time.Duration) bool
- func MacFromIP(ip2check string, ifaceFlags ...string) (info string, err error)
- func NMConnectWifi(ifacename, ssid, password string) error
- func NMCreateHostPost(ifacename, conname, ssid, password string) error
- func NetCheckConectionToServer(domain string, ifacenames ...string) error
- func NetDiscoveryConfigPort(port int)
- func NetDiscoveryQueryServiceEntry(serviceName, domain string, timeout time.Duration, ifaceNames ...string) []*mdns.ServiceEntry
- func NetGetCIDR(iface ...string) (string, error)
- func NetGetDefaultGatewayOfIface(iface ...string) (string, error)
- func NetGetGatewayOfInterface(ifaceCheck string) (string, error)
- func NetGetInameByIP(ip string) (i string, err error)
- func NetGetInterfaceInfo(infotype int, ifaces ...string) (info string, err error)
- func NetGetInterfaceIpv4Addr(interfaceName string) (addr string, err error)
- func NetGetMac(iface ...string) (macadd string, err error)
- func NetGetMacBytesInterFace(interfaceName string) (macadd []byte, err error)
- func NetGetMacInterFace(interfaceName string) (macadd string, err error)
- func NetGetMacs(iface ...string) ([]string, error)
- func NetGetMask(iface ...string) (string, error)
- func NetGetMetricOfInterface(ifaceCheck string, cirdOrIp string) (int, error)
- func NetGetStaticLoopbackName() (retstr string)
- func NetGetStaticMac() string
- func NetIfaceHasIpv4(interfaceName string) bool
- func NetInitDiscoveryServer(ipService interface{}, serviceport interface{}, id, serviceName string, ...) (s *mdns.Server, err error)
- func NetInterfaceIsUp(ifaceName string) (bool, error)
- func NetIsIpv4(ip net.IP) bool
- func NetIsOnline(times, intervalsecs int, ifacenames ...string) bool
- func NetIsOnlineOld(times, intervalsecs int, ifacenames ...string) bool
- func NetIsOnlinePing(times, intervalsecs int, ifacenames ...string) bool
- func NetIsOnlinePingExternal(times, intervalsecs int, ifacenames ...string) bool
- func NetIsOnlineTcp(times, intervalsecs int, ifacenames ...string) bool
- func NetRouteAdd(iface string, metric int, cirdOrIp string) (cmd2run string, err error)
- func NetRouteAddTemporary(iface string, metric int, cirdOrIp string) (err error)
- func NetRouteDelete(iface string, metric int, cirdOrIp string) (cmd2run string, err error)
- func NetTCPClientSend(servAddr string, dataSend []byte, timeouts ...time.Duration) (retbytes []byte, err error)
- func NetWaitServerIsOnline(domain string, timeout time.Duration, ifacenames ...string) error
- func OnvifSendProbe(ifaceName ...string) (devices []string)
- func Ping(addr, iface string, timeouts ...time.Duration) (*net.IPAddr, time.Duration, error)
- func PingExternal(domain, ifacename string, timeout time.Duration) error
- func ResolverDomain(domain string, debugflag ...bool) (addrs []string, err error)
- func ResolverDomain2Ip4(domain string, debugflag ...bool) (addr string, err error)
- func ResolverDomainOld(domain string, debugflag ...bool) (addrs []string, err error)
- func RouteDefault(ifacename string, metrics ...int) (err error)
- func RouteTem(ifacename string, metrics ...int) (err error)
- func ServerIsLive(domain string, ifacenames ...string) bool
- func TimeGetUTCFromInternet() (t string)
- func TimeGetUTCFromhttp() (gmtteme string)
- func TimeUpdateFromInternet(tzone ...string) bool
- func TimeZoneGet() (tz string)
- type CamerasInfo
- type DeviceCCCInfo
- type DiscoveryInfo
- type HA
- type HAErrorCode
- type HAErrorResponse
- type HAMessages
- type HAResponseCommon
- type HAResult
- type HAResultInfo
- type HASuccessResponse
Constants ¶
const ( IfaceIname int = iota IfaceMacddr IfaceCidr IfaceIp4 IfaceIp6 IfaceMask )
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 GetDefaultIface ¶
func GetFreePort ¶
func GetFreeTcpPort ¶
func GetFreeTcpPorts ¶
func GetFreeUdpPort ¶
func GetFreeUdpPorts ¶
func GetIfaceRouteDefault ¶
func GetIfaceRouteDefault() (ifacename string)
func GetNetworkTime ¶
GetNetworkTime retrieves the current UTC time from the remote NTP server It returns the go time.Time type of the current time in UTC.
func GetOutboundIP ¶
func GetPublicIp ¶
func GetPublicIp() string
func HABuildErrorResponseStr ¶
func HABuildErrorResponseStr(errors []HAErrorCode, messages []HAMessages) (response string)
HABuildErrorResponseStr constructs an error response as a JSON string based on provided error codes and messages. Parameters:
errors: []HAErrorCode (type HAErrorCode struct {
Code int
Messages string
}) - List of error codes and messages
messages: []HAMessages (map[string]interface{}) - List of messages
Returns:
response: string - Constructed error response as a JSON string
func HABuildSuccessResponeStr ¶
func HABuildSuccessResponeStr(result HAResult, messages []HAMessages, result_info ...HAResultInfo) (response string)
HABuildSuccessResponeStr constructs a success response as a JSON string with the provided result, messages, and optional result information. Parameters:
result: HAResult (map[string]interface{})- Result of the operation
messages: []HAMessages (map[string]interface{}) - List of messages
result_info: ...HAResultInfo (map[string]interface{}) - Optional additional result information
Returns:
response: string - Constructed success response as a JSON string
func HttpClientFlush ¶
func HttpClientFlush()
func HttpClientNewTransPort ¶
func HttpClientReset ¶
func HttpClientReset()
func IfaceGetAllName ¶
func IfaceIsPluged ¶
func IfaceListAll ¶
func IfaceListAll()
func IfaceListHasInternet ¶
func IfaceListHasInternet() (ifaces []string)
func IfaceRestart ¶
func IpConfigAuto ¶
func IpGetDefault ¶
func IpIsPrivate ¶
func IpParserCIDR ¶
func IsPortOpen ¶
func IsPortOpen1 ¶
func IsPortTcpAvailable ¶
func IsPortUdpAvailable ¶
func IsPublicIP ¶
func NMConnectWifi ¶
func NMCreateHostPost ¶
func NetDiscoveryConfigPort ¶
func NetDiscoveryConfigPort(port int)
func NetGetCIDR ¶
func NetGetInameByIP ¶
func NetGetInterfaceInfo ¶
infotype 0 interface name, 1 macaddr, 2 cidr, >2 lanip]
func NetGetInterfaceIpv4Addr ¶
func NetGetMacBytesInterFace ¶
func NetGetMacInterFace ¶
func NetGetMacs ¶
func NetGetMask ¶
func NetGetMetricOfInterface ¶
func NetGetStaticLoopbackName ¶
func NetGetStaticLoopbackName() (retstr string)
func NetGetStaticMac ¶
func NetGetStaticMac() string
func NetIfaceHasIpv4 ¶
func NetInitDiscoveryServer ¶
func NetInitDiscoveryServer(ipService interface{}, serviceport interface{}, id, serviceName string, info interface{}, ifaceName ...interface{}) (s *mdns.Server, err error)
ipService: net.IP, *net.IP, []net.IP, *[]net.IP, string, *string, []string, *[]string => *[]net.IP serviceport: int, *int => *int info: string, []string, *[]string => *[]string ifaceName: string, net.Interface, *net.Interface => *net.Interface
func NetInterfaceIsUp ¶
func NetIsOnline ¶
func NetIsOnlineOld ¶
func NetIsOnlinePing ¶
func NetIsOnlinePingExternal ¶
func NetIsOnlineTcp ¶
func NetRouteAdd ¶
func NetRouteAddTemporary ¶
func NetRouteDelete ¶
func NetTCPClientSend ¶
func NetWaitServerIsOnline ¶
func OnvifSendProbe ¶
func ResolverDomain ¶
func ResolverDomain2Ip4 ¶
func ResolverDomainOld ¶
func RouteDefault ¶
func ServerIsLive ¶
func TimeGetUTCFromInternet ¶
func TimeGetUTCFromInternet() (t string)
func TimeGetUTCFromhttp ¶
func TimeGetUTCFromhttp() (gmtteme string)
func TimeUpdateFromInternet ¶
func TimeZoneGet ¶
func TimeZoneGet() (tz string)
Types ¶
type CamerasInfo ¶
type CamerasInfo struct {
From string `json:"from"`
IP string `json:"ip"`
Name string `json:"name"`
XADDR string `json:"xaddr"`
UUID string `json:"uuid"`
Hardware string `json:"hardware"`
Location string `json:"location"`
FirmwareVersion string `json:"firmware version"`
LastConnectError time.Time `json:"last_error_time"`
}
func OnvifDiscovery ¶
func OnvifDiscovery(ifaceName ...string) []CamerasInfo
type DeviceCCCInfo ¶
type DeviceCCCInfo struct {
From string `json:"from"`
IP string `json:"ip"`
Port int `json:"port"`
Serial_number string `json:"serial_number"`
Device_id string `json:"device_id"`
Extra []string `json:"more"`
LastDiscovery time.Time `json:"-"`
Version string `json:"Version"`
}
func NetDiscoveryQueryCCC ¶
func NetDiscoveryQueryCCC(servicename string, ifaceName ...string) (deviceList []DeviceCCCInfo)
type DiscoveryInfo ¶
func NetDiscoveryQuery ¶
func NetDiscoveryQuery(serviceName string, timeout time.Duration, ifaceNames ...string) []*DiscoveryInfo
type HA ¶
type HA map[string]interface{}
HA is a type alias representing a map with string keys and interface{} values.
type HAErrorCode ¶
HAErrorCode represents an error code along with a message.
func HABuildErrorCode ¶
func HABuildErrorCode(code int, msg string) HAErrorCode
type HAErrorResponse ¶
type HAErrorResponse struct {
HAResponseCommon
}
HAErrorResponse represents an error response containing common response fields.
func HABuildErrorResponse ¶
func HABuildErrorResponse(errors []HAErrorCode, messages []HAMessages) (response *HAErrorResponse)
HABuildErrorResponse constructs an error response based on provided error codes and messages. Parameters:
struct HAErrorCode { Code int; Messages string }
errors: []HAErrorCode - List of error codes and messages
messages: []HAMessages (map[string]interface{}) - List of messages
Returns:
response: *HAErrorResponse - Constructed error response
type HAMessages ¶
type HAMessages map[string]interface{}
HAMessages is a type alias representing a map with string keys and interface{} values, typically used for representing messages in the response.
type HAResponseCommon ¶
type HAResponseCommon struct {
Result HAResult `json:"result"` // Result of the operation, nil for error
Success bool `json:"success"` // Indicates success or failure (false/true)
Errors []HAErrorCode `json:"errors"` // List of error codes and messages
Messages []HAMessages `json:"messages"` // List of messages
}
HAResponseCommon is a common structure for both error and success responses.
type HAResult ¶
type HAResult map[string]interface{}
HAResult is a type alias representing a map with string keys and interface{} values, typically used for representing the result of an operation in the response.
type HAResultInfo ¶
type HAResultInfo map[string]interface{}
HAResultInfo is a type alias representing a map with string keys and interface{} values, often used for representing additional information about the result.
type HASuccessResponse ¶
type HASuccessResponse struct {
HAResponseCommon
Result_info HAResultInfo `json:"result_info"` // Additional result information
}
HASuccessResponse represents a success response containing common response fields along with additional result information.
func HABuildSuccessRespone ¶
func HABuildSuccessRespone(result HAResult, messages []HAMessages, result_info ...HAResultInfo) (response *HASuccessResponse)
HABuildSuccessRespone constructs a success response with the provided result, messages, and optional result information. Parameters:
result: HAResult (map[string]interface{})- Result of the operation
messages: []HAMessages (map[string]interface{}) - List of messages
result_info: ...HAResultInfo (map[string]interface{}) - Optional additional result information
Returns:
response: *HASuccessResponse - Constructed success response