OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "remoting/protocol/jingle_session.h" | 5 #include "remoting/protocol/jingle_session.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
10 #include "base/rand_util.h" | 10 #include "base/rand_util.h" |
11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
12 #include "crypto/hmac.h" | 12 #include "crypto/hmac.h" |
13 #include "crypto/rsa_private_key.h" | 13 #include "crypto/rsa_private_key.h" |
14 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
15 #include "net/socket/stream_socket.h" | 15 #include "net/socket/stream_socket.h" |
16 #include "remoting/base/constants.h" | 16 #include "remoting/base/constants.h" |
17 #include "remoting/protocol/jingle_datagram_connector.h" | 17 #include "remoting/protocol/jingle_datagram_connector.h" |
18 #include "remoting/protocol/jingle_session_manager.h" | 18 #include "remoting/protocol/jingle_session_manager.h" |
19 #include "remoting/protocol/jingle_stream_connector.h" | 19 #include "remoting/protocol/jingle_stream_connector.h" |
| 20 #include "remoting/protocol/v1_client_channel_authenticator.h" |
| 21 #include "remoting/protocol/v1_host_channel_authenticator.h" |
20 #include "third_party/libjingle/source/talk/base/thread.h" | 22 #include "third_party/libjingle/source/talk/base/thread.h" |
21 #include "third_party/libjingle/source/talk/p2p/base/p2ptransportchannel.h" | 23 #include "third_party/libjingle/source/talk/p2p/base/p2ptransportchannel.h" |
22 #include "third_party/libjingle/source/talk/p2p/base/session.h" | 24 #include "third_party/libjingle/source/talk/p2p/base/session.h" |
23 #include "third_party/libjingle/source/talk/p2p/base/transport.h" | 25 #include "third_party/libjingle/source/talk/p2p/base/transport.h" |
24 | 26 |
25 using cricket::BaseSession; | 27 using cricket::BaseSession; |
26 | 28 |
27 namespace remoting { | 29 namespace remoting { |
28 namespace protocol { | 30 namespace protocol { |
29 | 31 |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 cricket_session_->CreateChannel(content_name, name); | 408 cricket_session_->CreateChannel(content_name, name); |
407 | 409 |
408 if (!jingle_session_manager_->allow_nat_traversal_ && | 410 if (!jingle_session_manager_->allow_nat_traversal_ && |
409 !cricket_session_->initiator()) { | 411 !cricket_session_->initiator()) { |
410 // Don't make outgoing connections from the host to client when | 412 // Don't make outgoing connections from the host to client when |
411 // NAT traversal is disabled. | 413 // NAT traversal is disabled. |
412 raw_channel->GetP2PChannel()->set_incoming_only(true); | 414 raw_channel->GetP2PChannel()->set_incoming_only(true); |
413 } | 415 } |
414 | 416 |
415 channel_connectors_[name] = connector; | 417 channel_connectors_[name] = connector; |
416 connector->Connect(cricket_session_->initiator(), local_cert_, | 418 ChannelAuthenticator* authenticator; |
417 remote_cert_, local_private_key_.get(), raw_channel); | 419 if (cricket_session_->initiator()) { |
| 420 authenticator = new V1ClientChannelAuthenticator( |
| 421 remote_cert_, shared_secret_); |
| 422 } else { |
| 423 authenticator = new V1HostChannelAuthenticator( |
| 424 local_cert_, local_private_key_.get(), shared_secret_); |
| 425 } |
| 426 connector->Connect(authenticator, raw_channel); |
418 | 427 |
419 // Workaround bug in libjingle - it doesn't connect channels if they | 428 // Workaround bug in libjingle - it doesn't connect channels if they |
420 // are created after the session is accepted. See crbug.com/89384. | 429 // are created after the session is accepted. See crbug.com/89384. |
421 // TODO(sergeyu): Fix the bug and remove this line. | 430 // TODO(sergeyu): Fix the bug and remove this line. |
422 cricket_session_->GetTransport(content_name)->ConnectChannels(); | 431 cricket_session_->GetTransport(content_name)->ConnectChannels(); |
423 } | 432 } |
424 | 433 |
425 void JingleSession::OnChannelConnectorFinished( | 434 void JingleSession::OnChannelConnectorFinished( |
426 const std::string& name, JingleChannelConnector* connector) { | 435 const std::string& name, JingleChannelConnector* connector) { |
427 DCHECK(CalledOnValidThread()); | 436 DCHECK(CalledOnValidThread()); |
(...skipping 24 matching lines...) Expand all Loading... |
452 DCHECK_NE(state_, FAILED); | 461 DCHECK_NE(state_, FAILED); |
453 | 462 |
454 state_ = new_state; | 463 state_ = new_state; |
455 if (!state_change_callback_.is_null()) | 464 if (!state_change_callback_.is_null()) |
456 state_change_callback_.Run(new_state); | 465 state_change_callback_.Run(new_state); |
457 } | 466 } |
458 } | 467 } |
459 | 468 |
460 } // namespace protocol | 469 } // namespace protocol |
461 } // namespace remoting | 470 } // namespace remoting |
OLD | NEW |