mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-19 15:15:17 +08:00
initial commit
This commit is contained in:
54
ee/util.go
Normal file
54
ee/util.go
Normal file
@@ -0,0 +1,54 @@
|
||||
package ee
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
|
||||
"github.com/gravitl/netmaker/logic"
|
||||
)
|
||||
|
||||
var isEnterprise bool
|
||||
|
||||
// SetIsEnterprise - sets server to use enterprise features
|
||||
func SetIsEnterprise() {
|
||||
isEnterprise = true
|
||||
}
|
||||
|
||||
// IsEnterprise - checks if enterprise binary or not
|
||||
func IsEnterprise() bool {
|
||||
return 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()
|
||||
nodes, err := logic.GetAllNodes()
|
||||
if err == nil {
|
||||
limits.Nodes = len(nodes)
|
||||
}
|
||||
clients, err := logic.GetAllExtClients()
|
||||
if err == nil {
|
||||
limits.Clients = len(clients)
|
||||
}
|
||||
users, err := logic.GetUsers()
|
||||
if err == nil {
|
||||
limits.Users = len(users)
|
||||
}
|
||||
limits.Servers = getServerCount()
|
||||
return
|
||||
}
|
Reference in New Issue
Block a user