tools

package
v0.1.43 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2022 License: MIT Imports: 30 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CancelError = errors.New("CancelError")

CancelError signals user-initiated cancellation

View Source
var SilentError = errors.New("SilentError")

SilentError is an error that triggers exit code 1 without any error messaging

Functions

func ArchiveAndCompressFiles

func ArchiveAndCompressFiles(files []*os.File) (*os.File, int64, error)

ArchiveAndCompressFiles tars and gzip-compresses files into a temporary file, returning it along with the resulting size

func Contains

func Contains(s []string, str string) bool

func DecodePayload

func DecodePayload(payload interface{}, target interface{}) (err error)

func DecompressAndUnarchiveBytes

func DecompressAndUnarchiveBytes(reader io.Reader) ([]string, int64, error)

DecompressAndUnarchiveBytes gzip-decompresses and un-tars files into the current working directory and returns the names and decompressed size of the created files

func DisplayWidth

func DisplayWidth(s string) int

DisplayWidth calculates what the rendered width of a string may be

func FilesTotalSize

func FilesTotalSize(files []*os.File) (int64, error)

Traverses files and directories (recursively) for total size in bytes

func GeneratePassword

func GeneratePassword(id int) models.Password

GeneratePassword generates a random password prefixed with the supplied id.

func GetOpenPort

func GetOpenPort() (int, error)

func HashPassword

func HashPassword(password models.Password) string

func Indent

func Indent(s, indent string) string

func IsUserCancellation

func IsUserCancellation(err error) bool

func MutuallyExclusive

func MutuallyExclusive(message string, conditions ...bool) error

func ParsePassword

func ParsePassword(passStr string) (models.Password, error)

func PrintError

func PrintError(out io.Writer, err error, cmd *cobra.Command, debug bool)

func RandomSeed

func RandomSeed()

func ReadEncryptedMessage

func ReadEncryptedMessage(wsConn *websocket.Conn, crypt *crypt.Crypt) (protocol.TransferMessage, error)

func ReadFiles

func ReadFiles(fileNames []string) ([]*os.File, error)

func ReadTranxMessage

func ReadTranxMessage(wsConn *websocket.Conn, expected protocol.TranxMessageType) (protocol.TranxMessage, error)

func RemoveTemporaryFiles

func RemoveTemporaryFiles(prefix string)

func ReplaceExcessiveWhitespace

func ReplaceExcessiveWhitespace(s string) string

func Truncate

func Truncate(maxWidth int, s string) string

Truncate shortens a string to fit the maximum display width

func TruncateColumn

func TruncateColumn(maxWidth int, s string) string

TruncateColumn replaces the first new line character with an ellipsis and shortens a string to fit the maximum display width

func ValidateHostname

func ValidateHostname(name string) error

ValidateHostname returns an error if the domain name is not valid source: https://gist.github.com/chmike/d4126a3247a6d9a70922fc0e8b4f4013

func WebsocketHandler

func WebsocketHandler(wsHandler WsHandlerFunc) http.HandlerFunc

func WriteEncryptedMessage

func WriteEncryptedMessage(wsConn *websocket.Conn, msg protocol.TransferMessage, crypt *crypt.Crypt) error

Types

type FlagError

type FlagError struct {
	Err error
}

FlagError is the kind of error raised in flag processing

func (FlagError) Error

func (fe FlagError) Error() string

func (FlagError) Unwrap

func (fe FlagError) Unwrap() error

type WsHandlerFunc

type WsHandlerFunc func(*websocket.Conn)

Jump to

Keyboard shortcuts

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