forked from getlantern/lantern
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request getlantern#2965 from getlantern/issue2943
use new ip and country headers closes #2943
- Loading branch information
Showing
3 changed files
with
136 additions
and
27 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
58 changes: 58 additions & 0 deletions
58
src/github.com/getlantern/flashlight/geolookup/geolookup_test.go
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,58 @@ | ||
package geolookup | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
"github.com/getlantern/fronted" | ||
"github.com/getlantern/keyman" | ||
) | ||
|
||
func TestNonDefaultClient(t *testing.T) { | ||
d := integrationDialer(t, nil) | ||
defer func() { | ||
if err := d.Close(); err != nil { | ||
t.Fatalf("Unable to close dialer: %v", err) | ||
} | ||
}() | ||
|
||
client := d.NewDirectDomainFronter() | ||
country, ip, err := lookupIp(client) | ||
if len(country) != 2 { | ||
t.Fatalf("Bad country %s", country) | ||
} | ||
|
||
if len(ip) < 7 { | ||
t.Fatalf("Bad IP %s", ip) | ||
} | ||
|
||
if err != nil { | ||
t.Fatalf("Should not have gotten an error looking up country and IP %v", err) | ||
} | ||
} | ||
|
||
func integrationDialer(t *testing.T, statsFunc func(success bool, domain, addr string, resolutionTime, connectTime, handshakeTime time.Duration)) fronted.Dialer { | ||
rootCAs, err := keyman.PoolContainingCerts("-----BEGIN CERTIFICATE-----\nMIIDdTCCAl2gAwIBAgILBAAAAAABFUtaw5QwDQYJKoZIhvcNAQEFBQAwVzELMAkG\nA1UEBhMCQkUxGTAXBgNVBAoTEEdsb2JhbFNpZ24gbnYtc2ExEDAOBgNVBAsTB1J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h3WZlXi/EjJKSZp4A==\n-----END CERTIFICATE-----\n") | ||
if err != nil { | ||
t.Fatalf("Unable to set up cert pool") | ||
} | ||
|
||
maxMasquerades := 2 | ||
masquerades := make([]*fronted.Masquerade, maxMasquerades) | ||
for i := 0; i < len(masquerades); i++ { | ||
// Good masquerade with IP | ||
masquerades[i] = &fronted.Masquerade{ | ||
Domain: "10minutemail.com", | ||
IpAddress: "162.159.250.16", | ||
} | ||
} | ||
|
||
return fronted.NewDialer(fronted.Config{ | ||
Host: "fallbacks.getiantem.org", | ||
Port: 443, | ||
Masquerades: masquerades, | ||
MaxMasquerades: maxMasquerades, | ||
RootCAs: rootCAs, | ||
OnDialStats: statsFunc, | ||
}) | ||
} |
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