license_commons

package
v0.2.67 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2024 License: BSD-3-Clause Imports: 9 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	LicenseNotFoundError                  = errors.New("license_not_found_error")
	LicenseConfigurationFileNotFoundError = errors.New("license_config_not_found_error")
	LicenseExpiredError                   = errors.New("license_expired_error")
)
View Source
var KEY = "G&G-license-key-fake______________"

Functions

func Decode

func Decode(data []byte) (response []byte, err error)

func DecodeText

func DecodeText(text string) (response string, err error)

func Download

func Download(url string) ([]byte, error)

func Encode

func Encode(data []byte) (response []byte, err error)

func EncodeText

func EncodeText(text string) (response string, err error)

func IsJSON

func IsJSON(bytes []byte) bool

func IsValidPacket

func IsValidPacket(bytes []byte) bool

Types

type License

type License struct {
	Uid          string                 `json:"uid"`
	CreationTime time.Time              `json:"creation_time"`
	DurationDays int64                  `json:"duration_days"`
	Name         string                 `json:"name"`
	Email        string                 `json:"email"`
	Lang         string                 `json:"lang"`
	Enabled      bool                   `json:"enabled"`
	Params       map[string]interface{} `json:"params"`
}

func NewLicense

func NewLicense(uid string) *License

func (*License) Add

func (instance *License) Add(days int64)

func (*License) Encode

func (instance *License) Encode() (text string, err error)

func (*License) GetDataAsString

func (instance *License) GetDataAsString() string

func (*License) GetExpireDate

func (instance *License) GetExpireDate() time.Time

func (*License) IsValid

func (instance *License) IsValid() bool

func (*License) Parse

func (instance *License) Parse(text string) error

func (*License) ParseBytes

func (instance *License) ParseBytes(bytes []byte) error

func (*License) ParseExpireDate

func (instance *License) ParseExpireDate(layout string, value string) error

func (*License) ReadFromFile

func (instance *License) ReadFromFile(filename string) (err error)

func (*License) RemainingDays

func (instance *License) RemainingDays() int64

func (*License) SaveToFile

func (instance *License) SaveToFile(filename string) (err error)

func (*License) SetExpireDate

func (instance *License) SetExpireDate(date time.Time)

func (*License) String

func (instance *License) String() string

type LicenseConfig

type LicenseConfig struct {
	Host   string `json:"host"`
	Port   int    `json:"port"`
	Path   string `json:"path"`
	UseSSL bool   `json:"use_ssl"`
}

func (*LicenseConfig) GetRequestFileName

func (instance *LicenseConfig) GetRequestFileName() string

GetRequestFileName ---- Return file name if 'Path' is a static file, otherwise returns empty string. Path can be both a static file ("/licenses/lic.json") or url invoking a remote endpoint ("/endpoint?uid=123&act=get") ----

func (*LicenseConfig) Parse

func (instance *LicenseConfig) Parse(text string) error

func (*LicenseConfig) ToString

func (instance *LicenseConfig) ToString() string

Jump to

Keyboard shortcuts

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