Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use new geolookup api #1158

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion desktop/app/fronted_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,5 @@ func configureFronted() {
fronted.Configure(certs, cfg.Client.FrontedProviders(), config.DefaultFrontedProviderID, filepath.Join(tempConfigDir, "masquerade_cache"))

// Perform initial geolookup with a high timeout so that we don't later timeout when trying to
geolookup.Refresh()
geolookup.GetCountry(5 * time.Second)
}
8 changes: 3 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/getlantern/lantern-client

go 1.22.3
go 1.23

toolchain go1.22.8

Expand Down Expand Up @@ -38,7 +38,7 @@ require (
github.com/getlantern/eventual v1.0.0
github.com/getlantern/eventual/v2 v2.0.2
github.com/getlantern/filepersist v0.0.0-20210901195658-ed29a1cb0b7c
github.com/getlantern/flashlight/v7 v7.6.124
github.com/getlantern/flashlight/v7 v7.6.123-0.20241030174958-0910899ee120
github.com/getlantern/fronted v0.0.0-20241028162429-6616677cce5d
github.com/getlantern/golog v0.0.0-20230503153817-8e72de7e0a65
github.com/getlantern/hidden v0.0.0-20220104173330-f221c5a24770
Expand Down Expand Up @@ -164,7 +164,6 @@ require (
github.com/getlantern/fdcount v0.0.0-20210503151800-5decd65b3731 // indirect
github.com/getlantern/framed v0.0.0-20190601192238-ceb6431eeede // indirect
github.com/getlantern/geo v0.0.0-20240108161311-50692a1b69a9 // indirect
github.com/getlantern/geolookup v0.0.0-20230327091034-aebe73c6eef4 // indirect
github.com/getlantern/go-socks5 v0.0.0-20171114193258-79d4dd3e2db5 // indirect
github.com/getlantern/go-update v0.0.0-20230221120840-8d795213a8bc // indirect
github.com/getlantern/gonat v0.0.0-20201001145726-634575ba87fb // indirect
Expand Down Expand Up @@ -308,14 +307,13 @@ require (
github.com/tjfoc/gmsm v1.4.1 // indirect
github.com/tkuchiki/go-timezone v0.2.3 // indirect
github.com/ulikunitz/xz v0.5.11 // indirect
github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74 // indirect
github.com/wlynxg/anet v0.0.3 // indirect
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
github.com/xtaci/smux v1.5.27 // indirect
gitlab.com/yawning/edwards25519-extra.git v0.0.0-20211229043746-2f91fcc9fbdb // indirect
gitlab.com/yawning/obfs4.git v0.0.0-20220204003609-77af0cba934d // indirect
go.etcd.io/bbolt v1.3.10 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.42.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.45.0 // indirect
go.opentelemetry.io/otel v1.19.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.42.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v0.42.0 // indirect
Expand Down
15 changes: 6 additions & 9 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -293,16 +293,14 @@ github.com/getlantern/fdcount v0.0.0-20210503151800-5decd65b3731/go.mod h1:XZwE+
github.com/getlantern/filepersist v0.0.0-20160317154340-c5f0cd24e799/go.mod h1:8DGAx0LNUfXNnEH+fXI0s3OCBA/351kZCiz/8YSK3i8=
github.com/getlantern/filepersist v0.0.0-20210901195658-ed29a1cb0b7c h1:mcz27xtAkb1OuOLBct/uFfL1p3XxAIcFct82GbT+UZM=
github.com/getlantern/filepersist v0.0.0-20210901195658-ed29a1cb0b7c/go.mod h1:8DGAx0LNUfXNnEH+fXI0s3OCBA/351kZCiz/8YSK3i8=
github.com/getlantern/flashlight/v7 v7.6.124 h1:7UXgoSNyR6lxy0WIVP1Ddilop0lP0I2ZeYjjEGL6IzY=
github.com/getlantern/flashlight/v7 v7.6.124/go.mod h1:XpFdE7V0Na3Os1ZGVVGopmiTvuOlAfjNEyLQ4CaRmyU=
github.com/getlantern/flashlight/v7 v7.6.123-0.20241030174958-0910899ee120 h1:rWBrJ2dKtNSINhaiQ+cH5PSeIvzwZRgy2ZDYOC+HxUU=
github.com/getlantern/flashlight/v7 v7.6.123-0.20241030174958-0910899ee120/go.mod h1:JmYTbFkYwhdINabeZvlRmGK3k1Y1YH4MW9gtLuojkyA=
github.com/getlantern/framed v0.0.0-20190601192238-ceb6431eeede h1:yrU6Px3ZkvCsDLPryPGi6FN+2iqFPq+JeCb7EFoDBhw=
github.com/getlantern/framed v0.0.0-20190601192238-ceb6431eeede/go.mod h1:nhnoiS6DE6zfe+BaCMU4YI01UpsuiXnDqM5S8jxHuuI=
github.com/getlantern/fronted v0.0.0-20241028162429-6616677cce5d h1:UyXg0m0jaZV3JBKpn8MImV1RU6uknVkVyLZ+7mOu/dI=
github.com/getlantern/fronted v0.0.0-20241028162429-6616677cce5d/go.mod h1:WByj7b55hNRpeuIaES521Poebt0ABOdzG/9g+bS4BiQ=
github.com/getlantern/geo v0.0.0-20240108161311-50692a1b69a9 h1:mSg57/+t59Q08AqArlhW+3N1AVPn5ox0dTOYonRps6w=
github.com/getlantern/geo v0.0.0-20240108161311-50692a1b69a9/go.mod h1:RjQ0krF8NTCc5xo2Q1995/vZBnYg33h8svn15do7dLg=
github.com/getlantern/geolookup v0.0.0-20230327091034-aebe73c6eef4 h1:Ju9l1RretVWJTNo2vpl/xAW8Dcuiyg5kJC6LRBpCigw=
github.com/getlantern/geolookup v0.0.0-20230327091034-aebe73c6eef4/go.mod h1:4UNvIsawdB8WclVxqYv46Oe1zzWJ8wMhUO+q6tUzATo=
github.com/getlantern/go-socks5 v0.0.0-20171114193258-79d4dd3e2db5 h1:RBKofGGMt2k6eGBwX8mky9qunjL+KnAp9JdzXjiRkRw=
github.com/getlantern/go-socks5 v0.0.0-20171114193258-79d4dd3e2db5/go.mod h1:kGHRXch95rnGLHjER/GhhFiHvfnqNz7KqWD9kGfATHY=
github.com/getlantern/go-tun2socks v1.16.12-0.20201218023150-b68f09e5ae93 h1:CFLw2b6vgOmpxsRWRiTd46tiR6YKg2crIuTu4cINYcY=
Expand Down Expand Up @@ -952,8 +950,8 @@ github.com/ulikunitz/xz v0.5.9/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oW
github.com/ulikunitz/xz v0.5.11 h1:kpFauv27b6ynzBNT/Xy+1k+fK4WswhN/6PN5WhFAGw8=
github.com/ulikunitz/xz v0.5.11/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
github.com/vishvananda/netns v0.0.0-20180720170159-13995c7128cc/go.mod h1:ZjcWmFBXmLKZu9Nxj3WKYEafiSqer2rnvPr0en9UNpI=
github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74 h1:gga7acRE695APm9hlsSMoOoE65U4/TcqNj90mc69Rlg=
github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0=
github.com/vishvananda/netns v0.0.1 h1:JDkWS7Axy5ziNM3svylLhpSgqjPDb+BgVUbXoDo+iPw=
github.com/vishvananda/netns v0.0.1/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0=
github.com/vulcand/oxy v1.4.2 h1:KibUVdKrwy7eXR3uHS2pYoZ9dCzKVcgDNHD2jkPZmxU=
github.com/vulcand/oxy v1.4.2/go.mod h1:Yq8OBb0XWU/7nPSglwUH5LS2Pcp4yvad8SVayobZbSo=
github.com/willf/bitset v1.1.9/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4=
Expand Down Expand Up @@ -982,8 +980,8 @@ go.etcd.io/bbolt v1.3.10/go.mod h1:bK3UQLPJZly7IlNmV7uVHJDxfe5aK9Ll93e/74Y9oEQ=
go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.42.0 h1:pginetY7+onl4qN1vl0xW/V/v6OBZ0vVdH+esuJgvmM=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.42.0/go.mod h1:XiYsayHc36K3EByOO6nbAXnAWbrUxdjUROCEeeROOH8=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.45.0 h1:x8Z78aZx8cOF0+Kkazoc7lwUNMGy0LrzEMxTm4BbTxg=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.45.0/go.mod h1:62CPTSry9QZtOaSsE3tOzhx6LzDhHnXJ6xHeMNNiM6Q=
go.opentelemetry.io/otel v1.19.0 h1:MuS/TNf4/j4IXsZuJegVzI1cwut7Qc00344rgH7p8bs=
go.opentelemetry.io/otel v1.19.0/go.mod h1:i0QyjOq3UPoTzff0PJB2N66fb4S0+rSbSB15/oyH9fY=
go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.42.0 h1:ZtfnDL+tUrs1F0Pzfwbg2d59Gru9NCH3bgSHBM6LDwU=
Expand Down Expand Up @@ -1137,7 +1135,6 @@ golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200217220822-9197077df867/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200413165638-669c56c373c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand Down
7 changes: 5 additions & 2 deletions internalsdk/android_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"net"
"net/http"
"net/url"
Expand Down Expand Up @@ -96,6 +95,10 @@ func TestProxying(t *testing.T) {
newResult, err := Start("testapp", "en_US", testSettings{}, testSession{})
require.NoError(t, err, "Should have been able to start lantern twice")
require.Equal(t, result.HTTPAddr, newResult.HTTPAddr, "2nd start should have resulted in the same address")

// give the client time to initialize. This helps with consistency in tests
time.Sleep(1 * time.Second)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there something you can expose to synchronize on that will guarantee that it's initialized? Sleeping in tests is always a bad idea and the tests are already super flakey.


err = testProxiedRequest(helper, result.HTTPAddr, result.DNSGrabAddr, false)
require.NoError(t, err, "Proxying request via HTTP should have worked")
err = testProxiedRequest(helper, result.SOCKS5Addr, result.DNSGrabAddr, true)
Expand Down Expand Up @@ -162,7 +165,7 @@ func testProxiedRequest(helper *integrationtest.Helper, proxyAddr string, dnsGra

var buf []byte

buf, err = ioutil.ReadAll(res.Body)
buf, err = io.ReadAll(res.Body)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a sanity check to the length of the body here? Just check Response.ContentLength or whatever it's called, or add a io.LimitReader to some reasonably (large) value? Although I do see a timeout above, if it applies to body reading then it's moot.

Copy link
Contributor Author

@garmr-ulfr garmr-ulfr Oct 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It think it applies to the entire request, including reading the body.

if err != nil {
return err
}
Expand Down
39 changes: 0 additions & 39 deletions internalsdk/geo.go

This file was deleted.

7 changes: 3 additions & 4 deletions internalsdk/ios/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"encoding/hex"
"fmt"
"io"
"io/ioutil"
"net"
"net/http"
"net/http/httputil"
Expand All @@ -24,6 +23,7 @@ import (
"github.com/getlantern/flashlight/v7/email"
"github.com/getlantern/flashlight/v7/embeddedconfig"
"github.com/getlantern/flashlight/v7/geolookup"

"github.com/getlantern/lantern-client/internalsdk/common"
)

Expand Down Expand Up @@ -135,7 +135,6 @@ func (cf *configurer) Configure(userID int, proToken string, refreshProxies bool
log.Errorf("Unable to configure fronting, sticking with embedded configuration: %v", err)
} else {
log.Debug("Refreshing geolookup")
geolookup.Refresh()

go func() {
cf.uc.Country = geolookup.GetCountry(1 * time.Minute)
Expand Down Expand Up @@ -208,7 +207,7 @@ func (cf *configurer) writeUserConfig() error {
}

func (cf *configurer) readUserConfig() (*UserConfig, error) {
bytes, err := ioutil.ReadFile(cf.fullPathTo(userConfigYaml))
bytes, err := os.ReadFile(cf.fullPathTo(userConfigYaml))
if err != nil {
return nil, errors.New("Unable to read userconfig.yaml: %v", err)
}
Expand Down Expand Up @@ -387,7 +386,7 @@ func (cf *configurer) doUpdateFromWeb(rt http.RoundTripper, name string, etag st
}
}()

bytes, err := ioutil.ReadAll(gzReader)
bytes, err := io.ReadAll(gzReader)
if err != nil {
return nil, "", errors.New("Unable to read response for %v: %v", name, err)
}
Expand Down
3 changes: 1 addition & 2 deletions internalsdk/replica.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/getlantern/flashlight/v7"
"github.com/getlantern/flashlight/v7/client"
"github.com/getlantern/flashlight/v7/config"
"github.com/getlantern/flashlight/v7/geolookup"
"github.com/getlantern/flashlight/v7/proxied"
replicaConfig "github.com/getlantern/replica/config"
replicaServer "github.com/getlantern/replica/server"
Expand Down Expand Up @@ -126,7 +125,7 @@ func (s *ReplicaServer) newHandler() (*replicaServer.HttpHandler, error) {
return s.Flashlight.FeatureOptions(config.FeatureReplica, options)
},
s.Session.GetCountryCode,
geolookup.Refresh)
func() {})

input := replicaServer.NewHttpHandlerInput{}
input.SetDefaults()
Expand Down
Loading