Skip to content

Commit

Permalink
strip dhtup for now
Browse files Browse the repository at this point in the history
  • Loading branch information
myleshorton committed Oct 31, 2023
1 parent 83dc69e commit 971d252
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 208 deletions.
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
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.

14 changes: 5 additions & 9 deletions config_v7/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_v7/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
6 changes: 1 addition & 5 deletions flashlight.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (

commonconfig "github.com/getlantern/common/config"
"github.com/getlantern/detour"
"github.com/getlantern/dhtup"
"github.com/getlantern/dnsgrab"
"github.com/getlantern/errors"
"github.com/getlantern/eventual"
Expand Down Expand Up @@ -95,7 +94,6 @@ type Flashlight struct {
client *client.Client
op *fops.Op
errorHandler func(HandledErrorType, error)
dhtupContext *dhtup.Context
mxProxyListeners sync.RWMutex
proxyListeners []func(map[string]*commonconfig.ProxyConfig, config.Source)
}
Expand Down Expand Up @@ -276,7 +274,7 @@ func (f *Flashlight) startConfigFetch() func() {
stopConfig := config.Init(
f.configDir, f.flagsAsMap, f.userConfig,
proxiesDispatch, onProxiesSaveError,
globalDispatch, onConfigSaveError, rt, f.dhtupContext)
globalDispatch, onConfigSaveError, rt)
return stopConfig
}

Expand Down Expand Up @@ -326,7 +324,6 @@ func New(
reverseDNS func(host string) (string, error),
adTrackUrl func() string,
eventWithLabel func(category, action, label string),
dhtupContext *dhtup.Context,
) (*Flashlight, error) {
log.Debugf("Running in app: %v", appName)
log.Debugf("Using configdir: %v", configDir)
Expand Down Expand Up @@ -357,7 +354,6 @@ func New(
errorHandler: func(t HandledErrorType, err error) {
log.Errorf("%v: %v", t, err)
},
dhtupContext: dhtupContext,
proxyListeners: make([]func(map[string]*commonconfig.ProxyConfig, config.Source), 0),
}

Expand Down
Loading

0 comments on commit 971d252

Please sign in to comment.