This repository has been archived by the owner on Jan 29, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into 54-1-7-19-Fixes
Merged master back in to feature branch in order to bring in fixes needed to test the new installer.
- Loading branch information
Showing
34 changed files
with
798 additions
and
304 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package yaml | ||
|
||
import "net" | ||
import "github.com/pkg/errors" | ||
|
||
//filtering implements config.Filtering | ||
type filtering struct { | ||
AlwaysInclude []string `yaml:"AlwaysInclude"` | ||
NeverInclude []string `yaml:"NeverInclude"` | ||
InternalSubnets []string `yaml:"InternalSubnets"` | ||
} | ||
|
||
func (f *filtering) GetAlwaysIncludeSubnets() ([]net.IPNet, []error) { | ||
return f.parseSubnetList(f.AlwaysInclude) | ||
} | ||
|
||
func (f *filtering) GetNeverIncludeSubnets() ([]net.IPNet, []error) { | ||
return f.parseSubnetList(f.NeverInclude) | ||
} | ||
|
||
func (f *filtering) GetInternalSubnets() ([]net.IPNet, []error) { | ||
return f.parseSubnetList(f.InternalSubnets) | ||
} | ||
|
||
func (f *filtering) parseSubnetList(netList []string) ([]net.IPNet, []error) { | ||
var errorList []error | ||
var nets []net.IPNet | ||
for j := range netList { | ||
//parse as network | ||
_, network, err := net.ParseCIDR(netList[j]) | ||
if err != nil { | ||
//parse as IP | ||
ipAddr := net.ParseIP(netList[j]) | ||
|
||
if ipAddr == nil { | ||
errorList = append(errorList, errors.WithStack(err)) | ||
continue | ||
} | ||
|
||
network = f.ipToIPNet(ipAddr) | ||
} | ||
|
||
nets = append(nets, *network) | ||
} | ||
return nets, errorList | ||
} | ||
|
||
func (f *filtering) ipToIPNet(ipAddr net.IP) *net.IPNet { | ||
var netmask net.IPMask | ||
if ipAddr.To4() == nil { | ||
netmask = net.CIDRMask(32, 32) | ||
} else { | ||
netmask = net.CIDRMask(128, 128) | ||
} | ||
return &net.IPNet{ | ||
IP: ipAddr, | ||
Mask: netmask, | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.