diff --git a/dns-remap.go b/dns-remap.go index 669e956..8b6df37 100644 --- a/dns-remap.go +++ b/dns-remap.go @@ -173,36 +173,20 @@ func dnsRemap(qname string, qtype uint16, orig *dns.Msg) ([]PowerDnsAnswer, erro // perform nftables assignment if len(nft_ipv4) > 0 { - nftDoWithTable(cfgNftTable, cfgNftTableFamily, func(c *nft.Conn, t *nft.Table) error { - m, err := nftGetMapByName(c, t, cfgNftMapV4) - if err != nil { - return err - } + nftDoWithMap(cfgNftTable, cfgNftTableFamily, cfgNftMapV4, func(c *nft.Conn, t *nft.Table, m *nft.Set) error { _ = c.SetDeleteElements(m, nft_ipv4) return nil }) - nftDoWithTable(cfgNftTable, cfgNftTableFamily, func(c *nft.Conn, t *nft.Table) error { - m, err := nftGetMapByName(c, t, cfgNftMapV4) - if err != nil { - return err - } + nftDoWithMap(cfgNftTable, cfgNftTableFamily, cfgNftMapV4, func(c *nft.Conn, t *nft.Table, m *nft.Set) error { return c.SetAddElements(m, nft_ipv4) }) } if len(nft_ipv6) > 0 { - nftDoWithTable(cfgNftTable, cfgNftTableFamily, func(c *nft.Conn, t *nft.Table) error { - m, err := nftGetMapByName(c, t, cfgNftMapV6) - if err != nil { - return err - } + nftDoWithMap(cfgNftTable, cfgNftTableFamily, cfgNftMapV6, func(c *nft.Conn, t *nft.Table, m *nft.Set) error { _ = c.SetDeleteElements(m, nft_ipv6) return nil }) - nftDoWithTable(cfgNftTable, cfgNftTableFamily, func(c *nft.Conn, t *nft.Table) error { - m, err := nftGetMapByName(c, t, cfgNftMapV6) - if err != nil { - return err - } + nftDoWithMap(cfgNftTable, cfgNftTableFamily, cfgNftMapV6, func(c *nft.Conn, t *nft.Table, m *nft.Set) error { return c.SetAddElements(m, nft_ipv6) }) }