From d16d82c8ed4e6dbc07d2377a8580ced1c33bba9b Mon Sep 17 00:00:00 2001 From: Daniel Lavrushin Date: Mon, 10 Aug 2026 19:33:55 +0200 Subject: [PATCH] fixes: refactor chain and hook initialization in applyDNSTCPFamily function --- src/tables/dnstcp.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/tables/dnstcp.go b/src/tables/dnstcp.go index 1c909c29..759c2c17 100644 --- a/src/tables/dnstcp.go +++ b/src/tables/dnstcp.go @@ -148,7 +148,11 @@ func (n *NFTablesManager) applyDNSTCPFamily(v6 bool) error { return fmt.Errorf("failed to create nftables dns nat table (%s): %w", family, err) } - for chain, hook := range map[string]string{"dnstcp_pre": "prerouting", "dnstcp_out": "output"} { + for _, c := range []struct{ chain, hook string }{ + {"dnstcp_pre", "prerouting"}, + {"dnstcp_out", "output"}, + } { + chain, hook := c.chain, c.hook if _, err := n.runNft("add", "chain", family, table, chain, fmt.Sprintf("{ type nat hook %s priority %d ; policy accept ; }", hook, nftDstnatPriority)); err != nil { return fmt.Errorf("failed to create nat %s chain (%s): %w", hook, family, err)