MCPcopy
hub / github.com/cloudflare/cloudflared / NewPolicy

Function NewPolicy

ipaccess/access.go:20–33  ·  view source on GitHub ↗
(defaultAllow bool, rules []Rule)

Source from the content-addressed store, hash-verified

18}
19
20func NewPolicy(defaultAllow bool, rules []Rule) (*Policy, error) {
21 for _, rule := range rules {
22 if err := rule.Validate(); err != nil {
23 return nil, err
24 }
25 }
26
27 policy := Policy{
28 defaultAllow: defaultAllow,
29 rules: rules,
30 }
31
32 return &policy, nil
33}
34
35func NewRuleByCIDR(prefix *string, ports []int, allow bool) (Rule, error) {
36 if prefix == nil || len(*prefix) == 0 {

Callers 6

validateIngressFunction · 0.92
accessPolicyFunction · 0.92
TestRulesNoRulesFunction · 0.85
TestRulesMatchIPAndPortFunction · 0.85
TestRulesMatchIPAndPort2Function · 0.85

Calls 1

ValidateMethod · 0.45

Tested by 5

accessPolicyFunction · 0.74
TestRulesNoRulesFunction · 0.68
TestRulesMatchIPAndPortFunction · 0.68
TestRulesMatchIPAndPort2Function · 0.68