minor code improvement
This commit is contained in:
parent
2539af3bd4
commit
ddaf00f0e7
24
dns-remap.go
24
dns-remap.go
@ -173,36 +173,20 @@ func dnsRemap(qname string, qtype uint16, orig *dns.Msg) ([]PowerDnsAnswer, erro
|
|||||||
|
|
||||||
// perform nftables assignment
|
// perform nftables assignment
|
||||||
if len(nft_ipv4) > 0 {
|
if len(nft_ipv4) > 0 {
|
||||||
nftDoWithTable(cfgNftTable, cfgNftTableFamily, func(c *nft.Conn, t *nft.Table) error {
|
nftDoWithMap(cfgNftTable, cfgNftTableFamily, cfgNftMapV4, func(c *nft.Conn, t *nft.Table, m *nft.Set) error {
|
||||||
m, err := nftGetMapByName(c, t, cfgNftMapV4)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
_ = c.SetDeleteElements(m, nft_ipv4)
|
_ = c.SetDeleteElements(m, nft_ipv4)
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
nftDoWithTable(cfgNftTable, cfgNftTableFamily, func(c *nft.Conn, t *nft.Table) error {
|
nftDoWithMap(cfgNftTable, cfgNftTableFamily, cfgNftMapV4, func(c *nft.Conn, t *nft.Table, m *nft.Set) error {
|
||||||
m, err := nftGetMapByName(c, t, cfgNftMapV4)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return c.SetAddElements(m, nft_ipv4)
|
return c.SetAddElements(m, nft_ipv4)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if len(nft_ipv6) > 0 {
|
if len(nft_ipv6) > 0 {
|
||||||
nftDoWithTable(cfgNftTable, cfgNftTableFamily, func(c *nft.Conn, t *nft.Table) error {
|
nftDoWithMap(cfgNftTable, cfgNftTableFamily, cfgNftMapV6, func(c *nft.Conn, t *nft.Table, m *nft.Set) error {
|
||||||
m, err := nftGetMapByName(c, t, cfgNftMapV6)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
_ = c.SetDeleteElements(m, nft_ipv6)
|
_ = c.SetDeleteElements(m, nft_ipv6)
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
nftDoWithTable(cfgNftTable, cfgNftTableFamily, func(c *nft.Conn, t *nft.Table) error {
|
nftDoWithMap(cfgNftTable, cfgNftTableFamily, cfgNftMapV6, func(c *nft.Conn, t *nft.Table, m *nft.Set) error {
|
||||||
m, err := nftGetMapByName(c, t, cfgNftMapV6)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return c.SetAddElements(m, nft_ipv6)
|
return c.SetAddElements(m, nft_ipv6)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user