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

Bump to latest http-proxy-lantern #1329

Merged
merged 8 commits into from
Nov 1, 2023
Merged
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
4 changes: 2 additions & 2 deletions .github/workflows/compile_genconfig.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ jobs:
runs-on: ubuntu-20.04 # the binary produced on newer Ubuntu versions won't run on our rather old cloudmaster
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: 1.19
- name: Granting private modules access
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/globalconfig.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: 1.19
- name: Granting private modules access
run: |
git config --global url."https://${{ secrets.CI_PRIVATE_REPOS_GH_TOKEN }}:[email protected]/".insteadOf "https://github.com/"
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: main
- run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install libpcap
run: sudo apt-get install libpcap-dev
- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: 1.19
- name: Set up gotestfmt
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/shortcut.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: 1.19
- name: Granting private modules access
run: |
git config --global url."https://${{ secrets.CI_PRIVATE_REPOS_GH_TOKEN }}:[email protected]/".insteadOf "https://github.com/"
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- run: |
cd ./shortcut
./genlist.sh
Expand Down
2 changes: 1 addition & 1 deletion chained/dialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"github.com/getlantern/bufconn"
"github.com/getlantern/errors"
"github.com/getlantern/idletiming"
gp "github.com/getlantern/proxy/v2"
gp "github.com/getlantern/proxy/v3"

"github.com/getlantern/flashlight/v7/balancer"
"github.com/getlantern/flashlight/v7/bandwidth"
Expand Down
4 changes: 2 additions & 2 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ import (
"github.com/getlantern/iptool"
"github.com/getlantern/mitm"
"github.com/getlantern/netx"
"github.com/getlantern/proxy/v2"
"github.com/getlantern/proxy/v2/filters"
"github.com/getlantern/proxy/v3"
"github.com/getlantern/proxy/v3/filters"
"github.com/getlantern/shortcut"

"github.com/getlantern/flashlight/v7/balancer"
Expand Down
2 changes: 1 addition & 1 deletion client/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"github.com/andybalholm/brotli"

"github.com/getlantern/idletiming"
"github.com/getlantern/proxy/v2/filters"
"github.com/getlantern/proxy/v3/filters"

"github.com/getlantern/flashlight/v7/chained"
"github.com/getlantern/flashlight/v7/common"
Expand Down
2 changes: 1 addition & 1 deletion client/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/stretchr/testify/require"

"github.com/getlantern/flashlight/v7/config"
"github.com/getlantern/proxy/v2/filters"
"github.com/getlantern/proxy/v3/filters"
sc "github.com/getlantern/shortcut"
"github.com/getlantern/yaml"

Expand Down
37 changes: 0 additions & 37 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"github.com/getsentry/sentry-go"
"gopkg.in/yaml.v3"

"github.com/getlantern/dhtup"
"github.com/getlantern/golog"
"github.com/getlantern/rot13"

Expand Down Expand Up @@ -109,8 +108,6 @@ type options struct {
// dictate whether the fetcher will use dual fetching (from fronted and
// chained URLs) or not.
rt http.RoundTripper

dhtupContext *dhtup.Context
}

var globalConfigDhtTarget krpc.ID
Expand Down Expand Up @@ -207,40 +204,6 @@ func pipeConfig(opts *options) (stop func()) {
dispatch(cfg, Fetched)
}, fetcher, opts.sleep,
golog.LoggerFor(fmt.Sprintf("%v.%v.fetcher.http", packageLogPrefix, opts.name)))

