Documentation ¶
Index ¶
- Constants
- Variables
- func CheckAccountPermissions(perms []string) error
- func CheckManagementPermissions(perms []string) error
- func Decode(src []byte) ([]byte, error)
- func EditFile(file string) error
- func Encode(src []byte) []byte
- func GenerateKeypairFromMnemonic(mnemonic string) (*bmcrypto.KeyPair, error)
- func GenerateKeypairWithRandomSeed(kt bmcrypto.KeyType) (*bmcrypto.KeyPair, error)
- func GetASCIILogo() string
- func GetMnemonic(kp *bmcrypto.KeyPair) string
- func GetMonochromeASCIILogo() string
- func JSONFileEditor(src interface{}, dst interface{}) error
- func MnemonicToRandomSeed(mnemonic string) ([]byte, error)
- func ParseDuration(s string) (time.Duration, error)
- func ParseOptions(opts interface{})
- func RandomSeedToMnemonic(seed []byte) (string, error)
- func Reload()
- func SetLogging(format, level, path string)
- func TimeNow() time.Time
- func ValidDuration(ds string) (time.Duration, error)
- func VersionString(name string) string
- func WordWrap(s string, limit int) string
- func WriteVersionInfo(name string, w io.Writer)
- type HTTPLogger
- type RedisBridge
- func (r RedisBridge) Del(ctx context.Context, keys ...string) (int64, error)
- func (r RedisBridge) Exists(ctx context.Context, key string) (int64, error)
- func (r RedisBridge) Get(ctx context.Context, key string) (string, error)
- func (r RedisBridge) SAdd(ctx context.Context, key string, members ...interface{}) (int64, error)
- func (r RedisBridge) SMembers(ctx context.Context, key string) ([]string, error)
- func (r RedisBridge) SRem(ctx context.Context, key string, members ...interface{}) (int64, error)
- func (r RedisBridge) Set(ctx context.Context, key string, value interface{}, expiration time.Duration) (string, error)
- type RedisResultWrapper
- type RoutingInfo
Constants ¶
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 ¶
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" )
var AccountPermissions = []string{ PermGetHeaders, }
AccountPermissions is a set of permissions for specific accounts
var ManagementPermissions = []string{ PermAPIKeys, PermFlush, PermGenerateInvites, }
ManagementPermissions is a list of all permissions available for remote management
var Version = semver.New(strings.Replace(VersionTag, "v", "", 1))
Version is a structure with the current version of the software
Functions ¶
func CheckAccountPermissions ¶
CheckAccountPermissions checks all permission and returns an error when a permission is not valid
func CheckManagementPermissions ¶
CheckManagementPermissions checks all permission and returns an error when a permission is not valid
func GenerateKeypairFromMnemonic ¶ added in v0.0.1
GenerateKeypairFromMnemonic generates a keypair based on the given mnemonic
func GenerateKeypairWithRandomSeed ¶ added in v0.0.1
GenerateKeypairWithRandomSeed generates a seed and generates a keypair which can be reconstructed again with the same seed
func GetASCIILogo ¶
func GetASCIILogo() string
GetASCIILogo returns ASCII logo with or without colors depending on your console settings
func GetMnemonic ¶ added in v0.0.1
GetMnemonic will return a mnemonic representation of the given keypair
func GetMonochromeASCIILogo ¶
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
MnemonicToRandomSeed converts a mnemonic to a random seed
func ParseDuration ¶
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
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 ¶
TimeNow returns the current time in UTC zone WITHOUT nanoseconds. This is useful when marshalling times to JSON
func ValidDuration ¶
ValidDuration gets a time duration string and return the time duration. Accepts single int as days
func VersionString ¶
VersionString returns a string with all version information
func WriteVersionInfo ¶
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 (*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.
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