Skip to content

Commit

Permalink
Add iptables v6
Browse files Browse the repository at this point in the history
  • Loading branch information
NHAS committed Oct 31, 2024
1 parent aa114f7 commit 702f786
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions internal/router/iptables.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 702f786

Please sign in to comment.