if opts.dhtupContext != nil {
dhtFetcher := dhtFetcher{
dhtupResource: dhtup.NewResource(dhtup.ResourceInput{
DhtTarget: globalConfigDhtTarget,
DhtContext: opts.dhtupContext,
FilePath: opts.name,
// Empty this to force data to be obtained through peers.
WebSeedUrls: []string{
"https://globalconfig.flashlightproxy.com/dhtup/",
// For the same reason as with MetainfoUrls, if there's a config change, the
// wrong data is present if you go through globalconfig.flashlightproxy.com.
// This results in the webseeding code in anacrolix/torrent getting angry,
// and everyone piling onto the bootstrap seeders.
"https://s3.ap-northeast-1.amazonaws.com/globalconfig.flashlightproxy.com/dhtup/",
},
Salt: []byte("globalconfig"),
// Empty this to force metainfo to be obtained via peers.
MetainfoUrls: []string{
// This won't work for changes until the CloudFlare caches are flushed as part of updates.
"https://globalconfig.flashlightproxy.com/dhtup/globalconfig.torrent",
// Bypass CloudFlare cache.
"https://s3.ap-northeast-1.amazonaws.com/globalconfig.flashlightproxy.com/dhtup/globalconfig.torrent",
},
}),
}
go conf.configFetcher(
stopCh,
func(cfg interface{}) {
dispatch(cfg, Dht)
},
dhtFetcher, opts.sleep,
golog.LoggerFor(fmt.Sprintf("%v.%v.fetcher.dht", packageLogPrefix, opts.name)))
}
} else {
log.Debugf("Using sticky config")
}
Expand Down
55 changes: 0 additions & 55 deletions config/dht.go

This file was deleted.

14 changes: 5 additions & 9 deletions config/initializer.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"time"

commonconfig "github.com/getlantern/common/config"
"github.com/getlantern/dhtup"
"github.com/getlantern/golog"
"github.com/getlantern/yaml"

Expand Down Expand Up @@ -38,16 +37,15 @@ func Init(
configDir string, flags map[string]interface{}, userConfig common.UserConfig,
proxiesDispatch func(interface{}, Source), onProxiesSaveError func(error),
origGlobalDispatch func(interface{}, Source), onGlobalSaveError func(error),
rt http.RoundTripper, dhtupContext *dhtup.Context) (stop func()) {
rt http.RoundTripper) (stop func()) {

staging := isStaging(flags)
proxyConfigURL := checkOverrides(flags, getProxyURL(staging), "proxies.yaml.gz")
globalConfigURL := checkOverrides(flags, getGlobalURL(staging), "global.yaml.gz")

return InitWithURLs(
configDir, flags, userConfig, proxiesDispatch, onProxiesSaveError,
origGlobalDispatch, onGlobalSaveError, proxyConfigURL, globalConfigURL, rt,
dhtupContext)
origGlobalDispatch, onGlobalSaveError, proxyConfigURL, globalConfigURL, rt)
}

type cfgWithSource struct {
Expand All @@ -63,8 +61,7 @@ func InitWithURLs(
configDir string, flags map[string]interface{}, userConfig common.UserConfig,
origProxiesDispatch func(interface{}, Source), onProxiesSaveError func(error),
origGlobalDispatch func(interface{}, Source), onGlobalSaveError func(error),
proxyURL string, globalURL string, rt http.RoundTripper,
dhtupContext *dhtup.Context) (stop func()) {
proxyURL string, globalURL string, rt http.RoundTripper) (stop func()) {

var mx sync.RWMutex
globalConfigPollInterval := DefaultGlobalConfigPollInterval
Expand Down Expand Up @@ -151,9 +148,8 @@ func InitWithURLs(
defer mx.RUnlock()
return globalConfigPollInterval
},
sticky: isSticky(flags),
rt: rt,
dhtupContext: dhtupContext,
sticky: isSticky(flags),
rt: rt,
}

stopGlobal := pipeConfig(globalOptions)
Expand Down
4 changes: 2 additions & 2 deletions config/initializer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestInit(t *testing.T) {
req.Header.Add(common.CfgSvrAuthTokenHeader, "staging-token")
return nil, nil
},
}, nil)
})
defer stop()

