util

package
v1.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 5, 2023 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultTokenSize  = 32 // 256-bit AES key
	DefaultLongIdSize = 16 // 128-bit

	NodeIdBits = 48
	NodeIdSize = NodeIdBits / 8

	Encoding = base64.RawURLEncoding
)

Functions

func AppendFile

func AppendFile(filename string, filePerm os.FileMode, format string, args ...interface{}) error

func BackupFile

func BackupFile(filePath string, filePerm os.FileMode) (int64, error)

func CopyFile

func CopyFile(src string, dst string, perm os.FileMode) (int64, error)

func CreateFileIfNeeded

func CreateFileIfNeeded(fileName string, fileperm os.FileMode) error

func DecodeId

func DecodeId(base62str string) (uint64, error)

func DecodeLongId

func DecodeLongId(base62str string) ([]byte, error)

func EncodeId

func EncodeId(id uint64) string

func EncodeLongId

func EncodeLongId(id []byte) string

func FindGatewayHandler

func FindGatewayHandler(srv *http.Server, pattern string) (*rt.ServeMux, error)

func GenerateAuthToken

func GenerateAuthToken(secretKey []byte, user *sauce.AuthorizedUser) (string, error)

func GenerateLongId

func GenerateLongId() (string, error)

func GenerateNodeId

func GenerateNodeId() (string, error)

func GenerateToken

func GenerateToken() (string, error)

func IsFileLocked

func IsFileLocked(filePath string) bool

func PackGzipData

func PackGzipData(plain []byte) ([]byte, error)

func ParseClientAuth

func ParseClientAuth(s string) tls.ClientAuthType

func ParseFileMode

func ParseFileMode(s string) os.FileMode

* Parses only os.Unix file mode with 0777 mask

func ParseNodeId

func ParseNodeId(nodeId string) (uint64, error)

func ParseToken

func ParseToken(base64key string) ([]byte, error)

func Prompt

func Prompt(request string) string

func PromptPEM

func PromptPEM(request string) (string, error)

func PromptPassword

func PromptPassword(request string) string

func PromptQuery

func PromptQuery(request string) string

func Promptf

func Promptf(request string, args ...interface{}) string

func RemoveFileIfExist

func RemoveFileIfExist(filePath string) error

func ToFqdn

func ToFqdn(name string) string

ToFqdn converts the name into a fqdn appending a trailing dot.

func ToZone

func ToZone(domain string) (string, error)

func UnFqdn

func UnFqdn(name string) string

UnFqdn converts the fqdn into a name removing the trailing dot.

func UnpackGzipData

func UnpackGzipData(compressed []byte) ([]byte, error)

func UnpackGzipFile

func UnpackGzipFile(inputFilePath, outputFilePath string, filePerm os.FileMode) (int64, error)

func UnpackTarGzipFile

func UnpackTarGzipFile(fileName string, inputFilePath, outputFilePath string, filePerm os.FileMode) (int64, error)

func VerifyAuthToken

func VerifyAuthToken(secretKey []byte, jwtToken string) (*sauce.AuthorizedUser, error)

Types

type RateLimiter

type RateLimiter struct {
	Limit time.Duration
	// contains filtered or unexported fields
}

func (*RateLimiter) Do

func (t *RateLimiter) Do(fn func() error) error

type UserClaims

type UserClaims struct {
	Roles   []string          `json:"roles"`
	Context map[string]string `json:"ctx"`
	jwt.StandardClaims
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL