mirror of
https://github.com/gravitl/netmaker.git
synced 2025-09-12 16:14:37 +08:00
* set free tier limits through config * add host limit to config * check for host limit on free tier * fix license validation, replace node limit with hosts * add hosts to telemetry data * debug init * validate license every 1hr * hook manager, api to fetch server usage * hook manager, server usage api * encode json server usage api * update ngork url * update license validation endpoint * avoid setting limits on eer * adding hotfix * correct users limits env var * add comments to exported funcs --------- Co-authored-by: afeiszli <alex.feiszli@gmail.com>
52 lines
1,023 B
Go
52 lines
1,023 B
Go
package ee
|
|
|
|
import (
|
|
"encoding/base64"
|
|
|
|
"github.com/gravitl/netmaker/logic"
|
|
)
|
|
|
|
var isEnterprise bool
|
|
|
|
// setIsEnterprise - sets server to use enterprise features
|
|
func setIsEnterprise() {
|
|
isEnterprise = true
|
|
logic.SetEEForTelemetry(isEnterprise)
|
|
}
|
|
|
|
// base64encode - base64 encode helper function
|
|
func base64encode(input []byte) string {
|
|
return base64.StdEncoding.EncodeToString(input)
|
|
}
|
|
|
|
// base64decode - base64 decode helper function
|
|
func base64decode(input string) []byte {
|
|
|
|
bytes, err := base64.StdEncoding.DecodeString(input)
|
|
|
|
if err != nil {
|
|
return nil
|
|
}
|
|
|
|
return bytes
|
|
}
|
|
func getCurrentServerLimit() (limits LicenseLimits) {
|
|
limits.SetDefaults()
|
|
hosts, err := logic.GetAllHosts()
|
|
if err == nil {
|
|
limits.Hosts = len(hosts)
|
|
}
|
|
clients, err := logic.GetAllExtClients()
|
|
if err == nil {
|
|
limits.Clients = len(clients)
|
|
}
|
|
users, err := logic.GetUsers()
|
|
if err == nil {
|
|
limits.Users = len(users)
|
|
}
|
|
networks, err := logic.GetNetworks()
|
|
if err == nil {
|
|
limits.Networks = len(networks)
|
|
}
|
|
return
|
|
}
|