acl.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package models
  2. import (
  3. "time"
  4. "github.com/google/uuid"
  5. )
  6. // AllowedTrafficDirection - allowed direction of traffic
  7. type AllowedTrafficDirection int
  8. const (
  9. // TrafficDirectionUni implies traffic is only allowed in one direction (src --> dst)
  10. TrafficDirectionUni AllowedTrafficDirection = iota
  11. // TrafficDirectionBi implies traffic is allowed both direction (src <--> dst )
  12. TrafficDirectionBi
  13. )
  14. type AclPolicyType string
  15. const (
  16. UserPolicy AclPolicyType = "user-policy"
  17. DevicePolicy AclPolicyType = "device-policy"
  18. )
  19. type AclPolicyTag struct {
  20. ID AclGroupType `json:"id"`
  21. Value string `json:"value"`
  22. }
  23. type AclGroupType string
  24. const (
  25. UserAclID AclGroupType = "user"
  26. UserGroupAclID AclGroupType = "user-group"
  27. DeviceAclID AclGroupType = "tag"
  28. NetmakerIPAclID AclGroupType = "ip"
  29. NetmakerSubNetRangeAClID AclGroupType = "ipset"
  30. )
  31. func (g AclGroupType) String() string {
  32. return string(g)
  33. }
  34. type Acl struct {
  35. ID uuid.UUID `json:"id"`
  36. Default bool `json:"default"`
  37. Name string `json:"name"`
  38. NetworkID NetworkID `json:"network_id"`
  39. RuleType AclPolicyType `json:"policy_type"`
  40. Src []AclPolicyTag `json:"src_type"`
  41. Dst []AclPolicyTag `json:"dst_type"`
  42. AllowedDirection AllowedTrafficDirection `json:"allowed_traffic_direction"`
  43. Enabled bool `json:"enabled"`
  44. CreatedBy string `json:"created_by"`
  45. CreatedAt time.Time `json:"created_at"`
  46. }