Refactor handling of local traffic detection.

This commit is contained in:
Satyadeep Musuvathy
2020-01-16 18:51:31 -08:00
parent 3631887a28
commit 8c6956e5bb
24 changed files with 804 additions and 101 deletions

View File

@@ -57,6 +57,7 @@ type Rule map[string]string
type FakeIPTables struct {
hasRandomFully bool
Lines []byte
ipv6 bool
}
// NewFake returns a no-op iptables.Interface
@@ -64,6 +65,11 @@ func NewFake() *FakeIPTables {
return &FakeIPTables{}
}
// NewIpv6Fake returns a no-op iptables.Interface with IsIPv6() == true
func NewIpv6Fake() *FakeIPTables {
return &FakeIPTables{ipv6: true}
}
// SetHasRandomFully is part of iptables.Interface
func (f *FakeIPTables) SetHasRandomFully(can bool) *FakeIPTables {
f.hasRandomFully = can
@@ -96,8 +102,8 @@ func (*FakeIPTables) DeleteRule(table iptables.Table, chain iptables.Chain, args
}
// IsIpv6 is part of iptables.Interface
func (*FakeIPTables) IsIpv6() bool {
return false
func (f *FakeIPTables) IsIpv6() bool {
return f.ipv6
}
// Save is part of iptables.Interface