Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(405)

Unified Diff: webrtc/p2p/base/tcpport.cc

Issue 1914803002: Allow the localhost IP address even if it does not match the tcp port address (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Merge with head Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/base/virtualsocketserver.cc ('k') | webrtc/p2p/base/tcpport_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/p2p/base/tcpport.cc
diff --git a/webrtc/p2p/base/tcpport.cc b/webrtc/p2p/base/tcpport.cc
index 59c4f317d4bc755bba05246e1207b55b372571d1..5ccb8108a058b0ab608c7c8b454f10b2882016d9 100644
--- a/webrtc/p2p/base/tcpport.cc
+++ b/webrtc/p2p/base/tcpport.cc
@@ -387,28 +387,35 @@ void TCPConnection::OnConnect(rtc::AsyncPacketSocket* socket) {
// the one we asked for. This is seen in Chrome, where TCP sockets cannot be
// given a binding address, and the platform is expected to pick the
// correct local address.
- const rtc::IPAddress& socket_ip = socket->GetLocalAddress().ipaddr();
- if (socket_ip == port()->ip() || IPIsAny(port()->ip())) {
- if (socket_ip == port()->ip()) {
- LOG_J(LS_VERBOSE, this) << "Connection established to "
- << socket->GetRemoteAddress().ToSensitiveString();
- } else {
- LOG(LS_WARNING) << "Socket is bound to a different address:"
- << socket->GetLocalAddress().ipaddr().ToString()
- << ", rather then the local port:"
- << port()->ip().ToString()
- << ". Still allowing it since it's any address"
- << ", possibly caused by multi-routes being disabled.";
- }
- set_connected(true);
- connection_pending_ = false;
+ const rtc::SocketAddress& socket_addr = socket->GetLocalAddress();
+ if (socket_addr.ipaddr() == port()->ip()) {
+ LOG_J(LS_VERBOSE, this) << "Connection established to "
+ << socket->GetRemoteAddress().ToSensitiveString();
+ } else if (IPIsAny(port()->ip())) {
+ LOG(LS_WARNING) << "Socket is bound to a different address:"
+ << socket_addr.ipaddr().ToString()
+ << ", rather then the local port:"
+ << port()->ip().ToString()
+ << ". Still allowing it since it's any address"
+ << ", possibly caused by multi-routes being disabled.";
+ } else if (socket_addr.IsLoopbackIP()) {
+ LOG(LS_WARNING) << "Socket is bound to a different address:"
+ << socket_addr.ipaddr().ToString()
+ << ", rather then the local port:"
+ << port()->ip().ToString()
+ << ". Still allowing it since it's localhost.";
} else {
LOG_J(LS_WARNING, this) << "Dropping connection as TCP socket bound to IP "
- << socket_ip.ToSensitiveString()
+ << socket_addr.ipaddr().ToSensitiveString()
<< ", different from the local candidate IP "
<< port()->ip().ToSensitiveString();
OnClose(socket, 0);
+ return;
}
+
+ // Connection is established successfully.
+ set_connected(true);
+ connection_pending_ = false;
}
void TCPConnection::OnClose(rtc::AsyncPacketSocket* socket, int error) {
« no previous file with comments | « webrtc/base/virtualsocketserver.cc ('k') | webrtc/p2p/base/tcpport_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698