Reworked update code, split v4/v6 updates

- collect dns updatees individually, so that we clear A and AAAA separately if and only if needed.
- made nft AddIP call more resilient against partial updates
- updated nft processing code to no longer add nil to a v4/v6 set which would end in an invalid call to AddIP when updating nft. call it individually now.
- updated samples with real world traces from an AVM Box
This commit is contained in:
2021-09-25 11:56:50 +02:00
parent a23043ba5f
commit 45d4e45bb1
4 changed files with 38 additions and 14 deletions

View File

@ -85,19 +85,19 @@ func (ur *UpdateRequest) Process() error {
if err := DNSUpdateEntry(ur.Config.Domain, other.Hostname, ur.IPv4, fullV6IP); err != nil {
return fmt.Errorf("failed to update DNS for host %s: %v", other.Hostname, err)
}
} else {
} else if ur.IPv6 != nil {
if err := DNSUpdateEntry(ur.Config.Domain, other.Hostname, nil, fullV6IP); err != nil {
return fmt.Errorf("failed to update DNS for host %s: %v", other.Hostname, err)
}
}
if other.NFT.Table != "" {
if other.NFT.Set6 != "" {
if other.NFT.Set6 != "" && ur.IPv6 != nil {
if err := nfu.AddIP(other.NFT.Table, other.NFT.Set6, fullV6IP); err != nil {
return fmt.Errorf("failed to update IPv6 NFT setup for host %s: %v", other.Hostname, err)
}
}
if other.RegisterV4 && other.NFT.Set4 != "" {
if other.RegisterV4 && other.NFT.Set4 != "" && ur.IPv4 != nil {
if err := nfu.AddIP(other.NFT.Table, other.NFT.Set4, ur.IPv4); err != nil {
return fmt.Errorf("failed to update IPv6 NFT setup for host %s: %v", other.Hostname, err)
}