Skip to content

Commit 0371d57

Browse files
committed
feat: using radiance kindling http client and using it for downloading the WASM file and seeding
1 parent 93ab937 commit 0371d57

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

protocol/water/outbound.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
waterDownloader "github.com/getlantern/lantern-water/downloader"
1717
"github.com/getlantern/lantern-water/seed"
1818
waterVC "github.com/getlantern/lantern-water/version_control"
19+
"github.com/getlantern/radiance/kindling"
1920
"github.com/refraction-networking/water"
2021
_ "github.com/refraction-networking/water/transport/v1"
2122
"github.com/sagernet/sing-box/adapter"
@@ -74,7 +75,12 @@ func NewOutbound(ctx context.Context, router adapter.Router, logger log.ContextL
7475

7576
slogLogger := slog.New(L.NewLogHandler(logger))
7677
vc := waterVC.NewWaterVersionControl(wasmDir, slogLogger)
77-
d, err := waterDownloader.NewWASMDownloader(options.Hashsum, options.WASMAvailableAt, &http.Client{Timeout: timeout})
78+
httpClient := &http.Client{Timeout: timeout}
79+
kHTTPClient := kindling.HTTPClient()
80+
if kHTTPClient != nil {
81+
httpClient.Transport = kHTTPClient.Transport
82+
}
83+
d, err := waterDownloader.NewWASMDownloader(options.Hashsum, options.WASMAvailableAt, httpClient)
7884
if err != nil {
7985
return nil, E.New("failed to create WASM downloader", err)
8086
}
@@ -133,7 +139,7 @@ func NewOutbound(ctx context.Context, router adapter.Router, logger log.ContextL
133139
}
134140
if options.SeedEnabled {
135141
transportFilepath := filepath.Join(wasmDir, fmt.Sprintf("%s.%s", options.Transport, "wasm"))
136-
seeder, err := seed.New(transportFilepath, options.AnnounceList)
142+
seeder, err := seed.New(transportFilepath, options.AnnounceList, httpClient)
137143
if err != nil {
138144
logger.WarnContext(ctx, "failed to seed WASM", slog.Any("error", err), slog.String("transport", transportFilepath))
139145
}

0 commit comments

Comments
 (0)