Skip to content

Commit

Permalink
AppEngine: Use recursive include for SPF records; fixes client9#125
Browse files Browse the repository at this point in the history
  • Loading branch information
dsamarin committed May 17, 2018
1 parent a512522 commit a8ecd7e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
26 changes: 16 additions & 10 deletions appengine.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,31 @@ func lookupSPFRecord(name string, f func(dir string) error) error {
// DownloadAppEngine downloads and returns raw bytes of the Google App Engine ip
// range list
func DownloadAppEngine() ([]string, error) {
var ranges []string
if err := lookupSPFRecord("_cloud-netblocks.googleusercontent.com", func(dir string) error {
inc := strings.TrimPrefix(dir, "include:")
if dir == inc {
return nil
}
ranges := []string{}
domainList := []string{"_cloud-netblocks.googleusercontent.com"}

return lookupSPFRecord(inc, func(dir string) error {
for len(domainList) > 0 {
// Dequeue a domain from this list
var domain string
domain, domainList = domainList[0], domainList[1:]
err := lookupSPFRecord(domain, func(dir string) error {
// Enqueue domain from this record
if inc := strings.TrimPrefix(dir, "include:"); dir != inc {
domainList = append(domainList, inc)
}
// Add IPv4 range
if ip4 := strings.TrimPrefix(dir, "ip4:"); dir != ip4 {
ranges = append(ranges, ip4)
}
// Add IPv6 range
if ip6 := strings.TrimPrefix(dir, "ip6:"); dir != ip6 {
ranges = append(ranges, ip6)
}

return nil
})
}); err != nil {
return nil, err
if err != nil {
return nil, err
}
}

return ranges, nil
Expand Down
2 changes: 1 addition & 1 deletion datacenters-stats.csv
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Datacenter Name, Total IPs
Amazon AWS,1542202570030687795110271325976
Cloudflare Inc,1109194275199700726309617091584
Google App Engine,9903520314283042199195425536
Google App Engine,9903520314283042199196141312
Microsoft Azure,13024127
Akamai,8145728
SoftLayer,1903104
Expand Down
9 changes: 6 additions & 3 deletions datacenters.csv
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,11 @@
35.184.0.0,35.190.239.255,Google App Engine,https://cloud.google.com/appengine
35.192.0.0,35.199.191.255,Google App Engine,https://cloud.google.com/appengine
35.200.0.0,35.203.223.255,Google App Engine,https://cloud.google.com/appengine
35.203.240.0,35.207.255.255,Google App Engine,https://cloud.google.com/appengine
35.224.0.0,35.229.255.255,Google App Engine,https://cloud.google.com/appengine
35.203.232.0,35.207.255.255,Google App Engine,https://cloud.google.com/appengine
35.224.0.0,35.235.127.255,Google App Engine,https://cloud.google.com/appengine
35.235.192.0,35.235.207.255,Google App Engine,https://cloud.google.com/appengine
35.235.224.0,35.235.239.255,Google App Engine,https://cloud.google.com/appengine
35.236.0.0,35.241.63.255,Google App Engine,https://cloud.google.com/appengine
37.9.169.0,37.9.169.255,WebSupport,https://www.websupport.sk/
37.9.224.0,37.9.228.223,seeweb.it,http://seeweb.it/
37.10.0.0,37.10.127.255,Optimate Server,http://optimate-server.de/
Expand Down Expand Up @@ -1846,7 +1849,7 @@
128.204.208.0,128.204.215.255,ecritel.net,http://www.ecritel.net/
130.185.144.0,130.185.151.255,Titan Internet Ltd,http://www.titaninternet.co.uk/index.cfm
130.185.152.0,130.185.155.255,webexxpurts.com,http://webexxpurts.com/
130.211.8.0,130.211.255.255,Google App Engine,https://cloud.google.com/appengine
130.211.4.0,130.211.255.255,Google App Engine,https://cloud.google.com/appengine
131.0.72.0,131.0.75.255,Cloudflare Inc,https://www.cloudflare.com/
131.253.12.8,131.253.12.31,Microsoft Azure,http://www.windowsazure.com/en-us/
131.253.12.36,131.253.12.79,Microsoft Azure,http://www.windowsazure.com/en-us/
Expand Down

0 comments on commit a8ecd7e

Please sign in to comment.