acl.go 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. package models
  2. import (
  3. "time"
  4. )
  5. // AllowedTrafficDirection - allowed direction of traffic
  6. type AllowedTrafficDirection int
  7. const (
  8. // TrafficDirectionUni implies traffic is only allowed in one direction (src --> dst)
  9. TrafficDirectionUni AllowedTrafficDirection = iota
  10. // TrafficDirectionBi implies traffic is allowed both direction (src <--> dst )
  11. TrafficDirectionBi
  12. )
  13. type AclPolicyType string
  14. const (
  15. UserPolicy AclPolicyType = "user-policy"
  16. DevicePolicy AclPolicyType = "device-policy"
  17. )
  18. type AclPolicyTag struct {
  19. ID AclGroupType `json:"id"`
  20. Value string `json:"value"`
  21. }
  22. type AclGroupType string
  23. const (
  24. UserAclID AclGroupType = "user"
  25. UserGroupAclID AclGroupType = "user-group"
  26. DeviceAclID AclGroupType = "tag"
  27. NetmakerIPAclID AclGroupType = "ip"
  28. NetmakerSubNetRangeAClID AclGroupType = "ipset"
  29. )
  30. func (g AclGroupType) String() string {
  31. return string(g)
  32. }
  33. type UpdateAclRequest struct {
  34. Acl
  35. NewName string `json:"new_name"`
  36. }
  37. type AclPolicy struct {
  38. TypeID AclPolicyType
  39. PrefixTagUser AclGroupType
  40. }
  41. type Acl struct {
  42. ID string `json:"id"`
  43. Default bool `json:"default"`
  44. MetaData string `json:"meta_data"`
  45. Name string `json:"name"`
  46. NetworkID NetworkID `json:"network_id"`
  47. RuleType AclPolicyType `json:"policy_type"`
  48. Src []AclPolicyTag `json:"src_type"`
  49. Dst []AclPolicyTag `json:"dst_type"`
  50. AllowedDirection AllowedTrafficDirection `json:"allowed_traffic_direction"`
  51. Enabled bool `json:"enabled"`
  52. CreatedBy string `json:"created_by"`
  53. CreatedAt time.Time `json:"created_at"`
  54. }
  55. type AclPolicyTypes struct {
  56. RuleTypes []AclPolicyType `json:"policy_types"`
  57. SrcGroupTypes []AclGroupType `json:"src_grp_types"`
  58. DstGroupTypes []AclGroupType `json:"dst_grp_types"`
  59. }