Files
ddns-updater/pkg/models/ipmethod.go
Quentin McGaw 89cd9c7185 BIg code restructuring to accommodate more user parameters
- 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
2019-05-01 17:58:15 +02:00

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)
}