Documentation
¶
Overview ¶
Package utils provides the util func
Package utils provides the util func ¶
Package utils offer utils for file watcher ¶
Package utils offer the some utils for certificate handling ¶
Package utils offer the some utils for certificate handling ¶
Package utils provides the util func ¶
Package utils this file for password handler ¶
Package utils provides the util func
Index ¶
- Constants
- func CheckMode(mode os.FileMode, optional ...os.FileMode) bool
- func CheckOwnerAndPermission(verifyPath string, mode os.FileMode, uid uint32) (string, error)
- func CheckPassWordComplexity(s []byte) error
- func CheckPath(path string) (string, error)
- func ClientIP(r *http.Request) string
- func CopyDir(src string, dst string) error
- func CopyFile(src, dst string) error
- func GetDriverLibPath(libraryName string) (string, error)
- func GetSha256Code(data []byte) []byte
- func IsDir(path string) bool
- func IsExist(filePath string) bool
- func IsFile(path string) bool
- func IsLexist(filePath string) bool
- func IsNil(i interface{}) bool
- func IsSoftlink(path string) (bool, error)
- func LoadFile(filePath string) ([]byte, error)
- func MakeSureDir(path string) error
- func MaskPrefix(source string) string
- func PathStringChecker(path string) (string, error)
- func ReadLimitBytes(path string, limitLength int) ([]byte, error)
- func RealDirChecker(path string, checkParent, allowLink bool) (string, error)
- func RealFileChecker(path string, checkParent, allowLink bool, size int64) (string, error)
- func ReplacePrefix(source, prefix string) string
- func ReverseString(s string) string
- func SafeChmod(path string, size int64, mode os.FileMode) error
- func ValidatePassWord(userName string, passWord []byte) error
- func VerifyFile(file *os.File, size int64) error
- type FileWatcher
Constants ¶
const ( // FileMode file privilege FileMode = 0600 // Size10M bytes of 10M Size10M = 10 * 1024 * 1024 )
const ( // DefaultWhiteList default white list in string DefaultWhiteList = "-_./~" // DefaultStringLength default string max length DefaultStringLength = 256 // DefaultPathLength default path max length DefaultPathLength = 4096 )
const (
// DefaultWriteFileMode default file mode for write permission check
DefaultWriteFileMode = 0022
)
const (
// SplitFlag backup file splitflag
SplitFlag = "\n</=--*^^||^^--*=/>"
)
Variables ¶
This section is empty.
Functions ¶
func CheckMode ¶
CheckMode check input file mode whether includes invalid mode. For example, if read operation of group and other is forbidden, then call CheckMode(inputFileMode, 0044). All operations are forbidden for group and other, then call CheckMode(inputFileMode, 0077). Write operation is forbidden for group and other by default, with calling CheckMode(inputFileMode)
func CheckOwnerAndPermission ¶
CheckOwnerAndPermission check path owner and permission
func CheckPassWordComplexity ¶
CheckPassWordComplexity check password complexity
func GetDriverLibPath ¶
GetDriverLibPath get driver lib path from ld config
func GetSha256Code ¶
GetSha256Code return the sha256 hash bytes
func IsExist ¶
IsExist check whether the path exists, If the file is a symbolic link, the returned the final FileInfo
func IsLexist ¶
IsLexist check whether the path exists, If the file is a symbolic link, the returned FileInfo describes the symbolic link
func IsNil ¶
func IsNil(i interface{}) bool
IsNil check whether the interface is nil, including type or data is nil
func IsSoftlink ¶
IsSoftlink check whether the path is softlink
func MakeSureDir ¶
MakeSureDir create directory. The last element of path should end with slash, or it will be omitted.
func PathStringChecker ¶
PathStringChecker Check whether the directory string is valid
func ReadLimitBytes ¶
ReadLimitBytes read limit length of contents from file path
func RealDirChecker ¶
RealDirChecker Check whether the directory is valid
func RealFileChecker ¶
RealFileChecker Check whether the file is valid
func ReplacePrefix ¶
ReplacePrefix replace string with prefix
func ValidatePassWord ¶
ValidatePassWord validate password
Types ¶
type FileWatcher ¶
type FileWatcher struct {
// contains filtered or unexported fields
}
FileWatcher struct file watcher
func GetFileWatcherChan ¶
func GetFileWatcherChan(filePath string) (*FileWatcher, error)
GetFileWatcherChan get eventCh and errCh for file watcher
func (*FileWatcher) Events ¶
func (fw *FileWatcher) Events() chan fsnotify.Event
Events get event channel
func (*FileWatcher) WatchFile ¶
func (fw *FileWatcher) WatchFile(filePath string) error
WatchFile add file to watch