2023-01-21 06:38:32 +08:00
|
|
|
// TODO: Either add a returnNetwork and returnKey, or delete this
|
2021-04-27 11:39:15 +08:00
|
|
|
package models
|
|
|
|
|
2023-02-07 04:38:42 +08:00
|
|
|
// DNSUpdateAction identifies the action to be performed with the dns update data
|
2023-02-06 20:26:55 +08:00
|
|
|
type DNSUpdateAction int
|
|
|
|
|
|
|
|
const (
|
2023-02-07 04:38:42 +08:00
|
|
|
// DNSDeleteByIP delete the dns entry
|
2023-02-07 03:50:29 +08:00
|
|
|
DNSDeleteByIP = iota
|
2023-02-07 04:38:42 +08:00
|
|
|
// DNSDeleteByName delete the dns entry
|
2023-02-06 23:48:33 +08:00
|
|
|
DNSDeleteByName
|
2023-02-07 04:38:42 +08:00
|
|
|
// DNSReplaceName replace the dns entry
|
2023-02-07 03:50:29 +08:00
|
|
|
DNSReplaceName
|
2023-02-07 04:38:42 +08:00
|
|
|
// DNSReplaceIP resplace the dns entry
|
|
|
|
DNSReplaceIP
|
|
|
|
// DNSInsert insert a new dns entry
|
2023-02-06 20:26:55 +08:00
|
|
|
DNSInsert
|
|
|
|
)
|
|
|
|
|
2023-02-08 05:03:22 +08:00
|
|
|
func (action DNSUpdateAction) String() string {
|
|
|
|
return [...]string{"DNSDeleteByIP", "DNSDeletByName", "DNSReplaceName", "DNSReplaceIP", "DNSInsert"}[action]
|
|
|
|
}
|
|
|
|
|
2023-02-10 19:58:00 +08:00
|
|
|
// DNSError.Error implementation of error interface
|
|
|
|
func (e DNSError) Error() string {
|
|
|
|
return "error publishing dns update"
|
|
|
|
}
|
|
|
|
|
|
|
|
// DNSError error struct capable of holding multiple error messages
|
|
|
|
type DNSError struct {
|
|
|
|
ErrorStrings []string
|
|
|
|
}
|
|
|
|
|
2023-02-07 04:38:42 +08:00
|
|
|
// DNSUpdate data for updating entries in /etc/hosts
|
2023-02-06 20:26:55 +08:00
|
|
|
type DNSUpdate struct {
|
2023-02-08 03:24:57 +08:00
|
|
|
Action DNSUpdateAction
|
|
|
|
Name string
|
|
|
|
NewName string
|
|
|
|
Address string
|
|
|
|
NewAddress string
|
2023-02-06 20:26:55 +08:00
|
|
|
}
|
|
|
|
|
2022-04-20 04:18:03 +08:00
|
|
|
// DNSEntry - a DNS entry represented as struct
|
2021-04-27 11:39:15 +08:00
|
|
|
type DNSEntry struct {
|
2023-08-22 14:20:28 +08:00
|
|
|
Address string `json:"address" validate:"ip"`
|
|
|
|
Address6 string `json:"address6"`
|
|
|
|
Name string `json:"name" validate:"required,name_unique,min=1,max=192,whitespace"`
|
|
|
|
Network string `json:"network" validate:"network_exists"`
|
2021-04-27 11:39:15 +08:00
|
|
|
}
|