dnsEntry.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. // DNSError.Error implementation of error interface
  21. func (e DNSError) Error() string {
  22. return "error publishing dns update"
  23. }
  24. // DNSError error struct capable of holding multiple error messages
  25. type DNSError struct {
  26. ErrorStrings []string
  27. }
  28. // DNSUpdate data for updating entries in /etc/hosts
  29. type DNSUpdate struct {
  30. Action DNSUpdateAction
  31. Name string
  32. NewName string
  33. Address string
  34. NewAddress string
  35. }
  36. // DNSEntry - a DNS entry represented as struct
  37. type DNSEntry struct {
  38. Address string `json:"address" bson:"address" validate:"ip"`
  39. Address6 string `json:"address6" bson:"address6"`
  40. Name string `json:"name" bson:"name" validate:"required,name_unique,min=1,max=192"`
  41. Network string `json:"network" bson:"network" validate:"network_exists"`
  42. }