// AddPathRule maps a list of trusted netblocks to a given path
AddPathRule maps a list of trusted netblocks to a given path
// AddPathRule maps a list of trusted netblocks to a given path
func (fw *Firewall) AddPathRule(path string, networks []string) error {
	if _, exists := fw.Rules.PathToNetblocks[path]; exists {
		return ErrPathHasRule
	}
	var trusted []net.IPNet
	for _, network := range networks {
		_, trustedNetblock, err := net.ParseCIDR(network)
		if err != nil {
			return fmt.Errorf("could not parse CIDR: %s", err)
		}
		trusted = append(trusted, *trustedNetblock)
	}
	fw.Rules.PathToNetblocks[path] = trusted
	return nil
}
func ( fw * Firewall ) AddPathRule ( path string , networks [ ] string ) error { if _ , exists := fw . Rules . PathToNetblocks [ path ] ; exists { return ErrPathHasRule } var trusted [ ] net . IPNet for _ , network := range networks { _ , trustedNetblock , err := net . ParseCIDR ( network ) if err != nil { return fmt . Errorf ( " " , err ) } trusted = append ( trusted , * trustedNetblock ) } fw . Rules . PathToNetblocks [ path ] = trusted return nil }
AddPathRule maps a list of trusted netblocks to a given path
AddPathRule maps a list of trusted netblocks to a given path
// parse network CIDRs // add trusted netblocks to path