Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Net 1784 latest #3250

Merged
merged 2 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions controllers/acls.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@ func createAcl(w http.ResponseWriter, r *http.Request) {
acl.CreatedBy = user.UserName
acl.CreatedAt = time.Now().UTC()
acl.Default = false
if acl.ServiceType == models.Any {
acl.Port = []string{}
acl.Proto = models.ALL
}
// validate create acl policy
if !logic.IsAclPolicyValid(acl) {
logic.ReturnErrorResponse(w, r, logic.FormatError(errors.New("invalid policy"), "badrequest"))
Expand Down
8 changes: 7 additions & 1 deletion logic/acls.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,10 @@ func UpdateAcl(newAcl, acl models.Acl) error {
acl.Proto = newAcl.Proto
acl.ServiceType = newAcl.ServiceType
}
if newAcl.ServiceType == models.Any {
acl.Port = []string{}
acl.Proto = models.ALL
}
acl.Enabled = newAcl.Enabled
d, err := json.Marshal(acl)
if err != nil {
Expand Down Expand Up @@ -844,6 +848,7 @@ func GetAclRulesForNode(targetnode *models.Node) (rules map[string]models.AclRul
}

acls := listDevicePolicies(models.NetworkID(targetnode.Network))
targetnode.Tags["*"] = struct{}{}
for nodeTag := range targetnode.Tags {
for _, acl := range acls {
if !acl.Enabled {
Expand Down Expand Up @@ -944,7 +949,8 @@ func GetAclRulesForNode(targetnode *models.Node) (rules map[string]models.AclRul
}
}
} else {
if _, ok := dstTags[nodeTag.String()]; ok {
_, all := dstTags["*"]
if _, ok := dstTags[nodeTag.String()]; ok || all {
// get all src tags
for src := range srcTags {
if src == nodeTag.String() {
Expand Down
5 changes: 5 additions & 0 deletions logic/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,7 @@ func GetTagMapWithNodesByNetwork(netID models.NetworkID, withStaticNodes bool) (
tagNodesMap[nodeTagID] = append(tagNodesMap[nodeTagID], nodeI)
}
}
tagNodesMap["*"] = nodes
if !withStaticNodes {
return
}
Expand All @@ -850,6 +851,10 @@ func AddTagMapWithStaticNodes(netID models.NetworkID,
IsStatic: true,
StaticNode: extclient,
})
tagNodesMap["*"] = append(tagNodesMap["*"], models.Node{
IsStatic: true,
StaticNode: extclient,
})
}

}
Expand Down
Loading