license

package
v0.0.0-...-aefcfe0 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2022 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const HMACKeyForLimitsEncryption = "HMACKeyForLimitsEncryption"

HMACKeyForLimitsEncryption

View Source
const PublicKeyBase64 = "" /* 132-byte string literal not displayed */

the public key b64 encoded from the private key using: lkgen pub my_private_key_file`.

View Source
const TestLicense = "" /* 544-byte string literal not displayed */

TestLicense used in unit tests

Variables

View Source
var ErrOverLimit = errors.New("limit is over")

ErrOverLimit contains error for over limit

View Source
var TotalLimitDuration = "864000h"

TotalLimitDuration is a time duration to be used for total time range in a string representation 864000h is equal to 100 years

Functions

func Initialize

func Initialize(licenseBytes []byte) error

Initialize extracts license from the bytes provided to LD variable and stores it inside the db

func Load

func Load() error

Load loads the license from the db and extracts it to LD variable

Types

type LicenseData

type LicenseData struct {
	// Name represents the name license assigned to
	Name string `json:"n"`
	// Email represents email address of the license owner
	Email string `json:"e"`
	// End represents the date when license ends
	End time.Time `json:"end"`
	// Limits represents limits assigned to the license
	Limits []*ratelimiter.Limit `json:"l"`
	// MaxDirectoryWatchers represents maximum allowed directories to watch with watch and sign service
	MaxDirectoryWatchers int `json:"d"`

	// RL contains rate limiter
	RL *ratelimiter.RateLimiter `json:"-"`
	// contains filtered or unexported fields
}

LicenseData represents all the license related data

var LD LicenseData

LD stores all the license related data

func (*LicenseData) AutoSave

func (ld *LicenseData) AutoSave()

AutoSave saves state every second

func (*LicenseData) Info

func (ld *LicenseData) Info() string

Info returns formatted information about the license

func (*LicenseData) SaveLimitState

func (ld *LicenseData) SaveLimitState() error

SaveLimitState saves the limit state to the db

func (*LicenseData) Wait

func (ld *LicenseData) Wait() error

Wait validates license end data and limits, if one of the limits are reached, waits the time till the work is allowed again

Directories

Path Synopsis
Package ratelimiter implements rate limiting functionality.
Package ratelimiter implements rate limiting functionality.

Jump to

Keyboard shortcuts

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