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

Method Validate

ipaccess/access.go:57–72  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

55}
56
57func (r *Rule) Validate() error {
58 if r.ipNet == nil {
59 return fmt.Errorf("no ipnet set on the rule")
60 }
61
62 if len(r.ports) > 0 {
63 sort.Ints(r.ports)
64 for _, port := range r.ports {
65 if port < 1 || port > 65535 {
66 return fmt.Errorf("invalid port %d, needs to be between 1 and 65535", port)
67 }
68 }
69 }
70
71 return nil
72}
73
74func (h *Policy) Allowed(ip net.IP, port int) (bool, *Rule) {
75 if len(h.rules) == 0 {

Callers 2

NewRuleFunction · 0.95
NewPolicyFunction · 0.45

Calls 1

ErrorfMethod · 0.80

Tested by

no test coverage detected