This commit is contained in:
Quentin McGaw
2024-01-28 07:28:29 +00:00
parent bc54ba5aca
commit 7525e870e3
3 changed files with 9 additions and 2 deletions

View File

@@ -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 {

View File

@@ -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

View File

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