Skip to content

Commit

Permalink
lazily set issue httpclient
Browse files Browse the repository at this point in the history
  • Loading branch information
myleshorton committed Dec 2, 2024
1 parent 72d9979 commit 4ad166d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
2 changes: 0 additions & 2 deletions flashlight.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"github.com/getlantern/flashlight/v7/email"
"github.com/getlantern/flashlight/v7/geolookup"
"github.com/getlantern/flashlight/v7/goroutines"
"github.com/getlantern/flashlight/v7/issue"
fops "github.com/getlantern/flashlight/v7/ops"
"github.com/getlantern/flashlight/v7/otel"
"github.com/getlantern/flashlight/v7/proxied"
Expand Down Expand Up @@ -196,7 +195,6 @@ func New(
log.Errorf("Unable to configure fronted: %v", err)
}
proxied.SetFronted(f.fronted)
issue.SetHTTPClient(proxied.DirectThenFrontedClient(30 * time.Second))

var grabber dnsgrab.Server
var grabberErr error
Expand Down
11 changes: 2 additions & 9 deletions issue/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import (
"github.com/getlantern/flashlight/v7/common"
"github.com/getlantern/flashlight/v7/geolookup"
"github.com/getlantern/flashlight/v7/logging"
"github.com/getlantern/flashlight/v7/proxied"
"github.com/getlantern/flashlight/v7/util"
"github.com/getlantern/golog"
)

var (
log = golog.LoggerFor("flashlight.issue")
maxLogSize = 10247680
httpClient *http.Client
)

const (
Expand Down Expand Up @@ -76,10 +76,7 @@ func sendReport(
osVersion string,
attachments []*Attachment,
) error {
if httpClient == nil {
log.Errorf("httpClient is nil, using default client")
httpClient = http.DefaultClient
}
httpClient := proxied.DirectThenFrontedClient(30 * time.Second)
r := &Request{}

r.Type = Request_ISSUE_TYPE(issueType)
Expand Down Expand Up @@ -155,7 +152,3 @@ func sendReport(
log.Debugf("issue report sent: %v", resp)
return nil
}

func SetHTTPClient(client *http.Client) {
httpClient = client
}

0 comments on commit 4ad166d

Please sign in to comment.