Skip to content

Commit 4aa6119

Browse files
committed
Merge DialHost must connect to the requested host (#1683)
2 parents 87a7661 + 65fb7cb commit 4aa6119

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

AUTHORS

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,4 +135,5 @@ Neal Turett <[email protected]>
135135
Doug Schaapveld <[email protected]>
136136
Steven Seidman <[email protected]>
137137
Wojciech Przytuła <[email protected]>
138-
João Reis <[email protected]>
138+
João Reis <[email protected]>
139+
Lauro Ramos Venancio <[email protected]>

dial.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,12 @@ func (hd *defaultHostDialer) DialHost(ctx context.Context, host *HostInfo) (*Dia
4545
return nil, fmt.Errorf("host missing port: %v", port)
4646
}
4747

48-
addr := host.HostnameAndPort()
49-
conn, err := hd.dialer.DialContext(ctx, "tcp", addr)
48+
connAddr := host.ConnectAddressAndPort()
49+
conn, err := hd.dialer.DialContext(ctx, "tcp", connAddr)
5050
if err != nil {
5151
return nil, err
5252
}
53+
addr := host.HostnameAndPort()
5354
return WrapTLS(ctx, conn, addr, hd.tlsConfig)
5455
}
5556

host_source.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,13 @@ func (h *HostInfo) HostnameAndPort() string {
401401
return net.JoinHostPort(h.hostname, strconv.Itoa(h.port))
402402
}
403403

404+
func (h *HostInfo) ConnectAddressAndPort() string {
405+
h.mu.Lock()
406+
defer h.mu.Unlock()
407+
addr, _ := h.connectAddressLocked()
408+
return net.JoinHostPort(addr.String(), strconv.Itoa(h.port))
409+
}
410+
404411
func (h *HostInfo) String() string {
405412
h.mu.RLock()
406413
defer h.mu.RUnlock()

0 commit comments

Comments
 (0)