f7fd29b246
Cloudflare hosted services provide a certain service of `/cdn-cgi/trace` with their base url (for example, `www.cloudflare.com` or `www.nginx.com`), which can be used to obtain `ip` in the probe's `geolocate` feature. The same feature was added in this pr, hence, increasing the number of `baseURL`s in `geolocate`. Co-authored-by: Simone Basso <bassosimone@gmail.com>
27 lines
439 B
Go
27 lines
439 B
Go
package geolocate
|
|
|
|
import (
|
|
"context"
|
|
"net"
|
|
"net/http"
|
|
"testing"
|
|
|
|
"github.com/apex/log"
|
|
"github.com/ooni/probe-cli/v3/internal/engine/httpheader"
|
|
)
|
|
|
|
func TestIPLookupWorksUsingcloudlflare(t *testing.T) {
|
|
ip, err := cloudflareIPLookup(
|
|
context.Background(),
|
|
http.DefaultClient,
|
|
log.Log,
|
|
httpheader.UserAgent(),
|
|
)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if net.ParseIP(ip) == nil {
|
|
t.Fatalf("not an IP address: '%s'", ip)
|
|
}
|
|
}
|