mirror of
https://github.com/juanfont/headscale.git
synced 2024-11-26 08:53:05 +00:00
make generateFilterRule a pol struct func
Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This commit is contained in:
parent
5bbbe437df
commit
200e3b88cc
2 changed files with 9 additions and 10 deletions
5
acls.go
5
acls.go
|
@ -128,7 +128,7 @@ func (h *Headscale) UpdateACLRules() error {
|
|||
return errEmptyPolicy
|
||||
}
|
||||
|
||||
rules, err := generateFilterRules(machines, *h.aclPolicy, h.cfg.OIDC.StripEmaildomain)
|
||||
rules, err := h.aclPolicy.generateFilterRules(machines, h.cfg.OIDC.StripEmaildomain)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -226,9 +226,8 @@ func expandACLPeerAddr(srcIP string) []string {
|
|||
|
||||
// generateFilterRules takes a set of machines and an ACLPolicy and generates a
|
||||
// set of Tailscale compatible FilterRules used to allow traffic on clients.
|
||||
func generateFilterRules(
|
||||
func (pol *ACLPolicy) generateFilterRules(
|
||||
machines []Machine,
|
||||
pol ACLPolicy,
|
||||
stripEmaildomain bool,
|
||||
) ([]tailcfg.FilterRule, error) {
|
||||
rules := []tailcfg.FilterRule{}
|
||||
|
|
14
acls_test.go
14
acls_test.go
|
@ -54,7 +54,7 @@ func (s *Suite) TestBasicRule(c *check.C) {
|
|||
err := app.LoadACLPolicy("./tests/acls/acl_policy_basic_1.hujson")
|
||||
c.Assert(err, check.IsNil)
|
||||
|
||||
rules, err := generateFilterRules([]Machine{}, *app.aclPolicy, false)
|
||||
rules, err := app.aclPolicy.generateFilterRules([]Machine{}, false)
|
||||
c.Assert(err, check.IsNil)
|
||||
c.Assert(rules, check.NotNil)
|
||||
}
|
||||
|
@ -411,7 +411,7 @@ func (s *Suite) TestPortRange(c *check.C) {
|
|||
err := app.LoadACLPolicy("./tests/acls/acl_policy_basic_range.hujson")
|
||||
c.Assert(err, check.IsNil)
|
||||
|
||||
rules, err := generateFilterRules([]Machine{}, *app.aclPolicy, false)
|
||||
rules, err := app.aclPolicy.generateFilterRules([]Machine{}, false)
|
||||
c.Assert(err, check.IsNil)
|
||||
c.Assert(rules, check.NotNil)
|
||||
|
||||
|
@ -425,7 +425,7 @@ func (s *Suite) TestProtocolParsing(c *check.C) {
|
|||
err := app.LoadACLPolicy("./tests/acls/acl_policy_basic_protocols.hujson")
|
||||
c.Assert(err, check.IsNil)
|
||||
|
||||
rules, err := generateFilterRules([]Machine{}, *app.aclPolicy, false)
|
||||
rules, err := app.aclPolicy.generateFilterRules([]Machine{}, false)
|
||||
c.Assert(err, check.IsNil)
|
||||
c.Assert(rules, check.NotNil)
|
||||
|
||||
|
@ -439,7 +439,7 @@ func (s *Suite) TestPortWildcard(c *check.C) {
|
|||
err := app.LoadACLPolicy("./tests/acls/acl_policy_basic_wildcards.hujson")
|
||||
c.Assert(err, check.IsNil)
|
||||
|
||||
rules, err := generateFilterRules([]Machine{}, *app.aclPolicy, false)
|
||||
rules, err := app.aclPolicy.generateFilterRules([]Machine{}, false)
|
||||
c.Assert(err, check.IsNil)
|
||||
c.Assert(rules, check.NotNil)
|
||||
|
||||
|
@ -455,7 +455,7 @@ func (s *Suite) TestPortWildcardYAML(c *check.C) {
|
|||
err := app.LoadACLPolicy("./tests/acls/acl_policy_basic_wildcards.yaml")
|
||||
c.Assert(err, check.IsNil)
|
||||
|
||||
rules, err := generateFilterRules([]Machine{}, *app.aclPolicy, false)
|
||||
rules, err := app.aclPolicy.generateFilterRules([]Machine{}, false)
|
||||
c.Assert(err, check.IsNil)
|
||||
c.Assert(rules, check.NotNil)
|
||||
|
||||
|
@ -498,7 +498,7 @@ func (s *Suite) TestPortUser(c *check.C) {
|
|||
machines, err := app.ListMachines()
|
||||
c.Assert(err, check.IsNil)
|
||||
|
||||
rules, err := generateFilterRules(machines, *app.aclPolicy, false)
|
||||
rules, err := app.aclPolicy.generateFilterRules(machines, false)
|
||||
c.Assert(err, check.IsNil)
|
||||
c.Assert(rules, check.NotNil)
|
||||
|
||||
|
@ -541,7 +541,7 @@ func (s *Suite) TestPortGroup(c *check.C) {
|
|||
machines, err := app.ListMachines()
|
||||
c.Assert(err, check.IsNil)
|
||||
|
||||
rules, err := generateFilterRules(machines, *app.aclPolicy, false)
|
||||
rules, err := app.aclPolicy.generateFilterRules(machines, false)
|
||||
c.Assert(err, check.IsNil)
|
||||
c.Assert(rules, check.NotNil)
|
||||
|
||||
|
|
Loading…
Reference in a new issue