Documentation
¶
Index ¶
- Constants
- func AesDecrypt(ciphertext, key []byte) ([]byte, error)
- func AesEncrypt(plaintext, key []byte) ([]byte, error)
- func AppendEnv(paramEnv map[string]string, includeHostEnv bool) []string
- func CalculateFileMD5(fn string) (string, error)
- func CopyFile(s, t string) error
- func DirExists(path string) bool
- func Equal(a, b interface{}) bool
- func FileExists(path string) bool
- func GetAvailablePort(host string) (int, error)
- func GetEnv(key string) string
- func GetSerialNumber(file string) (string, error)
- func LoadYAML(path string, out interface{}) error
- func NewAesKey() []byte
- func NewTLSClientConfig(c Certificate) (*tls.Config, error)
- func NewTLSServerConfig(c Certificate) (*tls.Config, error)
- func ParseURL(addr string) (*url.URL, error)
- func PathExists(path string) bool
- func RsaPrivateDecrypt(data, privateKey []byte) ([]byte, error)
- func RsaPrivateEncrypt(data, privateKey []byte) ([]byte, error)
- func RsaPublicDecrypt(data, publicKey []byte) ([]byte, error)
- func RsaPublicEncrypt(data, publicKey []byte) ([]byte, error)
- func SetDefaults(ptr interface{}) error
- func SetEnv(key, value string)
- func Trace(name string, log func(format string, args ...interface{})) func()
- func UnmarshalJSON(in []byte, out interface{}) error
- func UnmarshalYAML(in []byte, out interface{}) error
- func WriteFile(fn string, r io.Reader) error
- type Addr
- type CPUInfo
- type Certificate
- type DiskInfo
- type GPUInfo
- type HostInfo
- type Interface
- type Length
- type MemInfo
- type NetInfo
- type PerCPUInfo
- type PerGPUInfo
- type Tomb
Constants ¶
const ( AesIvLen = 16 AesKeyLen = 32 AesKeyCharSet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" )
AES aes
Variables ¶
This section is empty.
Functions ¶
func AesDecrypt ¶
AesDecrypt decrypts data using the specified key
func AesEncrypt ¶
AesEncrypt encrypts data using the specified key
func CalculateFileMD5 ¶
CalculateFileMD5 calculates file MD5
func GetAvailablePort ¶
GetAvailablePort finds an available port
func GetSerialNumber ¶
GetSerialNumber gets serial number from pem
func NewTLSClientConfig ¶
func NewTLSClientConfig(c Certificate) (*tls.Config, error)
NewTLSClientConfig loads tls config for client
func NewTLSServerConfig ¶
func NewTLSServerConfig(c Certificate) (*tls.Config, error)
NewTLSServerConfig loads tls config for server
func RsaPrivateDecrypt ¶
RsaPrivateDecrypt decrypts data using private key
func RsaPrivateEncrypt ¶
RsaPrivateEncrypt encrypts data using private key
func RsaPublicDecrypt ¶
RsaPublicDecrypt decrypts data using public key
func RsaPublicEncrypt ¶
RsaPublicEncrypt encrypts data using public key
func UnmarshalJSON ¶
UnmarshalJSON unmarshals, defaults and validates
func UnmarshalYAML ¶
UnmarshalYAML unmarshals, defaults and validates
Types ¶
type Addr ¶
type Addr struct { Network string `json:"network,omitempty"` Address string `json:"address,omitempty"` }
Addr network ip address
type CPUInfo ¶
type CPUInfo struct { Time time.Time `json:"time,omitempty"` Mhz float64 `json:"mhz,omitempty"` Cores int32 `json:"cores,omitempty"` CacheSize int32 `json:"cache_size,omitempty"` ModelName string `json:"model_name,omitempty"` PhysicalID string `json:"physical_id,omitempty"` UsedPercent float64 `json:"used_percent,omitempty"` Error string `json:"error,omitempty"` }
CPUInfo CPU information
type Certificate ¶
type Certificate struct { CA string `yaml:"ca" json:"ca"` Key string `yaml:"key" json:"key"` Cert string `yaml:"cert" json:"cert"` Insecure bool `yaml:"insecure" json:"insecure"` // for client, for test purpose }
Certificate certificate config for mqtt server
type DiskInfo ¶
type DiskInfo struct { Time time.Time `json:"time,omitempty"` Path string `json:"path,omitempty"` Fstype string `json:"fstype,omitempty"` Total uint64 `json:"total,omitempty"` Free uint64 `json:"free,omitempty"` Used uint64 `json:"used,omitempty"` UsedPercent float64 `json:"used_percent,omitempty"` InodesTotal uint64 `json:"inodes_total,omitempty"` InodesUsed uint64 `json:"inodes_used,omitempty"` InodesFree uint64 `json:"inodes_free,omitempty"` InodesUsedPercent float64 `json:"inodes_used_percent,omitempty"` Error string `json:"error,omitempty"` }
DiskInfo disk information
type GPUInfo ¶
type GPUInfo struct { Time time.Time `json:"time,omitempty"` GPUs []PerGPUInfo `json:"gpus,omitempty"` Error string `json:"error,omitempty"` }
GPUInfo GPU information
type HostInfo ¶
type HostInfo struct { Time time.Time `json:"time,omitempty"` Hostname string `json:"hostname,omitempty"` Uptime uint64 `json:"uptime,omitempty"` BootTime uint64 `json:"boot_time,omitempty"` ProcessNum uint64 `json:"process_num,omitempty"` OS string `json:"os,omitempty"` Platform string `json:"platform,omitempty"` PlatformFamily string `json:"platform_family,omitempty"` PlatformVersion string `json:"platform_version,omitempty"` KernelVersion string `json:"kernel_version,omitempty"` HostID string `json:"host_id,omitempty"` Error string `json:"error,omitempty"` }
HostInfo host information
type Interface ¶
type Interface struct { Index int `json:"index,omitempty"` Name string `json:"name,omitempty"` MAC string `json:"mac,omitempty"` Addrs []Addr `json:"addrs,omitempty"` Error string `json:"error,omitempty"` }
Interface interface information
type Length ¶
type Length struct {
Max int64 `yaml:"max" json:"max"`
}
Length length
func (*Length) UnmarshalYAML ¶
UnmarshalYAML customizes unmarshal
type MemInfo ¶
type MemInfo struct { Time time.Time `json:"time,omitempty"` Total uint64 `json:"total,omitempty"` Free uint64 `json:"free,omitempty"` Used uint64 `json:"used,omitempty"` UsedPercent float64 `json:"used_percent,omitempty"` SwapTotal uint64 `json:"swap_total,omitempty"` SwapFree uint64 `json:"swap_free,omitempty"` SwapUsed uint64 `json:"swap_used,omitempty"` SwapUsedPercent float64 `json:"swap_used_percent,omitempty"` Error string `json:"error,omitempty"` }
MemInfo memory information
type NetInfo ¶
type NetInfo struct { Time time.Time `json:"time,omitempty"` Interfaces []Interface `json:"interfaces,omitempty"` Error string `json:"error,omitempty"` }
NetInfo host information
type PerCPUInfo ¶
type PerCPUInfo struct {
UsedPercent float64 `json:"used_percent,omitempty"`
}
PerCPUInfo one CPU information
type PerGPUInfo ¶
type PerGPUInfo struct { Index string `json:"index,omitempty"` Model string `json:"model,omitempty"` MemTotal uint64 `json:"mem_total,omitempty"` MemFree uint64 `json:"mem_free,omitempty"` MemUsedPercent float64 `json:"mem_used_percent,omitempty"` GPUUsedPercent float64 `json:"gpu_used_percent,omitempty"` }
PerGPUInfo one GPU information
type Tomb ¶
type Tomb struct {
// contains filtered or unexported fields
}
Tomb wraps tomb.Tomb
func (*Tomb) Dying ¶
func (t *Tomb) Dying() <-chan struct{}
Dying returns the channel that can be used to wait until t.Kill is called.