Feature: uplift the 'localSubnet' concept to cover all local ethernet interfaces (#413)

This commit is contained in:
Michael Robbins
2021-04-10 03:08:20 +10:00
committed by GitHub
parent cc4117e054
commit 8230596f98
5 changed files with 87 additions and 11 deletions

View File

@@ -24,7 +24,7 @@ type Configurator interface {
RemoveAllowedPort(ctx context.Context, port uint16) (err error)
SetDebug()
// SetNetworkInformation is meant to be called only once
SetNetworkInformation(defaultInterface string, defaultGateway net.IP, localSubnet net.IPNet, localIP net.IP)
SetNetworkInformation(defaultInterface string, defaultGateway net.IP, localNetworks []routing.LocalNetwork, localIP net.IP)
}
type configurator struct { //nolint:maligned
@@ -36,7 +36,7 @@ type configurator struct { //nolint:maligned
debug bool
defaultInterface string
defaultGateway net.IP
localSubnet net.IPNet
localNetworks []routing.LocalNetwork
localIP net.IP
networkInfoMutex sync.Mutex
@@ -64,11 +64,11 @@ func (c *configurator) SetDebug() {
}
func (c *configurator) SetNetworkInformation(
defaultInterface string, defaultGateway net.IP, localSubnet net.IPNet, localIP net.IP) {
defaultInterface string, defaultGateway net.IP, localNetworks []routing.LocalNetwork, localIP net.IP) {
c.networkInfoMutex.Lock()
defer c.networkInfoMutex.Unlock()
c.defaultInterface = defaultInterface
c.defaultGateway = defaultGateway
c.localSubnet = localSubnet
c.localNetworks = localNetworks
c.localIP = localIP
}