From 6e58d7dd445da1d0d1d7be53ece4acedb2265c02 Mon Sep 17 00:00:00 2001 From: Jake Coffman Date: Fri, 26 Apr 2024 08:19:07 -0500 Subject: [PATCH 1/3] fix WSL connection refused to the fake API --- internal/server/api.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/server/api.go b/internal/server/api.go index 00d24d5..ff795c8 100644 --- a/internal/server/api.go +++ b/internal/server/api.go @@ -44,6 +44,10 @@ func NewAPI(expected []model.Output, writer io.Writer) *API { if runtime.GOOS == "linux" { fakeAPIHost = "0.0.0.0" } + // if running on WSL set the host back to 127.0.0.1 + if version, err := os.ReadFile("/proc/version"); err == nil && strings.Contains(string(version), "Microsoft") { + fakeAPIHost = "127.0.0.1" + } if os.Getenv("FAKE_API_HOST") != "" { fakeAPIHost = os.Getenv("FAKE_API_HOST") } From 3093912d92a2f38f6672b391ccffd6db9633ca6b Mon Sep 17 00:00:00 2001 From: Jake Coffman Date: Fri, 26 Apr 2024 08:21:58 -0500 Subject: [PATCH 2/3] fix WSL connection refused to the fake API --- internal/server/api.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/server/api.go b/internal/server/api.go index ff795c8..7c281a1 100644 --- a/internal/server/api.go +++ b/internal/server/api.go @@ -43,10 +43,10 @@ func NewAPI(expected []model.Output, writer io.Writer) *API { fakeAPIHost := "127.0.0.1" if runtime.GOOS == "linux" { fakeAPIHost = "0.0.0.0" - } - // if running on WSL set the host back to 127.0.0.1 - if version, err := os.ReadFile("/proc/version"); err == nil && strings.Contains(string(version), "Microsoft") { - fakeAPIHost = "127.0.0.1" + // if running on WSL set the host back to 127.0.0.1 because 0.0.0.0 doesn't work + if version, err := os.ReadFile("/proc/version"); err == nil && strings.Contains(string(version), "Microsoft") { + fakeAPIHost = "127.0.0.1" + } } if os.Getenv("FAKE_API_HOST") != "" { fakeAPIHost = os.Getenv("FAKE_API_HOST") From 01e5b93c057b132851b4536d22275aa7265c3721 Mon Sep 17 00:00:00 2001 From: Jake Coffman Date: Fri, 26 Apr 2024 08:25:43 -0500 Subject: [PATCH 3/3] fix WSL connection refused to the fake API --- internal/server/api.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/server/api.go b/internal/server/api.go index 7c281a1..af29374 100644 --- a/internal/server/api.go +++ b/internal/server/api.go @@ -43,7 +43,7 @@ func NewAPI(expected []model.Output, writer io.Writer) *API { fakeAPIHost := "127.0.0.1" if runtime.GOOS == "linux" { fakeAPIHost = "0.0.0.0" - // if running on WSL set the host back to 127.0.0.1 because 0.0.0.0 doesn't work + // if running on WSL, 0.0.0.0 doesn't work if version, err := os.ReadFile("/proc/version"); err == nil && strings.Contains(string(version), "Microsoft") { fakeAPIHost = "127.0.0.1" }