license

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddLicenseHooks

func AddLicenseHooks()

AddLicenseHooks - adds the validation hook

func ClientLimitExceeded added in v1.7.0

func ClientLimitExceeded(ctx context.Context) bool

func EgressLimitExceeded added in v1.7.0

func EgressLimitExceeded(ctx context.Context) bool

func EnforceLimits added in v1.7.0

func EnforceLimits(ctx context.Context) bool

func ErrLicenseValidation added in v1.7.0

func ErrLicenseValidation(ctx context.Context) error

func FetchApiServerKeys

func FetchApiServerKeys(ctx context.Context) (pub *[32]byte, priv *[32]byte, err error)

FetchApiServerKeys - fetches netmaker license keys for identification as well as secure communication with API if none present, it generates a new pair

func GetFeatureFlags added in v1.7.0

func GetFeatureFlags(ctx context.Context) models.FeatureFlags

func HostLimitExceeded added in v1.7.0

func HostLimitExceeded(ctx context.Context) bool

func IngressLimitExceeded added in v1.7.0

func IngressLimitExceeded(ctx context.Context) bool

func IsMSP added in v1.7.0

func IsMSP(ctx context.Context) bool

func NetworkLimitExceeded added in v1.7.0

func NetworkLimitExceeded(ctx context.Context) bool

func SyncOrgAndTenants added in v1.7.0

func SyncOrgAndTenants(ctx context.Context) error

func UserLimitExceeded added in v1.7.0

func UserLimitExceeded(ctx context.Context) bool

func ValidateLicense

func ValidateLicense(ctx context.Context, clearCache bool) (err error)

ValidateLicense - the initial and periodic license check for netmaker server checks if a license is valid + limits are not exceeded if license is free_tier and limits exceeds, then function should error if license is not valid, function should error

Types

type LicenseKey

type LicenseKey struct {
	LicenseValue   string `json:"license_value"` // actual (public) key and the unique value for the key
	Expiration     int64  `json:"expiration" swaggertype:"primitive,integer" format:"int64"`
	UsageServers   int    `json:"limit_servers"`
	UsageUsers     int    `json:"limit_users"`
	UsageClients   int    `json:"limit_clients"`
	UsageHosts     int    `json:"limit_hosts"`
	UsageNetworks  int    `json:"limit_networks"`
	UsageIngresses int    `json:"limit_ingresses"`
	UsageEgresses  int    `json:"limit_egresses"`
	Metadata       string `json:"metadata"`
	IsActive       bool   `json:"is_active"` // yes if active
}

LicenseKey - the license key struct representation with associated data

type LicenseOrg added in v1.7.0

type LicenseOrg struct {
	ID       string `json:"id"`
	Name     string `json:"name"`
	Metadata string `json:"metadata"`
	Status   string `json:"status"`
}

type LicenseSecret

type LicenseSecret struct {
	AssociatedID string                  `json:"associated_id" binding:"required"` // UUID for user foreign key to User table
	Usage        models.Usage            `json:"limits"        binding:"required"`
	TenantUsage  map[string]models.Usage `json:"tenant_usage"`
}

LicenseSecret - the encrypted struct for sending user-id

type LicenseTenant added in v1.7.0

type LicenseTenant struct {
	ID            string              `json:"id"`
	Name          string              `json:"name"`
	Metadata      string              `json:"metadata"`
	Status        TenantStatusMessage `json:"status"`
	EnforceLimits bool                `json:"enforce_limits"`
	Limits        Limits              `json:"limits"`
	FeatureFlags  models.FeatureFlags `json:"feature_flags"`
}

type Limits added in v1.7.0

type Limits struct {
	Servers   int `json:"servers"`
	Users     int `json:"users"`
	Clients   int `json:"clients"`
	Hosts     int `json:"hosts"`
	Networks  int `json:"networks"`
	Machines  int `json:"machines"`
	Ingresses int `json:"ingresses"`
	Egresses  int `json:"egresses"`
}

type TenantStatusMessage added in v1.7.0

type TenantStatusMessage string

TenantStatusMessage is an enumeration of the status of the tenant, represented as string message codes.

const (
	// TenantStatusOk indicates all is fine with the tenant status
	TenantStatusOk TenantStatusMessage = "ok"
	// TenantStatusPaymentInvalid indicates the user provided an invalid payment method (payment failed too many times)
	TenantStatusPaymentInvalid TenantStatusMessage = "payment_invalid"
	// TenantStatusPaymentMissing indicates the user has not provided a payment method
	TenantStatusPaymentMissing TenantStatusMessage = "payment_missing"
	// TenantStatusLicenseExpired indicates that the tenant's license has expired
	TenantStatusLicenseExpired TenantStatusMessage = "license_expired"
	// TenantStatusDeleted indicates the tenant has been deleted
	TenantStatusDeleted TenantStatusMessage = "deleted"
)

type ValidateLicenseRequest

type ValidateLicenseRequest struct {
	ServerVersion  string `json:"server_version"`
	LicenseKey     string `json:"license_key"       binding:"required"`
	NmServerPubKey string `json:"nm_server_pub_key" binding:"required"` // Netmaker server public key used to send data back to Netmaker for the Netmaker server to decrypt (eg output from validating license)
	EncryptedPart  string `json:"secret"            binding:"required"`
	NmBaseDomain   string `json:"nm_base_domain"`
}

ValidateLicenseRequest - used for request to validate license endpoint

type ValidatedLicense

type ValidatedLicense struct {
	LicenseValue     string              `json:"license_value"     binding:"required"` // license that validation is being requested for
	EncryptedLicense string              `json:"encrypted_license" binding:"required"` // to be decrypted by Netmaker using Netmaker server's private key
	DeploymentMode   string              `json:"deployment_mode"`
	FeatureFlags     models.FeatureFlags `json:"feature_flags" binding:"required"`
	Organization     LicenseOrg          `json:"organization"`
	Tenants          []LicenseTenant     `json:"tenants"`
}

ValidatedLicense - the validated license struct

Jump to

Keyboard shortcuts

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