utils

package
v0.0.0-...-f02d5ee Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2022 License: MIT Imports: 15 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	REDIS_HOST      string
	REDIS_PASSWORD  string
	REDIS_PORT      string
	REDIS_DB        string
	REDIS_PREFIX    string
	TOKEN_SEPARATOR string
	NO_SSL          bool = false
	APP_PORT        string
	APP_NAME        string
	DISCLAIMER      string
	COPYRIGHT       string
	FILEFOLDER      string
	MAXFILESIZE     string
	MaxFileSize     int64
	DataContext     pongo2.Context
)

Functions

func CleanFile

func CleanFile(fileName string)

func CleanFileWatch

func CleanFileWatch()

*

  • Subscribe to redis and check when a key expire then clean the associated file

func Decrypt

func Decrypt(password []byte, decryptionKey string, ttl int) (string, error)

*

  • Decrypt a password (bytes) using the provided key (bytes) and return the plain-text password (bytes).
  • @param password
  • @param decryption_key

func Encrypt

func Encrypt(password string) ([]byte, string, error)

* Take a password string, encrypt it with Fernet symmetric encryption and return the result (bytes), with the decryption key (bytes) * @param password

func EnvInit

func EnvInit()

func GetBaseUrl

func GetBaseUrl(context echo.Context) string

*

  • Return url with http or https based on NO_SSL env value

func GetFile

func GetFile(f *models.File) *echo.HTTPError

func GetMaxFileSizeText

func GetMaxFileSizeText() string

func GetTTLText

func GetTTLText(ttl int) (ttlText string)

* Transforme TTL to text

func GetTtlSeconds

func GetTtlSeconds(ttl int) int

*

  • Transforme TTL from form to seconds

func ParseToken

func ParseToken(token string) (string, string, error)

*

  • Return splitted token
  • @param token

func Ping

func Ping(c redis.Conn) bool

ping tests connectivity for redis (PONG should be returned)

func RandomSequence

func RandomSequence(n int) string

func RemoveFile

func RemoveFile(f *models.File) *echo.HTTPError

func RemovePassword

func RemovePassword(p *models.Password) *echo.HTTPError

*

  • Remove a password from the redis store. If an error occur we return a not found

func RetrieveFilePassword

func RetrieveFilePassword(f *models.File) *echo.HTTPError

func RetrievePassword

func RetrievePassword(p *models.Password) *echo.HTTPError

func SetFile

func SetFile(password string, ttl int, views int, deletable, provided bool, providedKey string) (string, *echo.HTTPError)

*

  • Encrypt and store the password for the specified lifetime.
  • Returns a token comprised of the key where the encrypted password is stored, and the decryption key.
  • @param {string} password
  • @param {number} ttl
  • @param {number} views
  • @param {boolean} deletable
  • @return {string} token

func SetPassword

func SetPassword(password string, ttl int, views int, deletable bool) (string, *echo.HTTPError)

*

  • Encrypt and store the password for the specified lifetime.
  • Returns a token comprised of the key where the encrypted password is stored, and the decryption key.
  • @param {string} password
  • @param {number} ttl
  • @param {number} views
  • @param {boolean} deletable
  • @return {string, error} token, error

Types

This section is empty.

Jump to

Keyboard shortcuts

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