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
|
||||
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)
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user