From a8cc57c4c96bbfd7a9be2326384234f522502512 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Wed, 9 Sep 2026 01:19:48 -0600 Subject: [PATCH] feat(iplist): make HTTP client part of Load API --- net/iplist/iplist.go | 8 ++------ net/iplist/iplist_test.go | 4 ++-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/net/iplist/iplist.go b/net/iplist/iplist.go index 05d5351..f22d64f 100644 --- a/net/iplist/iplist.go +++ b/net/iplist/iplist.go @@ -32,13 +32,9 @@ const ( // that are themselves HTTP(S) URLs are recursively expanded up to // MaxNestedSources levels. URL responses are cached below cacheDir and the // cache remains available across process restarts. -func Load(ctx context.Context, source, cacheDir string) ([]string, error) { - return LoadWithClient(ctx, source, cacheDir, nil) -} - -// LoadWithClient is Load with an optional HTTP client. A nil client uses the +// Load reads a source with an optional HTTP client. A nil client uses the // internal client with the package's standard timeout and transport policy. -func LoadWithClient(ctx context.Context, source, cacheDir string, client *http.Client) ([]string, error) { +func Load(ctx context.Context, source, cacheDir string, client *http.Client) ([]string, error) { if client == nil { client = https.NewInternalClient() } diff --git a/net/iplist/iplist_test.go b/net/iplist/iplist_test.go index 0454be4..6a56bcb 100644 --- a/net/iplist/iplist_test.go +++ b/net/iplist/iplist_test.go @@ -28,7 +28,7 @@ func TestLoadWithClient(t *testing.T) { called = true return http.DefaultTransport.RoundTrip(r) })} - entries, err := LoadWithClient(context.Background(), server.URL, t.TempDir(), client) + entries, err := Load(context.Background(), server.URL, t.TempDir(), client) if err != nil { t.Fatal(err) } @@ -54,7 +54,7 @@ func TestLoadURLAuthCacheAndNested(t *testing.T) { defer outer.Close() cacheDir := t.TempDir() - got, err := Load(context.Background(), strings.Replace(outer.URL, "http://", "http://u:p@", 1), cacheDir) + got, err := Load(context.Background(), strings.Replace(outer.URL, "http://", "http://u:p@", 1), cacheDir, nil) if err != nil || !authOK || len(got) != 1 || got[0] != "192.0.2.2" { t.Fatalf("auth=%v entries=%#v err=%v", authOK, got, err) }