Skip to content

Commit

Permalink
fix(firewall): query iptables version for iptables found
Browse files Browse the repository at this point in the history
  • Loading branch information
qdm12 committed May 4, 2024
1 parent 29bc60b commit ef6874f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
4 changes: 1 addition & 3 deletions cmd/gluetun/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,7 @@ func _main(ctx context.Context, buildInfo models.BuildInformation,
{name: "OpenVPN 2.5", getVersion: ovpnConf.Version25},
{name: "OpenVPN 2.6", getVersion: ovpnConf.Version26},
{name: "Unbound", getVersion: dnsConf.Version},
{name: "IPtables", getVersion: func(ctx context.Context) (version string, err error) {
return firewall.Version(ctx, cmder)
}},
{name: "IPtables", getVersion: firewallConf.Version},
})
if err != nil {
return err
Expand Down
7 changes: 3 additions & 4 deletions internal/firewall/iptables.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"strings"

"github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/golibs/command"
)

var (
Expand Down Expand Up @@ -44,9 +43,9 @@ func flipRule(rule string) string {
}

// Version obtains the version of the installed iptables.
func Version(ctx context.Context, runner command.Runner) (string, error) {
cmd := exec.CommandContext(ctx, "iptables", "--version")
output, err := runner.Run(cmd)
func (c *Config) Version(ctx context.Context) (string, error) {
cmd := exec.CommandContext(ctx, c.ipTables, "--version") //nolint:gosec
output, err := c.runner.Run(cmd)
if err != nil {
return "", err
}
Expand Down

0 comments on commit ef6874f

Please sign in to comment.