mirror of
https://github.com/gravitl/netmaker.git
synced 2025-09-06 05:04:27 +08:00
* feat(NET-326): return 200 [] instead of 500 when there are not network acls * fix(NET-326): implement allow/deny client acl functions * fix(NET-326): implement extclient acl update * fix(NET-326): kame fixes, send peer updates
41 lines
1 KiB
Go
41 lines
1 KiB
Go
package logic
|
|
|
|
import "github.com/gravitl/netmaker/models"
|
|
|
|
// DenyClientNode - add a denied node to an ext client's list
|
|
func DenyClientNode(ec *models.ExtClient, clientOrNodeID string) (ok bool) {
|
|
if ec == nil || len(clientOrNodeID) == 0 {
|
|
return
|
|
}
|
|
if ec.DeniedACLs == nil {
|
|
ec.DeniedACLs = map[string]struct{}{}
|
|
}
|
|
ok = true
|
|
ec.DeniedACLs[clientOrNodeID] = struct{}{}
|
|
return
|
|
}
|
|
|
|
// IsClientNodeAllowed - checks if given ext client and node are allowed to communicate
|
|
func IsClientNodeAllowed(ec *models.ExtClient, clientOrNodeID string) bool {
|
|
if ec == nil || len(clientOrNodeID) == 0 {
|
|
return false
|
|
}
|
|
if ec.DeniedACLs == nil {
|
|
return true
|
|
}
|
|
_, ok := ec.DeniedACLs[clientOrNodeID]
|
|
return !ok
|
|
}
|
|
|
|
// RemoveDeniedNodeFromClient - removes a node id from set of denied nodes
|
|
func RemoveDeniedNodeFromClient(ec *models.ExtClient, clientOrNodeID string) bool {
|
|
if ec.DeniedACLs == nil {
|
|
return true
|
|
}
|
|
_, ok := ec.DeniedACLs[clientOrNodeID]
|
|
if !ok {
|
|
return false
|
|
}
|
|
delete(ec.DeniedACLs, clientOrNodeID)
|
|
return true
|
|
}
|