81 lines
2.5 KiB
Diff
81 lines
2.5 KiB
Diff
|
From 49798c915f249922fb1e1ee87be98b1977ee2579 Mon Sep 17 00:00:00 2001
|
||
|
From: Hylke Visser <htdvisser@gmail.com>
|
||
|
Date: Thu, 14 Sep 2017 17:20:22 +0200
|
||
|
Subject: [PATCH 1/3] Fix REST API gateway loopback address
|
||
|
|
||
|
---
|
||
|
web/web.go | 9 ++++++++-
|
||
|
1 file changed, 8 insertions(+), 1 deletion(-)
|
||
|
|
||
|
diff --git a/web/web.go b/web/web.go
|
||
|
index 13d37dfdb..0d4e93221 100644
|
||
|
--- a/web/web.go
|
||
|
+++ b/web/web.go
|
||
|
@@ -391,7 +391,14 @@ func (h *Handler) Run(ctx context.Context) error {
|
||
|
)
|
||
|
av2.RegisterGRPC(grpcSrv)
|
||
|
|
||
|
- hh, err := av2.HTTPHandler(grpcl.Addr().String())
|
||
|
+ lAddr := grpcl.Addr().String()
|
||
|
+ host, port, _ := net.SplitHostPort(lAddr)
|
||
|
+ ip := net.ParseIP(host)
|
||
|
+ if ip.Equal(net.IPv4zero) || ip.Equal(net.IPv6zero) {
|
||
|
+ lAddr = net.JoinHostPort("localhost", port)
|
||
|
+ }
|
||
|
+
|
||
|
+ hh, err := av2.HTTPHandler(lAddr)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
From 1d3d6614ffe6d04d0b6ae7046bac1709057f4f04 Mon Sep 17 00:00:00 2001
|
||
|
From: Hylke Visser <htdvisser@gmail.com>
|
||
|
Date: Thu, 14 Sep 2017 21:39:29 +0200
|
||
|
Subject: [PATCH 2/3] Add err check for SplitHostPort of Listener address
|
||
|
|
||
|
---
|
||
|
web/web.go | 5 ++++-
|
||
|
1 file changed, 4 insertions(+), 1 deletion(-)
|
||
|
|
||
|
diff --git a/web/web.go b/web/web.go
|
||
|
index 0d4e93221..6e5054906 100644
|
||
|
--- a/web/web.go
|
||
|
+++ b/web/web.go
|
||
|
@@ -392,7 +392,10 @@ func (h *Handler) Run(ctx context.Context) error {
|
||
|
av2.RegisterGRPC(grpcSrv)
|
||
|
|
||
|
lAddr := grpcl.Addr().String()
|
||
|
- host, port, _ := net.SplitHostPort(lAddr)
|
||
|
+ host, port, err := net.SplitHostPort(lAddr)
|
||
|
+ if err != nil {
|
||
|
+ return err
|
||
|
+ }
|
||
|
ip := net.ParseIP(host)
|
||
|
if ip.Equal(net.IPv4zero) || ip.Equal(net.IPv6zero) {
|
||
|
lAddr = net.JoinHostPort("localhost", port)
|
||
|
|
||
|
From b2ca81d57eafddc0ff2cbbcf6f00a85d6f81a536 Mon Sep 17 00:00:00 2001
|
||
|
From: Hylke Visser <htdvisser@gmail.com>
|
||
|
Date: Mon, 18 Sep 2017 14:53:45 +0200
|
||
|
Subject: [PATCH 3/3] Add comment to explain the reason for PR #3174
|
||
|
|
||
|
---
|
||
|
web/web.go | 4 ++++
|
||
|
1 file changed, 4 insertions(+)
|
||
|
|
||
|
diff --git a/web/web.go b/web/web.go
|
||
|
index 6e5054906..c063963a3 100644
|
||
|
--- a/web/web.go
|
||
|
+++ b/web/web.go
|
||
|
@@ -398,6 +398,10 @@ func (h *Handler) Run(ctx context.Context) error {
|
||
|
}
|
||
|
ip := net.ParseIP(host)
|
||
|
if ip.Equal(net.IPv4zero) || ip.Equal(net.IPv6zero) {
|
||
|
+ // The gRPC server is listening on an empty/wildcard address (0.0.0.0 or ::).
|
||
|
+ // We should be able to connect to an empty IP just fine, but as there were
|
||
|
+ // some issues with this in the past (#3004, #3149), we explicitly tell
|
||
|
+ // the REST API gateway to connect to localhost.
|
||
|
lAddr = net.JoinHostPort("localhost", port)
|
||
|
}
|
||
|
|