mirror of
https://github.com/qdm12/ddns-updater.git
synced 2026-04-05 08:54:09 -04:00
chore(update): remove unneeded ip validity check
This commit is contained in:
@@ -2,7 +2,6 @@ package update
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/netip"
|
"net/netip"
|
||||||
"time"
|
"time"
|
||||||
@@ -220,10 +219,6 @@ func getIPMatchingVersion(ip, ipv4, ipv6 netip.Addr, ipVersion ipversion.IPVersi
|
|||||||
return netip.Addr{}
|
return netip.Addr{}
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
|
||||||
errUpdateIPNotValid = errors.New("IP to update is not valid")
|
|
||||||
)
|
|
||||||
|
|
||||||
func setInitialUpToDateStatus(db Database, id uint, updateIP netip.Addr, now time.Time) error {
|
func setInitialUpToDateStatus(db Database, id uint, updateIP netip.Addr, now time.Time) error {
|
||||||
record, err := db.Select(id)
|
record, err := db.Select(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -301,12 +296,8 @@ func (r *Runner) updateNecessary(ctx context.Context) (errors []error) {
|
|||||||
for id := range recordIDs {
|
for id := range recordIDs {
|
||||||
record := records[id]
|
record := records[id]
|
||||||
updateIP := getIPMatchingVersion(ip, ipv4, ipv6, record.Provider.IPVersion())
|
updateIP := getIPMatchingVersion(ip, ipv4, ipv6, record.Provider.IPVersion())
|
||||||
if !updateIP.IsValid() {
|
// Note: each record id has a matching valid public IP address.
|
||||||
err := fmt.Errorf("getting ip matching ip version: %w", errUpdateIPNotValid)
|
if updateIP.Is6() {
|
||||||
errors = append(errors, err)
|
|
||||||
r.logger.Error(err.Error())
|
|
||||||
continue
|
|
||||||
} else if updateIP.Is6() {
|
|
||||||
updateIP = ipv6WithSuffix(updateIP, record.Provider.IPv6Suffix())
|
updateIP = ipv6WithSuffix(updateIP, record.Provider.IPv6Suffix())
|
||||||
}
|
}
|
||||||
r.logger.Info("Updating record " + record.Provider.String() + " to use " + updateIP.String())
|
r.logger.Info("Updating record " + record.Provider.String() + " to use " + updateIP.String())
|
||||||
|
|||||||
Reference in New Issue
Block a user