Documentation
¶
Index ¶
- Constants
- Variables
- func BenchStatusToStr(r share.BenchStatus) string
- func CompareSliceWithoutOrder(a, b interface{}) bool
- func CompressToZipFile(source, targetFile string) error
- func Decrypt(encryptionKey, text []byte) ([]byte, error)
- func DecryptFromBase64(encryptionKey []byte, b64 string) (string, error)
- func DecryptFromRawStdBase64(key []byte, b64 string) (string, error)
- func DecryptFromRawURLBase64(key []byte, b64 string) (string, error)
- func DecryptPassword(encrypted string) string
- func DecryptSensitive(encrypted string, key []byte) string
- func DecryptURLSafe(encrypted string) string
- func DecryptUserToken(encrypted string, key []byte) string
- func DisplayBytes(num int64) string
- func Dns1123NameChg(name string) string
- func DoesGroupHavePolicyMode(name string) bool
- func Encrypt(encryptionKey, text []byte) ([]byte, error)
- func EncryptPassword(password string) string
- func EncryptSensitive(data string, key []byte) string
- func EncryptToBase64(encryptionKey, text []byte) (string, error)
- func EncryptToRawStdBase64(key, text []byte) (string, error)
- func EncryptToRawURLBase64(key, text []byte) (string, error)
- func EncryptURLSafe(password string) string
- func EncryptUserToken(token string, key []byte) string
- func EnsureBaseDir(fpath string) error
- func EvaluateApiCfgType(name string, bCrdType bool) string
- func EvaluateGroupType(name string) share.TCfgType
- func Exec(dir string, bin string, args ...string) ([]byte, error)
- func ExtractAllArchive(dst string, r io.Reader, maxFileSize int64) (int64, error)
- func ExtractAllArchiveToFiles(path string, r io.Reader, maxFileSize int64, encryptKey []byte) error
- func FileHashCrc32(path string, size int64) uint32
- func FilterIndexKey(path, regex string) string
- func GetCaller(skip int, excludes []string) string
- func GetCommonPorts(ports1 string, ports2 string) string
- func GetFileContentType(buffer []byte) string
- func GetFunctionName(f interface{}) string
- func GetGID() uint64
- func GetGuid() (string, error)
- func GetIPEnclosure(ips []net.IP) *net.IPNet
- func GetLicenseInfo(license string) (string, error)
- func GetMd5(s string) string
- func GetPortLink(ipproto uint8, port uint16) string
- func GetPortRangeLink(ipproto uint8, port uint16, portR uint16) string
- func GetRandomID(length int, prefix string) string
- func GetStringUUID(s string) string
- func GetSupportedTLSCipherSuites() []uint16
- func GetTimeUUID(t time.Time) string
- func GunzipBytes(buf []byte) []byte
- func GzipBytes(buf []byte) []byte
- func HasGroupProfiles(name string) bool
- func HashPassword(password string) string
- func HashStringToInt32(s string, slots int) int
- func Htonl(v uint32) uint32
- func IPNet2Subnet(ipnet *net.IPNet) *net.IPNet
- func IPNet2SubnetLoose(ipnet *net.IPNet, scope string) *net.IPNet
- func IPv42Int(ip net.IP) uint32
- func Int2IPv4(addr uint32) net.IP
- func InterpretIP(ip, ipR net.IP) string
- func IsContainerMountFile(pid int, path string) bool
- func IsCustomProfileGroup(group string) bool
- func IsExecutable(info os.FileInfo, path string) bool
- func IsExecutableLinkableFile(path string) bool
- func IsGroupLearned(name string) bool
- func IsGroupNodes(name string) bool
- func IsHostRelated(addr *share.CLUSWorkloadAddr) bool
- func IsIPv4(ip net.IP) bool
- func IsIPv6(ip net.IP) bool
- func IsMountPoint(path string) bool
- func IsNativeLittleEndian() bool
- func JoinCommand(cmds []string) string
- func MakeServiceName(namespace, name string) string
- func MakeTar(files []TarFileInfo) (*bytes.Buffer, error)
- func MakeUserFullname(server, username string) string
- func MergeSpecialSubnet(subnets map[string]share.CLUSSpecSubnet, snet share.CLUSSubnet, iptype string) bool
- func MergeSubnet(subnets map[string]share.CLUSSubnet, snet share.CLUSSubnet) bool
- func NopCloser(r io.Reader) io.ReadCloser
- func NormalizeForURL(name string) string
- func ParseIPRange(value string) (net.IP, net.IP)
- func ParsePortRangeLink(name string) (uint8, uint16, uint16, error)
- func PerfProfile(req *share.CLUSProfilingRequest, folder, prefix string)
- func PerfSnapshot(pid int, memLimit, profileLimit, usage uint64, ...)
- func Proto2Name(ipproto uint8) string
- func RandomString(length int) string
- func ResolveAddrList(addr string, skipLoopback bool) ([]string, bool)
- func ResolveIP(name string) ([]net.IP, error)
- func ReverseBytesInPlace(a []byte) []byte
- func SelectivelyExtractArchive(r io.Reader, selected func(string) bool, maxFileSize int64) (map[string][]byte, error)
- func SelectivelyExtractModules(r io.Reader, lastfix string, maxFileSize int64) (map[string][]byte, error)
- func SelectivelyExtractToFile(r io.Reader, selected func(string) bool, dir string) (map[string]string, error)
- func SelectivelyExtractToFiles(r io.Reader, dir string, selected func(string) bool, maxFileSize int64) (map[string]string, error)
- func SetReady(value string) error
- func SubnetContains(n1, n2 *net.IPNet) (bool, int)
- func UnsetReady() error
- func Unzip(src string, dest string) error
- func UnzipDataIfValid(value []byte) ([]byte, bool)
- type EnvironParser
- func (p EnvironParser) GetKVPairs() map[string]string
- func (p EnvironParser) GetPlatformEnv() map[string][]string
- func (p EnvironParser) GetPlatformIntf(port string) []string
- func (p EnvironParser) GetPlatformName() (string, string)
- func (p EnvironParser) GetSystemGroups() []*regexp.Regexp
- func (p EnvironParser) Value(key string) (string, bool)
- type Iterator
- type LogFormatter
- type Set
- type TarFileInfo
- type TarReadCloser
- type TimerTask
- type TimerWheel
- type Version
- func (a Version) Compare(b Version) int
- func (a Version) CompareWithoutEpoch(b Version) int
- func (v Version) MarshalJSON() ([]byte, error)
- func (v *Version) Scan(value interface{}) (err error)
- func (v Version) String() (s string)
- func (v *Version) UnmarshalJSON(b []byte) (err error)
- func (v *Version) Value() (driver.Value, error)
- type WheelTimeOut
- type XzReader
Constants ¶
const ( OS_READ = 04 OS_WRITE = 02 OS_EX = 01 OS_USER_SHIFT = 6 OS_GROUP_SHIFT = 3 OS_OTH_SHIFT = 0 OS_USER_X = OS_EX << OS_USER_SHIFT OS_GROUP_X = OS_EX << OS_GROUP_SHIFT OS_OTH_X = OS_EX << OS_OTH_SHIFT OS_ALL_X = OS_USER_X | OS_GROUP_X | OS_OTH_X )
Variables ¶
var ( // ErrCouldNotExtract occurs when an extraction fails. ErrCouldNotExtract = errors.New("could not extract the archive") ErrRequestCanceled = errors.New("request conceled") // ErrExtractedFileTooBig occurs when a file to extract is too big. ErrExtractedFileTooBig = errors.New("could not extract one or more files from the archive: file too big") ErrCouldNotWriteToDisk = errors.New("could not write to disk") )
var ( // MinVersion is a special package version which is always sorted first MinVersion = Version{/* contains filtered or unexported fields */} // MaxVersion is a special package version which is always sorted last MaxVersion = Version{/* contains filtered or unexported fields */} )
var CfgTypeToApiMapping = map[share.TCfgType]string{ share.Learned: api.CfgTypeLearned, share.UserCreated: api.CfgTypeUserCreated, share.GroundCfg: api.CfgTypeGround, share.FederalCfg: api.CfgTypeFederal, }
Utilities: find group attribute from the grou's name definitions, based on controller/api/apis.go
var IPv4Loopback = net.IPv4(127, 0, 0, 1)
Functions ¶
func BenchStatusToStr ¶
func BenchStatusToStr(r share.BenchStatus) string
func CompareSliceWithoutOrder ¶
func CompareSliceWithoutOrder(a, b interface{}) bool
func CompressToZipFile ¶
func DecryptPassword ¶
func DecryptSensitive ¶
func DecryptURLSafe ¶
func DecryptUserToken ¶
func DisplayBytes ¶
func Dns1123NameChg ¶
func DoesGroupHavePolicyMode ¶
func EncryptPassword ¶
func EncryptSensitive ¶
func EncryptToBase64 ¶
func EncryptToRawStdBase64 ¶
func EncryptToRawURLBase64 ¶
func EncryptURLSafe ¶
func EncryptUserToken ¶
User token cannot have / in it and cannot have - as the first char.
func EnsureBaseDir ¶
func EvaluateApiCfgType ¶
func EvaluateGroupType ¶
func ExtractAllArchive ¶
func FileHashCrc32 ¶
func FilterIndexKey ¶
func GetCommonPorts ¶
func GetFileContentType ¶
GetFileContentType: explore the content type, only work content at least 512 bytes
func GetFunctionName ¶
func GetFunctionName(f interface{}) string
func GetLicenseInfo ¶
func GetPortLink ¶
func GetRandomID ¶
func GetStringUUID ¶
func GetSupportedTLSCipherSuites ¶
func GetSupportedTLSCipherSuites() []uint16
When using `nmap -sV --script ssl-enum-ciphers` to check cipher suites, ECDHE will not be detected. This is because of a golang issue fixed in 1.20: https://github.com/golang/go/issues/49126
func GetTimeUUID ¶
func GunzipBytes ¶
func HasGroupProfiles ¶
func HashPassword ¶
func HashStringToInt32 ¶
func InterpretIP ¶
func IsContainerMountFile ¶
func IsCustomProfileGroup ¶
func IsExecutableLinkableFile ¶
IsExecutableLinkableFile: explore ELF header
func IsGroupLearned ¶
func IsGroupNodes ¶
func IsHostRelated ¶
func IsHostRelated(addr *share.CLUSWorkloadAddr) bool
func IsMountPoint ¶
func IsNativeLittleEndian ¶
func IsNativeLittleEndian() bool
func JoinCommand ¶
func MakeServiceName ¶
func MakeUserFullname ¶
func MergeSpecialSubnet ¶
func MergeSpecialSubnet(subnets map[string]share.CLUSSpecSubnet, snet share.CLUSSubnet, iptype string) bool
func MergeSubnet ¶
func MergeSubnet(subnets map[string]share.CLUSSubnet, snet share.CLUSSubnet) bool
func NopCloser ¶
func NopCloser(r io.Reader) io.ReadCloser
NopCloser returns a ReadCloser with a no-op Close method wrapping the provided Reader r.
func NormalizeForURL ¶
func PerfProfile ¶
func PerfProfile(req *share.CLUSProfilingRequest, folder, prefix string)
func PerfSnapshot ¶
func Proto2Name ¶
func RandomString ¶
func ReverseBytesInPlace ¶
func SelectivelyExtractArchive ¶
func SelectivelyExtractArchive(r io.Reader, selected func(string) bool, maxFileSize int64) (map[string][]byte, error)
SelectivelyExtractArchive extracts the specified files and folders from targz data read from the given reader and store them in a map indexed by file paths
func SelectivelyExtractToFile ¶
func SelectivelyExtractToFile(r io.Reader, selected func(string) bool, dir string) (map[string]string, error)
func SelectivelyExtractToFile(r io.Reader, prefix string, toExtract []string, dir string) (map[string]string, error) {
func SubnetContains ¶
The first value indicate if two subnets contains one or another, if true then, the second value returns 1 if n1 contains n2, -1 if n2 contains n1, 0 if equal.
func UnsetReady ¶
func UnsetReady() error
func Unzip ¶
Unzip will decompress a zip archive, moving all files and folders within the zip file (parameter 1) to an output directory (parameter 2).
func UnzipDataIfValid ¶
Types ¶
type EnvironParser ¶
type EnvironParser struct {
// contains filtered or unexported fields
}
func NewEnvironParser ¶
func NewEnvironParser(envs []string) *EnvironParser
func (EnvironParser) GetKVPairs ¶
func (p EnvironParser) GetKVPairs() map[string]string
func (EnvironParser) GetPlatformEnv ¶
func (p EnvironParser) GetPlatformEnv() map[string][]string
func (EnvironParser) GetPlatformIntf ¶
func (p EnvironParser) GetPlatformIntf(port string) []string
func (EnvironParser) GetPlatformName ¶
func (p EnvironParser) GetPlatformName() (string, string)
func (EnvironParser) GetSystemGroups ¶
func (p EnvironParser) GetSystemGroups() []*regexp.Regexp
type LogFormatter ¶
type LogFormatter struct {
Module string
}
type Set ¶
type Set interface { // Adds an element to the set. Returns whether // the item was added. Add(i interface{}) bool // Returns the number of elements in the set. Cardinality() int // Removes all elements from the set, leaving // the emtpy set. Clear() // Returns a clone of the set using the same // implementation, duplicating all keys. Clone() Set // Returns whether the given items // are all in the set. Contains(i ...interface{}) bool // Returns the difference between this set // and other. The returned set will contain // all elements of this set that are not also // elements of other. // // Note that the argument to Difference // must be of the same type as the receiver // of the method. Otherwise, Difference will // panic. Difference(other Set) Set // Determines if two sets are equal to each // other. If they have the same cardinality // and contain the same elements, they are // considered equal. The order in which // the elements were added is irrelevant. // // Note that the argument to Equal must be // of the same type as the receiver of the // method. Otherwise, Equal will panic. Equal(other Set) bool // Returns a new set containing only the elements // that exist only in both sets. // // Note that the argument to Intersect // must be of the same type as the receiver // of the method. Otherwise, Intersect will // panic. Intersect(other Set) Set // Determines if every element in the other set // is in this set. // // Note that the argument to IsSubset // must be of the same type as the receiver // of the method. Otherwise, IsSubset will // panic. IsSubset(other Set) bool // Determines if every element in this set is in // the other set. // // Note that the argument to IsSuperset // must be of the same type as the receiver // of the method. Otherwise, IsSuperset will // panic. IsSuperset(other Set) bool // Returns a channel of elements that you can // range over. Iter() threadUnsafeSet // Remove a single element from the set. Remove(i interface{}) // Provides a convenient string representation // of the current state of the set. String() string // Returns a new set with all elements which are // in either this set or the other set but not in both. // // Note that the argument to SymmetricDifference // must be of the same type as the receiver // of the method. Otherwise, SymmetricDifference // will panic. SymmetricDifference(other Set) Set // Returns a new set with all elements in both sets. // // Note that the argument to Union must be of the // same type as the receiver of the method. // Otherwise, IsSuperset will panic. Union(other Set) Set // Returns the members of the set as a slice. ToSlice() []interface{} ToInt32Slice() []int32 ToStringSlice() []string // Returns one member of the set. Any() interface{} }
func NewSetFromSlice ¶
func NewSetFromSlice(s []interface{}) Set
func NewSetFromSliceKind ¶
func NewSetFromSliceKind(slice interface{}) Set
func NewSetFromStringSlice ¶
type TarFileInfo ¶
type TarReadCloser ¶
TarReadCloser embeds a *tar.Reader and the related io.Closer It is the caller's responsibility to call Close on TarReadCloser when done.
func (*TarReadCloser) Close ¶
func (r *TarReadCloser) Close() error
type TimerWheel ¶
type TimerWheel struct {
// contains filtered or unexported fields
}
func NewTimerWheel ¶
func NewTimerWheel() *TimerWheel
func NewTimerWheelWithTick ¶
func NewTimerWheelWithTick(tick time.Duration) *TimerWheel
func (*TimerWheel) RemoveTask ¶
func (t *TimerWheel) RemoveTask(taskId string)
func (*TimerWheel) Start ¶
func (t *TimerWheel) Start()
func (*TimerWheel) Stop ¶
func (t *TimerWheel) Stop()
type Version ¶
type Version struct {
// contains filtered or unexported fields
}
Version represents a package version
func NewVersion ¶
NewVersion function parses a string into a Version struct which can be compared
The implementation is based on http://man.he.net/man5/deb-version on https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Version
It uses the dpkg-1.17.25's algorithm (lib/parsehelp.c)
func NewVersionUnsafe ¶
NewVersionUnsafe is just a wrapper around NewVersion that ignore potentiel parsing error. Useful for test purposes
func (Version) Compare ¶
Compare function compares two Debian-like package version
The implementation is based on http://man.he.net/man5/deb-version on https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Version
It uses the dpkg-1.17.25's algorithm (lib/version.c)
func (Version) CompareWithoutEpoch ¶
CompareWithoutEpoch uses same comparison logic as Compare but doesn't compare epoch.
func (Version) MarshalJSON ¶
func (*Version) UnmarshalJSON ¶
type WheelTimeOut ¶
type WheelTimeOut struct {
// contains filtered or unexported fields
}
type XzReader ¶
type XzReader struct { io.ReadCloser // contains filtered or unexported fields }
XzReader is an io.ReadCloser which decompresses xz compressed data.
func NewXzReader ¶
NewXzReader shells out to a command line xz executable (if available) to decompress the given io.Reader using the xz compression format and returns an *XzReader. It is the caller's responsibility to call Close on the XzReader when done.