dnsEntry.go 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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" validate:"omitempty,ip"`
  39. Address6 string `json:"address6" validate:"omitempty,ip"`
  40. Name string `json:"name" validate:"required,name_unique,min=1,max=192,whitespace"`
  41. Network string `json:"network" validate:"network_exists"`
  42. }
  43. type NameserverReq struct {
  44. Name string `json:"name"`
  45. Network string `json:"network"`
  46. Description string ` json:"description"`
  47. Servers []string `json:"servers"`
  48. MatchDomain string `json:"match_domain"`
  49. Tags []string `json:"tags"`
  50. Status bool `gorm:"status" json:"status"`
  51. }