Skip to content

Commit

Permalink
rename ipAddr to ipPortAddr
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoPolo committed Jan 23, 2025
1 parent f071f3e commit 927145d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions p2p/transport/websocket/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,15 +209,15 @@ func (t *WebsocketTransport) maDial(ctx context.Context, raddr ma.Multiaddr) (ma
copytlsClientConf := t.tlsClientConf.Clone()
copytlsClientConf.ServerName = sni
dialer.TLSClientConfig = copytlsClientConf
ipAddr := wsurl.Host
ipPortAddr := wsurl.Host
// We set the `.Host` to the sni field so that the host header gets properly set.
wsurl.Host = sni + ":" + wsurl.Port()
// Setting the NetDial because we already have the resolved IP address, so we can avoid another resolution.
dialer.NetDial = func(network, address string) (net.Conn, error) {
var tcpAddr *net.TCPAddr
var err error
if address == wsurl.Host {
tcpAddr, err = net.ResolveTCPAddr(network, ipAddr) // Use our already resolved IP address
tcpAddr, err = net.ResolveTCPAddr(network, ipPortAddr) // Use our already resolved IP address
} else {
tcpAddr, err = net.ResolveTCPAddr(network, address)
}
Expand Down

0 comments on commit 927145d

Please sign in to comment.