add missing all rule

This commit is contained in:
Pascal Fischer 2023-06-27 17:44:05 +02:00
parent d96f882acb
commit b39ffef22c

View File

@ -129,10 +129,10 @@ func (m *Manager) AddFiltering(
var p int var p int
if direction == fw.RuleDirectionIN { if direction == fw.RuleDirectionIN {
m.incomingRules[r.ip.String()] = append(m.incomingRules[r.ip.String()], r) m.incomingRules[r.ip.String()] = append(m.incomingRules[r.ip.String()], r)
p = len(m.incomingRules) - 1 p = len(m.incomingRules[r.ip.String()]) - 1
} else { } else {
m.outgoingRules[r.ip.String()] = append(m.outgoingRules[r.ip.String()], r) m.outgoingRules[r.ip.String()] = append(m.outgoingRules[r.ip.String()], r)
p = len(m.outgoingRules) - 1 p = len(m.outgoingRules[r.ip.String()]) - 1
} }
m.rulesIndex[r.id] = p m.rulesIndex[r.id] = p
m.mutex.Unlock() m.mutex.Unlock()
@ -234,18 +234,18 @@ func (m *Manager) dropFilter(packetData []byte, rules map[string][]Rule, isIncom
case layers.LayerTypeIPv4: case layers.LayerTypeIPv4:
if isIncomingPacket { if isIncomingPacket {
srcIP = d.ip4.SrcIP srcIP = d.ip4.SrcIP
ipRules = rules[srcIP.String()] ipRules = append(rules[srcIP.String()], rules["0.0.0.0"]...)
} else { } else {
dstIP = d.ip4.DstIP dstIP = d.ip4.DstIP
ipRules = rules[dstIP.String()] ipRules = append(rules[dstIP.String()], rules["0.0.0.0"]...)
} }
case layers.LayerTypeIPv6: case layers.LayerTypeIPv6:
if isIncomingPacket { if isIncomingPacket {
srcIP = d.ip6.SrcIP srcIP = d.ip6.SrcIP
ipRules = rules[srcIP.String()] ipRules = append(rules[srcIP.String()], rules["::"]...)
} else { } else {
dstIP = d.ip6.DstIP dstIP = d.ip6.DstIP
ipRules = rules[dstIP.String()] ipRules = append(rules[dstIP.String()], rules["::"]...)
} }
} }