mirror of
https://github.com/qdm12/ddns-updater.git
synced 2026-08-04 19:35:08 -04:00
- Move from settings in environment variables `RECORDi` to a configuration file *config.json* - Each entry can has its own delay optionally - Proper cleanup on exit (close channels etc.) - Fan out channels architecture for force and quit channels to all updates goroutines - Each entry has its own set of fields explained in the readme - Retrocompatibility for environment variables entries for now - More enum types to avoid problems
40 lines
803 B
Go
40 lines
803 B
Go
package models
|
|
|
|
import "fmt"
|
|
|
|
// IPMethodType is the enum type for all the possible IP methods
|
|
type IPMethodType uint8
|
|
|
|
// All possible IP methods values
|
|
const (
|
|
IPMETHODPROVIDER IPMethodType = iota
|
|
IPMETHODDUCKDUCKGO
|
|
IPMETHODOPENDNS
|
|
)
|
|
|
|
func (ipMethod IPMethodType) String() string {
|
|
switch ipMethod {
|
|
case IPMETHODPROVIDER:
|
|
return "provider"
|
|
case IPMETHODDUCKDUCKGO:
|
|
return "duckduckgo"
|
|
case IPMETHODOPENDNS:
|
|
return "opendns"
|
|
default:
|
|
return "unknown"
|
|
}
|
|
}
|
|
|
|
// ParseIPMethod obtains the IP method from a string
|
|
func ParseIPMethod(s string) (IPMethodType, error) {
|
|
switch s {
|
|
case "provider":
|
|
return IPMETHODPROVIDER, nil
|
|
case "duckduckgo":
|
|
return IPMETHODDUCKDUCKGO, nil
|
|
case "opendns":
|
|
return IPMETHODOPENDNS, nil
|
|
}
|
|
return 0, fmt.Errorf("IP method %s not recognized", s)
|
|
}
|