Skip to content

Commit 88a1bc3

Browse files
committed
server/proxy/tcpproxy: reuse addr in TCPProxy.Run
"addr" is the result of net.JoinHostPort which supports IPv6 address. Rather than ranging "tp.Endpoints" again, it's better to reuse "addr" in the first loop to collect "eps". See #7942 and #7943 for context. Signed-off-by: Jes Cok <[email protected]>
1 parent ce4b4e5 commit 88a1bc3

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

server/proxy/tcpproxy/userspace.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,12 @@ func (tp *TCPProxy) Run() error {
7474
if tp.MonitorInterval == 0 {
7575
tp.MonitorInterval = 5 * time.Minute
7676
}
77+
78+
var eps []string // for logging
7779
for _, srv := range tp.Endpoints {
7880
addr := net.JoinHostPort(srv.Target, fmt.Sprintf("%d", srv.Port))
7981
tp.remotes = append(tp.remotes, &remote{srv: srv, addr: addr})
80-
}
81-
82-
var eps []string
83-
for _, ep := range tp.Endpoints {
84-
eps = append(eps, fmt.Sprintf("%s:%d", ep.Target, ep.Port))
82+
eps = append(eps, addr)
8583
}
8684
if tp.Logger != nil {
8785
tp.Logger.Info("ready to proxy client requests", zap.Strings("endpoints", eps))

0 commit comments

Comments
 (0)