Skip to content

Commit

Permalink
Fixes to use new fronted
Browse files Browse the repository at this point in the history
  • Loading branch information
myleshorton committed Nov 26, 2024
1 parent 63d07db commit 545a0b1
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions flashlight.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ func New(
appName, appVersion, revisionDate, deviceID, isPro, func() string {
return geolookup.GetCountry(0)
})
email.SetHTTPClient(proxied.DirectThenFrontedClient(1 * time.Minute))

f := &Flashlight{
callbacks: clientCallbacks{
Expand Down Expand Up @@ -190,7 +189,7 @@ func New(
log.Errorf("Unable to get trusted ca certs, not configuring fronted: %s", err)
}

f.fronted, err = fronted.NewFronter(certs, globalConfig.Client.FrontedProviders(), config.DefaultFrontedProviderID, filepath.Join(configDir, "masquerade_cache"))
f.fronted, err = fronted.NewFronted(certs, globalConfig.Client.FrontedProviders(), config.DefaultFrontedProviderID, filepath.Join(configDir, "masquerade_cache"))
if err != nil {
log.Errorf("Unable to configure fronted: %v", err)
}
Expand Down Expand Up @@ -282,7 +281,7 @@ func New(

f.addProxyListener(func(proxies map[string]*commonconfig.ProxyConfig, src config.Source) {
log.Debug("Applying proxy config with proxies")
dialers := f.client.Configure(chained.CopyConfigs(proxies))
dialers := f.client.Configure(chained.CopyConfigs(proxies), f.fronted)
log.Debugf("Got %v dialers", len(dialers))
if dialers != nil {
f.callbacks.onProxiesUpdate(dialers, src)
Expand Down Expand Up @@ -400,7 +399,7 @@ func (f *Flashlight) startConfigService() (services.StopFn, error) {
configOpts := &services.ConfigOptions{
OriginURL: url,
UserConfig: f.userConfig,
RoundTripper: proxied.ChainedThenFronted(),
RoundTripper: proxied.ChainedThenFronted(f.fronted),
}
return services.StartConfigService(handler, configOpts)
}
Expand Down Expand Up @@ -552,7 +551,7 @@ func (f *Flashlight) startGlobalConfigFetch() func() {
log.Debugf("Applying global config")
f.onGlobalConfig(cfg, src)
}
rt := proxied.ParallelPreferChained()
rt := proxied.ParallelPreferChained(f.fronted)

onConfigSaveError := func(err error) {
f.errorHandler(ErrorTypeConfigSaveFailure, err)
Expand Down Expand Up @@ -622,7 +621,7 @@ func (f *Flashlight) RunClientListeners(httpProxyAddr, socksProxyAddr string,
err := f.client.ListenAndServeHTTP(httpProxyAddr, func() {
log.Debug("Started client HTTP proxy")
proxied.SetProxyAddr(f.client.Addr)
email.SetHTTPClient(proxied.DirectThenFrontedClient(1 * time.Minute))
email.SetHTTPClient(proxied.DirectThenFrontedClient(1*time.Minute, f.fronted))

if afterStart != nil {
afterStart(f.client)
Expand Down

0 comments on commit 545a0b1

Please sign in to comment.