mirror of
https://github.com/qdm12/ddns-updater.git
synced 2026-03-31 06:24:00 -04:00
wip
This commit is contained in:
@@ -16,7 +16,7 @@ type PublicIPFetcher interface {
|
||||
}
|
||||
|
||||
type UpdaterInterface interface {
|
||||
Update(ctx context.Context, recordID uint, ip netip.Addr, now time.Time) (err error)
|
||||
Update(ctx context.Context, recordID uint, ipv4, ipv6 netip.Addr, now time.Time) (err error)
|
||||
}
|
||||
|
||||
type Database interface {
|
||||
|
||||
@@ -95,6 +95,8 @@ func doIPVersion(records []librecords.Record) (doIP, doIPv4, doIPv6 bool) {
|
||||
doIPv4 = true
|
||||
case ipversion.IP6:
|
||||
doIPv6 = true
|
||||
case ipversion.IP4and6:
|
||||
doIPv4, doIPv6 = true, true
|
||||
}
|
||||
if doIP && doIPv4 && doIPv6 {
|
||||
return true, true, true
|
||||
|
||||
@@ -12,6 +12,7 @@ const (
|
||||
IP4or6 IPVersion = iota
|
||||
IP4
|
||||
IP6
|
||||
IP4and6
|
||||
)
|
||||
|
||||
func (v IPVersion) String() string {
|
||||
@@ -22,8 +23,10 @@ func (v IPVersion) String() string {
|
||||
return "ipv4"
|
||||
case IP6:
|
||||
return "ipv6"
|
||||
case IP4and6:
|
||||
return "ipv4 and ipv6"
|
||||
default:
|
||||
return "ip?"
|
||||
panic(fmt.Sprintf("ip version %d not programmed", v))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +40,8 @@ func Parse(s string) (version IPVersion, err error) {
|
||||
return IP4, nil
|
||||
case "ipv6":
|
||||
return IP6, nil
|
||||
case "ipv4 and ipv6":
|
||||
return IP4and6, nil
|
||||
default:
|
||||
return IP4or6, fmt.Errorf("%w: %q", ErrInvalidIPVersion, s)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user