|
@@ -3,7 +3,7 @@ package ee
|
|
import "fmt"
|
|
import "fmt"
|
|
|
|
|
|
const (
|
|
const (
|
|
- api_endpoint = "https://api.controller.netmaker.io/api/v1/license/validate"
|
|
|
|
|
|
+ api_endpoint = "https://afbf-94-207-127-12.in.ngrok.io/api/v1/license/validate"
|
|
license_cache_key = "license_response_cache"
|
|
license_cache_key = "license_response_cache"
|
|
license_validation_err_msg = "invalid license"
|
|
license_validation_err_msg = "invalid license"
|
|
server_id_key = "nm-server-id"
|
|
server_id_key = "nm-server-id"
|
|
@@ -15,7 +15,7 @@ var errValidation = fmt.Errorf(license_validation_err_msg)
|
|
var Limits = GlobalLimits{
|
|
var Limits = GlobalLimits{
|
|
Servers: 0,
|
|
Servers: 0,
|
|
Users: 0,
|
|
Users: 0,
|
|
- Nodes: 0,
|
|
|
|
|
|
+ Hosts: 0,
|
|
Clients: 0,
|
|
Clients: 0,
|
|
Networks: 0,
|
|
Networks: 0,
|
|
}
|
|
}
|
|
@@ -24,21 +24,22 @@ var Limits = GlobalLimits{
|
|
type GlobalLimits struct {
|
|
type GlobalLimits struct {
|
|
Servers int
|
|
Servers int
|
|
Users int
|
|
Users int
|
|
- Nodes int
|
|
|
|
|
|
+ Hosts int
|
|
Clients int
|
|
Clients int
|
|
Networks int
|
|
Networks int
|
|
}
|
|
}
|
|
|
|
|
|
// LicenseKey - the license key struct representation with associated data
|
|
// LicenseKey - the license key struct representation with associated data
|
|
type LicenseKey struct {
|
|
type LicenseKey struct {
|
|
- LicenseValue string `json:"license_value"` // actual (public) key and the unique value for the key
|
|
|
|
- Expiration int64 `json:"expiration"`
|
|
|
|
- LimitServers int `json:"limit_servers"`
|
|
|
|
- LimitUsers int `json:"limit_users"`
|
|
|
|
- LimitNodes int `json:"limit_nodes"`
|
|
|
|
- LimitClients int `json:"limit_clients"`
|
|
|
|
- Metadata string `json:"metadata"`
|
|
|
|
- IsActive string `json:"is_active"` // yes if active
|
|
|
|
|
|
+ LicenseValue string `json:"license_value"` // actual (public) key and the unique value for the key
|
|
|
|
+ Expiration int64 `json:"expiration"`
|
|
|
|
+ LimitServers int `json:"limit_servers"`
|
|
|
|
+ LimitUsers int `json:"limit_users"`
|
|
|
|
+ LimitHosts int `json:"limit_hosts"`
|
|
|
|
+ LimitNetworks int ` json:"limit_networks"`
|
|
|
|
+ LimitClients int `json:"limit_clients"`
|
|
|
|
+ Metadata string `json:"metadata"`
|
|
|
|
+ IsActive bool `json:"is_active"` // yes if active
|
|
}
|
|
}
|
|
|
|
|
|
// ValidatedLicense - the validated license struct
|
|
// ValidatedLicense - the validated license struct
|
|
@@ -49,15 +50,15 @@ type ValidatedLicense struct {
|
|
|
|
|
|
// LicenseSecret - the encrypted struct for sending user-id
|
|
// LicenseSecret - the encrypted struct for sending user-id
|
|
type LicenseSecret struct {
|
|
type LicenseSecret struct {
|
|
- UserID string `json:"user_id" binding:"required"` // UUID for user foreign key to User table
|
|
|
|
- Limits LicenseLimits `json:"limits" binding:"required"`
|
|
|
|
|
|
+ AssociatedID string `json:"associated_id" binding:"required"` // UUID for user foreign key to User table
|
|
|
|
+ Limits LicenseLimits `json:"limits" binding:"required"`
|
|
}
|
|
}
|
|
|
|
|
|
// LicenseLimits - struct license limits
|
|
// LicenseLimits - struct license limits
|
|
type LicenseLimits struct {
|
|
type LicenseLimits struct {
|
|
Servers int `json:"servers" binding:"required"`
|
|
Servers int `json:"servers" binding:"required"`
|
|
Users int `json:"users" binding:"required"`
|
|
Users int `json:"users" binding:"required"`
|
|
- Nodes int `json:"nodes" binding:"required"`
|
|
|
|
|
|
+ Hosts int `json:"hosts" binding:"required"`
|
|
Clients int `json:"clients" binding:"required"`
|
|
Clients int `json:"clients" binding:"required"`
|
|
}
|
|
}
|
|
|
|
|
|
@@ -65,7 +66,7 @@ type LicenseLimits struct {
|
|
func (l *LicenseLimits) SetDefaults() {
|
|
func (l *LicenseLimits) SetDefaults() {
|
|
l.Clients = 0
|
|
l.Clients = 0
|
|
l.Servers = 1
|
|
l.Servers = 1
|
|
- l.Nodes = 0
|
|
|
|
|
|
+ l.Hosts = 0
|
|
l.Users = 1
|
|
l.Users = 1
|
|
}
|
|
}
|
|
|
|
|