Maint: upgrade qdm12 dependencies
- Upgrade qdm12/golibs - Upgrade qdm12/dns to v1.11.0
This commit is contained in:
@@ -24,7 +24,7 @@ type Configurator interface {
|
||||
}
|
||||
|
||||
type Config struct { //nolint:maligned
|
||||
commander command.Commander
|
||||
runner command.Runner
|
||||
logger logging.Logger
|
||||
routing routing.Routing
|
||||
iptablesMutex sync.Mutex
|
||||
@@ -47,15 +47,15 @@ type Config struct { //nolint:maligned
|
||||
}
|
||||
|
||||
// NewConfig creates a new Config instance.
|
||||
func NewConfig(logger logging.Logger, cmder command.Commander,
|
||||
func NewConfig(logger logging.Logger, runner command.Runner,
|
||||
routing routing.Routing, defaultInterface string, defaultGateway net.IP,
|
||||
localNetworks []routing.LocalNetwork, localIP net.IP) *Config {
|
||||
return &Config{
|
||||
commander: cmder,
|
||||
runner: runner,
|
||||
logger: logger,
|
||||
routing: routing,
|
||||
allowedInputPorts: make(map[uint16]string),
|
||||
ip6Tables: ip6tablesSupported(context.Background(), cmder),
|
||||
ip6Tables: ip6tablesSupported(context.Background(), runner),
|
||||
customRulesPath: "/iptables/post-rules.txt",
|
||||
// Obtained from routing
|
||||
defaultInterface: defaultInterface,
|
||||
|
||||
@@ -15,9 +15,9 @@ var (
|
||||
ErrIP6NotSupported = errors.New("ip6tables not supported")
|
||||
)
|
||||
|
||||
func ip6tablesSupported(ctx context.Context, commander command.Commander) (supported bool) {
|
||||
func ip6tablesSupported(ctx context.Context, runner command.Runner) (supported bool) {
|
||||
cmd := exec.CommandContext(ctx, "ip6tables", "-L")
|
||||
if _, err := commander.Run(cmd); err != nil {
|
||||
if _, err := runner.Run(cmd); err != nil {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
@@ -43,7 +43,7 @@ func (c *Config) runIP6tablesInstruction(ctx context.Context, instruction string
|
||||
|
||||
flags := strings.Fields(instruction)
|
||||
cmd := exec.CommandContext(ctx, "ip6tables", flags...)
|
||||
if output, err := c.commander.Run(cmd); err != nil {
|
||||
if output, err := c.runner.Run(cmd); err != nil {
|
||||
return fmt.Errorf("%w: \"ip6tables %s\": %s: %s", ErrIP6Tables, instruction, output, err)
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -47,9 +47,9 @@ func flipRule(rule string) string {
|
||||
}
|
||||
|
||||
// Version obtains the version of the installed iptables.
|
||||
func Version(ctx context.Context, commander command.Commander) (string, error) {
|
||||
func Version(ctx context.Context, runner command.Runner) (string, error) {
|
||||
cmd := exec.CommandContext(ctx, "iptables", "--version")
|
||||
output, err := commander.Run(cmd)
|
||||
output, err := runner.Run(cmd)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -78,7 +78,7 @@ func (c *Config) runIptablesInstruction(ctx context.Context, instruction string)
|
||||
|
||||
flags := strings.Fields(instruction)
|
||||
cmd := exec.CommandContext(ctx, "iptables", flags...)
|
||||
if output, err := c.commander.Run(cmd); err != nil {
|
||||
if output, err := c.runner.Run(cmd); err != nil {
|
||||
return fmt.Errorf("%w \"iptables %s\": %s: %s", ErrIPTables, instruction, output, err)
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -60,7 +60,7 @@ func (c *Config) RemoveAllowedPort(ctx context.Context, port uint16) (err error)
|
||||
return nil
|
||||
}
|
||||
|
||||
c.logger.Info("removing allowed port "+strconv.Itoa(int(port))+" through firewall...", port)
|
||||
c.logger.Info("removing allowed port " + strconv.Itoa(int(port)) + " through firewall...")
|
||||
|
||||
intf, ok := c.allowedInputPorts[port]
|
||||
if !ok {
|
||||
|
||||
Reference in New Issue
Block a user