1
0
mirror of https://github.com/juanfont/headscale.git synced 2024-12-20 19:09:07 +01:00

feat(acls): simplify updating rules

This commit is contained in:
Adrien Raffin 2022-02-03 20:00:41 +01:00 committed by Adrien Raffin-Caboisse
parent e482dfeed4
commit e9949b4c70
No known key found for this signature in database
GPG Key ID: 7FB60532DEBEAD6A
2 changed files with 6 additions and 5 deletions

View File

@ -69,14 +69,16 @@ func (h *Headscale) LoadACLPolicy(path string) error {
} }
h.aclPolicy = &policy h.aclPolicy = &policy
return h.UpdateACLRules()
}
func (h *Headscale) UpdateACLRules() error {
rules, err := h.generateACLRules() rules, err := h.generateACLRules()
if err != nil { if err != nil {
return err return err
} }
h.aclRules = rules
log.Trace().Interface("ACL", rules).Msg("ACL rules generated") log.Trace().Interface("ACL", rules).Msg("ACL rules generated")
h.aclRules = rules
return nil return nil
} }

View File

@ -204,9 +204,8 @@ func (s *Suite) TestGetACLFilteredPeers(c *check.C) {
Tests: []ACLTest{}, Tests: []ACLTest{},
} }
rules, err := app.generateACLRules() err = app.UpdateACLRules()
c.Assert(err, check.IsNil) c.Assert(err, check.IsNil)
app.aclRules = rules
adminMachine, err := app.GetMachineByID(1) adminMachine, err := app.GetMachineByID(1)
c.Logf("Machine(%v), namespace: %v", adminMachine.Name, adminMachine.Namespace) c.Logf("Machine(%v), namespace: %v", adminMachine.Name, adminMachine.Namespace)