internal

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2021 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PermFlush Permission to restart/reload the system including flushing/forcing the queues
	PermFlush string = "flush"
	// PermGenerateInvites Permission to generate invites remotely
	PermGenerateInvites string = "invite"
	// PermAPIKeys Permission to create api keys
	PermAPIKeys string = "apikey"
	// PermGetHeaders allows you to fetch header and catalog from messages
	PermGetHeaders string = "get-headers"
)

Variables

View Source
var (
	// BuildDate as filled in during compilation
	BuildDate string
	// GitCommit sha as filled in during compilation
	GitCommit string
	// VersionTag is the v0.0.0 version to use
	VersionTag = "0.0.0"
)
View Source
var AccountPermissions = []string{
	PermGetHeaders,
}

AccountPermissions is a set of permissions for specific accounts

View Source
var ManagementPermissions = []string{
	PermAPIKeys,
	PermFlush,
	PermGenerateInvites,
}

ManagementPermissions is a list of all permissions available for remote management

View Source
var Version = semver.New(strings.Replace(VersionTag, "v", "", 1))

Version is a structure with the current version of the software

Functions

func CheckAccountPermissions

func CheckAccountPermissions(perms []string) error

CheckAccountPermissions checks all permission and returns an error when a permission is not valid

func CheckManagementPermissions

func CheckManagementPermissions(perms []string) error

CheckManagementPermissions checks all permission and returns an error when a permission is not valid

func Decode

func Decode(src []byte) ([]byte, error)

Decode base64 back into bytes

func EditFile

func EditFile(file string) error

EditFile allows you to inplace edit a file until the editor returns success status

func Encode

func Encode(src []byte) []byte

Encode data into base64

func GenerateKeypairFromMnemonic added in v0.0.1

func GenerateKeypairFromMnemonic(mnemonic string) (*bmcrypto.KeyPair, error)

GenerateKeypairFromMnemonic generates a keypair based on the given mnemonic

func GenerateKeypairWithRandomSeed added in v0.0.1

func GenerateKeypairWithRandomSeed(kt bmcrypto.KeyType) (*bmcrypto.KeyPair, error)

GenerateKeypairWithRandomSeed generates a seed and generates a keypair which can be reconstructed again with the same seed

func GetASCIILogo() string

GetASCIILogo returns ASCII logo with or without colors depending on your console settings

func GetMnemonic added in v0.0.1

func GetMnemonic(kp *bmcrypto.KeyPair) string

GetMnemonic will return a mnemonic representation of the given keypair

func GetMonochromeASCIILogo() string

GetMonochromeASCIILogo returns the monochrome version of the logo

func JSONFileEditor

func JSONFileEditor(src interface{}, dst interface{}) error

JSONFileEditor will open a text editor where you can manually edit the given src json

func MnemonicToRandomSeed added in v0.0.1

func MnemonicToRandomSeed(mnemonic string) ([]byte, error)

MnemonicToRandomSeed converts a mnemonic to a random seed

func ParseDuration

func ParseDuration(s string) (time.Duration, error)

ParseDuration will parse a string into a duration. This works pretty much the same way as the regular duration parser, except with larger times.

It supports:

 3y       // 3 years
 5w       // 5 weeks
 4d       // 4 days
14h       // 14 hours
52m       // 52 minutes

or any combination of them. Any order is possible, but no two of the same units are allowed (1d4m3d for example).

func ParseOptions

func ParseOptions(opts interface{})

ParseOptions will parse the commandline options given by opts. It will exit when issues arise or help is wanted

func RandomSeedToMnemonic added in v0.0.1

func RandomSeedToMnemonic(seed []byte) (string, error)

RandomSeedToMnemonic converts a random seed to a mnemonic

func Reload

func Reload()

Reload will reload any configuration changes without restarting the server

func SetLogging

func SetLogging(format, level, path string)

SetLogging will set the correct level and log path

func TimeNow

func TimeNow() time.Time

TimeNow returns the current time in UTC zone WITHOUT nanoseconds. This is useful when marshalling times to JSON

func ValidDuration

func ValidDuration(ds string) (time.Duration, error)

ValidDuration gets a time duration string and return the time duration. Accepts single int as days

func VersionString

func VersionString(name string) string

VersionString returns a string with all version information

func WordWrap

func WordWrap(s string, limit int) string

WordWrap wraps sentences to a maximum length of limit.

func WriteVersionInfo

func WriteVersionInfo(name string, w io.Writer)

WriteVersionInfo writes a string with all version information

Types

type HTTPLogger

type HTTPLogger struct {
}

HTTPLogger is a structure that allows to log HTTP requests and responses

func NewHTTPLogger

func NewHTTPLogger() *HTTPLogger

NewHTTPLogger returns a new http logger

func (*HTTPLogger) LogRequest

func (l *HTTPLogger) LogRequest(req *http.Request)

LogRequest will log the request

func (*HTTPLogger) LogResponse

func (l *HTTPLogger) LogResponse(req *http.Request, res *http.Response, err error, duration time.Duration)

LogResponse will log the response

type RedisBridge

type RedisBridge struct {
	Client redis.Client
}

RedisBridge forms a bridge between a redis-client and redis implementors. This is needed to get rid of the ".Result()" calls, which makes mocking and testing difficult.

func (RedisBridge) Del

func (r RedisBridge) Del(ctx context.Context, keys ...string) (int64, error)

Del removes a key

func (RedisBridge) Exists

func (r RedisBridge) Exists(ctx context.Context, key string) (int64, error)

Exists checks if a key exists

func (RedisBridge) Get

func (r RedisBridge) Get(ctx context.Context, key string) (string, error)

Get fetches a key

func (RedisBridge) SAdd

func (r RedisBridge) SAdd(ctx context.Context, key string, members ...interface{}) (int64, error)

SAdd adds a key to a set

func (RedisBridge) SMembers

func (r RedisBridge) SMembers(ctx context.Context, key string) ([]string, error)

SMembers returns a set

func (RedisBridge) SRem

func (r RedisBridge) SRem(ctx context.Context, key string, members ...interface{}) (int64, error)

SRem removes a key from a set

func (RedisBridge) Set

func (r RedisBridge) Set(ctx context.Context, key string, value interface{}, expiration time.Duration) (string, error)

Set stores a key

type RedisResultWrapper

type RedisResultWrapper interface {
	Del(ctx context.Context, keys ...string) (int64, error)
	Get(ctx context.Context, key string) (string, error)
	Exists(ctx context.Context, key string) (int64, error)
	Set(ctx context.Context, key string, value interface{}, expiration time.Duration) (string, error)
	SMembers(ctx context.Context, key string) ([]string, error)
	SAdd(ctx context.Context, key string, members ...interface{}) (int64, error)
	SRem(ctx context.Context, key string, members ...interface{}) (int64, error)
}

RedisResultWrapper This is the our redis repository. It only contains the methods we really need.

type RoutingInfo

type RoutingInfo struct {
	RoutingID string                   `json:"routing_id"`    // ID
	PrivKey   bmcrypto.PrivKey         `json:"priv_key"`      // PEM encoded private key
	PubKey    bmcrypto.PubKey          `json:"pub_key"`       // PEM encoded public key
	Pow       *proofofwork.ProofOfWork `json:"pow,omitempty"` // Proof of work
	Route     string                   `json:"route"`         // Route to server
}

RoutingInfo represents a routing configuration for a server

Jump to

Keyboard shortcuts

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