From 702f78680f69d1f78ee711435046cceafa51b9aa Mon Sep 17 00:00:00 2001 From: nhas Date: Fri, 1 Nov 2024 12:45:20 +1300 Subject: [PATCH] Add iptables v6 --- internal/router/iptables.go | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/internal/router/iptables.go b/internal/router/iptables.go index 44bbd78f..e5cc2ee2 100644 --- a/internal/router/iptables.go +++ b/internal/router/iptables.go @@ -18,7 +18,16 @@ func (f *Firewall) setupIptables() error { return errors.New("firewall instance has been closed") } - ipt, err := iptables.New() + var ( + err error + ipt *iptables.IPTables + ) + if config.Values.Wireguard.Range.IP.To16() == nil { + ipt, err = iptables.New() + } else { + ipt, err = iptables.New(iptables.IPFamily(iptables.ProtocolIPv6)) + } + if err != nil { return err } @@ -109,7 +118,16 @@ func (f *Firewall) teardownIptables() { log.Println("Removing Firewall rules...") - ipt, err := iptables.New() + var ( + err error + ipt *iptables.IPTables + ) + if config.Values.Wireguard.Range.IP.To16() == nil { + ipt, err = iptables.New() + } else { + ipt, err = iptables.New(iptables.IPFamily(iptables.ProtocolIPv6)) + } + if err != nil { log.Println("Unable to clean up firewall rules: ", err) return