Make dropping of other IPIP traffic optional
This commit is contained in:
@@ -23,13 +23,14 @@ import (
|
||||
)
|
||||
|
||||
type ipip struct {
|
||||
iface int
|
||||
strategy Strategy
|
||||
iface int
|
||||
strategy Strategy
|
||||
dropOtherIpIpTraffic bool
|
||||
}
|
||||
|
||||
// NewIPIP returns an encapsulator that uses IPIP.
|
||||
func NewIPIP(strategy Strategy) Encapsulator {
|
||||
return &ipip{strategy: strategy}
|
||||
func NewIPIP(strategy Strategy, dropOtherIpIpTraffic bool) Encapsulator {
|
||||
return &ipip{strategy: strategy, dropOtherIpIpTraffic: dropOtherIpIpTraffic}
|
||||
}
|
||||
|
||||
// CleanUp will remove any created IPIP devices.
|
||||
@@ -76,9 +77,11 @@ func (i *ipip) Rules(nodes []*net.IPNet) []iptables.Rule {
|
||||
// Accept encapsulated traffic from peers.
|
||||
rules = append(rules, iptables.NewRule(iptables.GetProtocol(n.IP), "filter", "KILO-IPIP", "-s", n.String(), "-m", "comment", "--comment", "Kilo: allow IPIP traffic", "-j", "ACCEPT"))
|
||||
}
|
||||
// Drop all other IPIP traffic.
|
||||
rules = append(rules, iptables.NewIPv4Rule("filter", "INPUT", "-p", proto, "-m", "comment", "--comment", "Kilo: reject other IPIP traffic", "-j", "DROP"))
|
||||
rules = append(rules, iptables.NewIPv6Rule("filter", "INPUT", "-p", proto, "-m", "comment", "--comment", "Kilo: reject other IPIP traffic", "-j", "DROP"))
|
||||
if i.dropOtherIpIpTraffic {
|
||||
// Drop all other IPIP traffic.
|
||||
rules = append(rules, iptables.NewIPv4Rule("filter", "INPUT", "-p", proto, "-m", "comment", "--comment", "Kilo: reject other IPIP traffic", "-j", "DROP"))
|
||||
rules = append(rules, iptables.NewIPv6Rule("filter", "INPUT", "-p", proto, "-m", "comment", "--comment", "Kilo: reject other IPIP traffic", "-j", "DROP"))
|
||||
}
|
||||
|
||||
return rules
|
||||
}
|
||||
|
Reference in New Issue
Block a user