dnsEntry.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // TODO: Either add a returnNetwork and returnKey, or delete this
  2. package models
  3. // DNSUpdateAction identifies the action to be performed with the dns update data
  4. type DNSUpdateAction int
  5. const (
  6. // DNSDeleteByIP delete the dns entry
  7. DNSDeleteByIP = iota
  8. // DNSDeleteByName delete the dns entry
  9. DNSDeleteByName
  10. // DNSReplaceName replace the dns entry
  11. DNSReplaceName
  12. // DNSReplaceIP resplace the dns entry
  13. DNSReplaceIP
  14. // DNSInsert insert a new dns entry
  15. DNSInsert
  16. )
  17. func (action DNSUpdateAction) String() string {
  18. return [...]string{"DNSDeleteByIP", "DNSDeletByName", "DNSReplaceName", "DNSReplaceIP", "DNSInsert"}[action]
  19. }
  20. // DNSUpdate data for updating entries in /etc/hosts
  21. type DNSUpdate struct {
  22. Action DNSUpdateAction
  23. Name string
  24. NewName string
  25. Address string
  26. NewAddress string
  27. }
  28. // DNSEntry - a DNS entry represented as struct
  29. type DNSEntry struct {
  30. Address string `json:"address" bson:"address" validate:"ip"`
  31. Address6 string `json:"address6" bson:"address6"`
  32. Name string `json:"name" bson:"name" validate:"required,name_unique,min=1,max=192"`
  33. Network string `json:"network" bson:"network" validate:"network_exists"`
  34. }