Skip to content

Commit

Permalink
Merge pull request #4 from b0bu/feat/release-4
Browse files Browse the repository at this point in the history
feat: add allow list
  • Loading branch information
b0bu authored Apr 17, 2023
2 parents 14a26ae + ad34b21 commit ae875f0
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions ZscalerPrefixList.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,25 @@ type City []struct {
Range string `json:"range"`
}

// filter cities by allow list
func allowedRegion(s string) bool {
regions := []string{"Amsterdam", "London", "Paris", "Manchester"}
for _, region := range regions {
if strings.Contains(s, region) {
return true
}
}
return false
}

// return slice "prefixes" containing ipv4 and ipv6 prefixes for each city for each continent
func ExtractIpPrefixes(r Response) []string {
var prefixes []string

for _, continent := range r.ZsCloudNet {
for _, city := range continent {
prefixes = append(prefixes, city[0].Range)
for city, ranges := range continent {
if allowedRegion(city) {
prefixes = append(prefixes, ranges[0].Range)
}
}
}
return prefixes
Expand Down

0 comments on commit ae875f0

Please sign in to comment.