Skip to content

Commit

Permalink
fixed statstracker usage
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Fisk authored and Adam Fisk committed Nov 13, 2024
1 parent 5cef9dd commit de764f1
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions dialer/fastconnect.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import (
"sort"
"sync"
"time"

"github.com/getlantern/flashlight/v7/stats"
)

type connectTimeProxyDialer struct {
Expand Down Expand Up @@ -44,9 +42,8 @@ type fastConnectDialer struct {
next func(*Options, Dialer) Dialer
opts *Options

onError func(error, bool)
onSuccess func(ProxyDialer)
statsTracker stats.Tracker
onError func(error, bool)
onSuccess func(ProxyDialer)
}

func newFastConnectDialer(opts *Options, next func(opts *Options, existing Dialer) Dialer) *fastConnectDialer {
Expand Down Expand Up @@ -76,7 +73,6 @@ func (fcd *fastConnectDialer) DialContext(ctx context.Context, network, addr str
conn, failedUpstream, err := td.DialContext(ctx, network, addr)
if err != nil {
hasSucceeding := len(fcd.connected) > 0
fcd.statsTracker.SetHasSucceedingProxy(hasSucceeding)
fcd.onError(err, hasSucceeding)
// Error connecting to the proxy or to the destination
if failedUpstream {
Expand All @@ -88,7 +84,6 @@ func (fcd *fastConnectDialer) DialContext(ctx context.Context, network, addr str
}
return nil, err
}
fcd.statsTracker.SetHasSucceedingProxy(true)
fcd.onSuccess(td)
return conn, err
}
Expand Down Expand Up @@ -126,7 +121,6 @@ func (fcd *fastConnectDialer) onConnected(pd ProxyDialer, connectTime time.Durat
log.Debugf("Setting new top dialer to %v", newTopDialer.Name())
fcd.topDialer.set(newTopDialer)
}
fcd.statsTracker.SetHasSucceedingProxy(true)
fcd.onSuccess(td)
log.Debug("Finished adding connected dialer")
}
Expand Down

0 comments on commit de764f1

Please sign in to comment.