Documentation
¶
Overview ¶
Package ncutils contains utility functions
Index ¶
- Constants
- func ConvertBytesToKey(data []byte) (*[32]byte, error)
- func ConvertKeyToBytes(key *[32]byte) ([]byte, error)
- func Copy(src, dst string) error
- func DNSFormatString(input string) string
- func FileExists(f string) bool
- func GetEmbedded() error
- func GetFreePort(rangestart, currListenPort int, init bool) (int, error)
- func GetInterfaceName() string
- func GetInterfaces() ([]models.Iface, error)
- func GetMacAddr() ([]net.HardwareAddr, error)
- func InterfaceExists(ifaceName string) (bool, error)
- func IsBridgeNetwork(ifaceName string) bool
- func IsIPTablesPresent() bool
- func IsLinux() bool
- func IsNFTablesPresent() bool
- func IsPortFree(port int) (free bool)
- func IsPublicIP(ip net.IP) bool
- func IsWindows() bool
- func RandomMacAddress() net.HardwareAddr
- func RandomString(length int) string
- func ReadPID() (int, error)
- func RunCmd(command string, printerr bool) (string, error)
- func RunCmdFormatted(command string, printerr bool) (string, error)
- func SavePID() error
- func SendRequest(method, endpoint string, headers http.Header, data any) (*bytes.Buffer, error)
- func SetInterfaceName(iface string)
- func SetVerbosity(logLevel int)
- func ShortenString(input string, length int) string
- func TraceCaller()
- type ErrStatusNotOk
- type WindowsPIDError
Constants ¶
const NetclientDefaultPort = 51821
NetclientDefaultPort - default port
const PidFile = "/var/run/netclient.pid"
PidFile - path/name of pid file
Variables ¶
This section is empty.
Functions ¶
func ConvertBytesToKey ¶
ConvertBytesToKey - util to convert bytes to a key to use elsewhere
func ConvertKeyToBytes ¶
ConvertKeyToBytes - util to convert a key to bytes to use elsewhere
func DNSFormatString ¶
DNSFormatString - Formats a string with correct usage for DNS
func GetFreePort ¶
GetFreePort - gets free port of machine
func GetInterfaceName ¶
func GetInterfaceName() string
GetInterfaceName - fetches the interface name
func GetInterfaces ¶ added in v0.90.0
func InterfaceExists ¶ added in v0.22.0
InterfaceExists - checks if iface exists already
func IsBridgeNetwork ¶ added in v0.18.6
IsBridgeNetwork - check if the interface is a bridge type
func IsIPTablesPresent ¶
func IsIPTablesPresent() bool
IsIPTablesPresent - returns true if iptables is present, false otherwise Does not consider OS, up to the caller to determine if the OS supports iptables/whether this check is valid.
func IsNFTablesPresent ¶
func IsNFTablesPresent() bool
IsNFTablesPresent - returns true if nftables is present, false otherwise. Does not consider OS, up to the caller to determine if the OS supports nftables/whether this check is valid.
func IsPortFree ¶ added in v0.21.0
IsPortFree - checks if port is free
func IsPublicIP ¶ added in v0.90.0
IsPublicIP indicates whether IP is public or not.
func RandomMacAddress ¶ added in v0.18.5
func RandomMacAddress() net.HardwareAddr
RandomMacAddress returns a random macaddress
func RandomString ¶ added in v0.20.5
RandomString - returns a random string in a charset
func RunCmdFormatted ¶
RunCmdFormatted - does nothing for linux
func SendRequest ¶ added in v1.5.0
func SetInterfaceName ¶ added in v0.22.0
func SetInterfaceName(iface string)
func SetVerbosity ¶ added in v0.90.0
func SetVerbosity(logLevel int)
func ShortenString ¶
ShortenString - Brings string down to specified length. Stops names from being too long
func TraceCaller ¶ added in v0.90.0
func TraceCaller()
Types ¶
type ErrStatusNotOk ¶ added in v1.5.0
func (ErrStatusNotOk) Error ¶ added in v1.5.0
func (e ErrStatusNotOk) Error() string
type WindowsPIDError ¶
type WindowsPIDError struct{}
WindowsPIDError - error returned from pid function on windows
func (*WindowsPIDError) Error ¶
func (*WindowsPIDError) Error() string
Error generates error for windows os