_, valid := gotProxies.Get(time.Second * 12)
Expand Down Expand Up @@ -86,7 +86,7 @@ func TestInitWithURLs(t *testing.T) {
inTempDir("."), flags, newTestUserConfig(),
proxiesDispatch, nil,
globalDispatch, nil,
proxyConfigURL, globalConfigURL, &http.Transport{}, nil)
proxyConfigURL, globalConfigURL, &http.Transport{})
defer stop()

// sleep some amount
Expand Down
10 changes: 6 additions & 4 deletions config_v3/embedded_global_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ func TestEmbeddedGlobal(t *testing.T) {
assert.NoError(t, err)

gl := global.(*Global)
assert.True(t, len(gl.Client.Fronted.Providers["akamai"].Masquerades) > 20)
assert.True(t, len(gl.Client.Fronted.Providers["cloudfront"].Masquerades) > 20)
assert.Containsf(t, gl.Client.Fronted.Providers["cloudfront"].HostAliases, "replica-search.lantern.io", "embedded global config does not contain replica-search cloudfront fronted provider")
assert.Containsf(t, gl.Client.Fronted.Providers["akamai"].HostAliases, "replica-search.lantern.io", "embedded global config does not contain replica-search akamai fronted provider")
akamai := gl.Client.Fronted.Providers["akamai"]
cloudfront := gl.Client.Fronted.Providers["cloudfront"]
assert.True(t, len(akamai.Masquerades) > 20, "embedded global config does not contain enough akamai masquerades: ")
assert.True(t, len(cloudfront.Masquerades) > 20, "embedded global config does not contain enough cloudfront masquerades")
assert.Containsf(t, cloudfront.HostAliases, "replica-search.lantern.io", "embedded global config does not contain replica-search cloudfront fronted provider")
assert.Containsf(t, akamai.HostAliases, "replica-search.lantern.io", "embedded global config does not contain replica-search akamai fronted provider")
}
30 changes: 0 additions & 30 deletions config_v7/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"github.com/getsentry/sentry-go"
"gopkg.in/yaml.v3"

"github.com/getlantern/dhtup"
"github.com/getlantern/golog"
"github.com/getlantern/rot13"

Expand Down Expand Up @@ -109,8 +108,6 @@ type options struct {
// dictate whether the fetcher will use dual fetching (from fronted and
// chained URLs) or not.
rt http.RoundTripper

dhtupContext *dhtup.Context
}

var globalConfigDhtTarget krpc.ID
Expand Down Expand Up @@ -207,33 +204,6 @@ func pipeConfig(opts *options) (stop func()) {
dispatch(cfg, Fetched)
}, fetcher, opts.sleep,
golog.LoggerFor(fmt.Sprintf("%v.%v.fetcher.http", packageLogPrefix, opts.name)))

if opts.dhtupContext != nil {
dhtFetcher := dhtFetcher{
dhtupResource: dhtup.NewResource(dhtup.ResourceInput{
DhtTarget: globalConfigDhtTarget,
DhtContext: opts.dhtupContext,
FilePath: opts.name,
// Empty this to force data to be obtained through peers.
WebSeedUrls: []string{"https://globalconfig.flashlightproxy.com/dhtup/"},
Salt: []byte("globalconfig"),
// Empty this to force metainfo to be obtained via peers.
MetainfoUrls: []string{
// This won't work for changes until the CloudFlare caches are flushed as part of updates.
"https://globalconfig.flashlightproxy.com/dhtup/globalconfig.torrent",
// Bypass CloudFlare cache.
"https://s3.ap-northeast-1.amazonaws.com/globalconfig.flashlightproxy.com/dhtup/globalconfig.torrent",
},
}),
}
go conf.configFetcher(
stopCh,
func(cfg interface{}) {
dispatch(cfg, Dht)
},
dhtFetcher, opts.sleep,
golog.LoggerFor(fmt.Sprintf("%v.%v.fetcher.dht", packageLogPrefix, opts.name)))
}
} else {
log.Debugf("Using sticky config")
}
Expand Down
55 changes: 0 additions & 55 deletions config_v7/dht.go

This file was deleted.

Loading