ipv4 and ipv6 detection using regex
This commit is contained in:
parent
832360a02c
commit
4101e3fc44
15
pkg/iptables/iptables.go
Normal file → Executable file
15
pkg/iptables/iptables.go
Normal file → Executable file
@ -380,21 +380,10 @@ func (c *Controller) Set(rules []Rule) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if i >= len(c.rules) {
|
if i >= len(c.rules) {
|
||||||
proto := rules[i].Proto()
|
if err := rules[i].Add(c.client(rules[i].Proto())); err != nil {
|
||||||
|
|
||||||
protocolName := "ipv4"
|
|
||||||
|
|
||||||
if proto == ProtocolIPv6 {
|
|
||||||
protocolName = "ipv6"
|
|
||||||
}
|
|
||||||
|
|
||||||
var ruleString = rules[i].String()
|
|
||||||
level.Debug(c.logger).Log("msg", "Applying Firewall Rule...", "Rule", ruleString, "Protocol", protocolName)
|
|
||||||
if err := rules[i].Add(c.v4); err != nil {
|
|
||||||
return fmt.Errorf("failed to add rule: %v", err)
|
return fmt.Errorf("failed to add rule: %v", err)
|
||||||
}
|
}
|
||||||
level.Debug(c.logger).Log("msg", "Firewall Rule applied.", "Rule", ruleString, "Protocol", protocolName)
|
c.rules = append(c.rulIes, rules[i])
|
||||||
c.rules = append(c.rules, rules[i])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user