Maint: firewall package interface rework

- return concrete struct type
- split interface is sub-interfaces
This commit is contained in:
Quentin McGaw (desktop)
2021-07-23 19:12:16 +00:00
parent 10aabe8375
commit 2ddc784965
9 changed files with 54 additions and 40 deletions

View File

@@ -6,7 +6,11 @@ import (
"net"
)
func (c *configurator) SetOutboundSubnets(ctx context.Context, subnets []net.IPNet) (err error) {
type OutboundSubnetsSetter interface {
SetOutboundSubnets(ctx context.Context, subnets []net.IPNet) (err error)
}
func (c *Config) SetOutboundSubnets(ctx context.Context, subnets []net.IPNet) (err error) {
c.stateMutex.Lock()
defer c.stateMutex.Unlock()
@@ -33,7 +37,7 @@ func (c *configurator) SetOutboundSubnets(ctx context.Context, subnets []net.IPN
return nil
}
func (c *configurator) removeOutboundSubnets(ctx context.Context, subnets []net.IPNet) {
func (c *Config) removeOutboundSubnets(ctx context.Context, subnets []net.IPNet) {
const remove = true
for _, subnet := range subnets {
if err := c.acceptOutputFromIPToSubnet(ctx, c.defaultInterface, c.localIP, subnet, remove); err != nil {
@@ -44,7 +48,7 @@ func (c *configurator) removeOutboundSubnets(ctx context.Context, subnets []net.
}
}
func (c *configurator) addOutboundSubnets(ctx context.Context, subnets []net.IPNet) error {
func (c *Config) addOutboundSubnets(ctx context.Context, subnets []net.IPNet) error {
const remove = false
for _, subnet := range subnets {
if err := c.acceptOutputFromIPToSubnet(ctx, c.defaultInterface, c.localIP, subnet, remove); err != nil {