Index: content/browser/renderer_host/p2p/socket_host_tcp.cc |
diff --git a/content/browser/renderer_host/p2p/socket_host_tcp.cc b/content/browser/renderer_host/p2p/socket_host_tcp.cc |
index 978f6269f5d65e4ae638f08136c8e549166424d7..962c30be4ca3e3e4ae8b2a140525e9c35680e1fb 100644 |
--- a/content/browser/renderer_host/p2p/socket_host_tcp.cc |
+++ b/content/browser/renderer_host/p2p/socket_host_tcp.cc |
@@ -85,6 +85,13 @@ bool P2PSocketHostTcpBase::Init(const net::IPEndPoint& local_address, |
net::HostPortPair dest_host_port_pair = |
net::HostPortPair::FromIPEndPoint(remote_address.ip_address); |
+ // If there is no resolved address, let's try with domain name, assuming |
+ // socket layer will do the DNS resolve. |
+ if (remote_address.ip_address.address().empty()) { |
+ dest_host_port_pair = net::HostPortPair( |
+ remote_address.hostname, remote_address.ip_address.port()); |
Sergey Ulanov
2014/07/03 03:31:06
DCHECK that hostname is not empty?
Mallinath (Gone from Chromium)
2014/07/07 17:56:44
Done.
|
+ } |
+ |
// TODO(mallinath) - We are ignoring local_address altogether. We should |
// find a way to inject this into ProxyResolvingClientSocket. This could be |
// a problem on multi-homed host. |
@@ -224,8 +231,8 @@ void P2PSocketHostTcpBase::OnOpen() { |
void P2PSocketHostTcpBase::DoSendSocketCreateMsg() { |
DCHECK(socket_.get()); |
- net::IPEndPoint address; |
- int result = socket_->GetLocalAddress(&address); |
+ net::IPEndPoint local_address; |
+ int result = socket_->GetLocalAddress(&local_address); |
if (result < 0) { |
LOG(ERROR) << "P2PSocketHostTcpBase::OnConnected: unable to get local" |
<< " address: " << result; |
@@ -233,13 +240,28 @@ void P2PSocketHostTcpBase::DoSendSocketCreateMsg() { |
return; |
} |
- VLOG(1) << "Local address: " << address.ToString(); |
+ VLOG(1) << "Local address: " << local_address.ToString(); |
+ |
+ net::IPEndPoint remote_address; |
+ result = socket_->GetPeerAddress(&remote_address); |
+ if (result < 0) { |
+ LOG(ERROR) << "P2PSocketHostTcpBase::OnConnected: unable to get peer" |
+ << " address: " << result; |
+ OnError(); |
+ return; |
+ } |
+ VLOG(1) << "Remote address: " << remote_address.ToString(); |
+ if (remote_address_.ip_address.address().empty()) { |
+ // Save |remote_address| if address is empty. |
+ remote_address_.ip_address = remote_address; |
+ } |
// If we are not doing TLS, we are ready to send data now. |
// In case of TLS SignalConnect will be sent only after TLS handshake is |
// successfull. So no buffering will be done at socket handlers if any |
// packets sent before that by the application. |
- message_sender_->Send(new P2PMsg_OnSocketCreated(id_, address)); |
+ message_sender_->Send(new P2PMsg_OnSocketCreated( |
+ id_, local_address, remote_address)); |
} |
void P2PSocketHostTcpBase::DoRead() { |