OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 // Magic value of 30 is from RFC3484, for IPv4 addresses. | 69 // Magic value of 30 is from RFC3484, for IPv4 addresses. |
70 static const uint32_t kDefaultPrflxPriority = | 70 static const uint32_t kDefaultPrflxPriority = |
71 ICE_TYPE_PREFERENCE_PRFLX << 24 | 30 << 8 | | 71 ICE_TYPE_PREFERENCE_PRFLX << 24 | 30 << 8 | |
72 (256 - ICE_CANDIDATE_COMPONENT_DEFAULT); | 72 (256 - ICE_CANDIDATE_COMPONENT_DEFAULT); |
73 | 73 |
74 static const int kTiebreaker1 = 11111; | 74 static const int kTiebreaker1 = 11111; |
75 static const int kTiebreaker2 = 22222; | 75 static const int kTiebreaker2 = 22222; |
76 | 76 |
77 static const char* data = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; | 77 static const char* data = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; |
78 | 78 |
| 79 static const int kGturnUserNameLength = 16; |
| 80 |
79 static Candidate GetCandidate(Port* port) { | 81 static Candidate GetCandidate(Port* port) { |
80 assert(port->Candidates().size() >= 1); | 82 assert(port->Candidates().size() >= 1); |
81 return port->Candidates()[0]; | 83 return port->Candidates()[0]; |
82 } | 84 } |
83 | 85 |
84 static SocketAddress GetAddress(Port* port) { | 86 static SocketAddress GetAddress(Port* port) { |
85 return GetCandidate(port).address(); | 87 return GetCandidate(port).address(); |
86 } | 88 } |
87 | 89 |
88 static IceMessage* CopyStunMessage(const IceMessage* src) { | 90 static IceMessage* CopyStunMessage(const IceMessage* src) { |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 RelayPort* CreateGturnPort(const SocketAddress& addr, | 520 RelayPort* CreateGturnPort(const SocketAddress& addr, |
519 ProtocolType int_proto, ProtocolType ext_proto) { | 521 ProtocolType int_proto, ProtocolType ext_proto) { |
520 RelayPort* port = CreateGturnPort(addr); | 522 RelayPort* port = CreateGturnPort(addr); |
521 SocketAddress addrs[] = | 523 SocketAddress addrs[] = |
522 { kRelayUdpIntAddr, kRelayTcpIntAddr, kRelaySslTcpIntAddr }; | 524 { kRelayUdpIntAddr, kRelayTcpIntAddr, kRelaySslTcpIntAddr }; |
523 port->AddServerAddress(ProtocolAddress(addrs[int_proto], int_proto)); | 525 port->AddServerAddress(ProtocolAddress(addrs[int_proto], int_proto)); |
524 return port; | 526 return port; |
525 } | 527 } |
526 RelayPort* CreateGturnPort(const SocketAddress& addr) { | 528 RelayPort* CreateGturnPort(const SocketAddress& addr) { |
527 // TODO(pthatcher): Remove GTURN. | 529 // TODO(pthatcher): Remove GTURN. |
528 return RelayPort::Create(main_, &socket_factory_, &network_, | 530 // Generate a username with length of 16 for Gturn only. |
529 addr.ipaddr(), 0, 0, | 531 std::string username = rtc::CreateRandomString(kGturnUserNameLength); |
530 username_, password_); | 532 return RelayPort::Create(main_, &socket_factory_, &network_, addr.ipaddr(), |
| 533 0, 0, username, password_); |
531 // TODO: Add an external address for ext_proto, so that the | 534 // TODO: Add an external address for ext_proto, so that the |
532 // other side can connect to this port using a non-UDP protocol. | 535 // other side can connect to this port using a non-UDP protocol. |
533 } | 536 } |
534 rtc::NATServer* CreateNatServer(const SocketAddress& addr, | 537 rtc::NATServer* CreateNatServer(const SocketAddress& addr, |
535 rtc::NATType type) { | 538 rtc::NATType type) { |
536 return new rtc::NATServer(type, ss_.get(), addr, addr, ss_.get(), addr); | 539 return new rtc::NATServer(type, ss_.get(), addr, addr, ss_.get(), addr); |
537 } | 540 } |
538 static const char* StunName(NATType type) { | 541 static const char* StunName(NATType type) { |
539 switch (type) { | 542 switch (type) { |
540 case NAT_OPEN_CONE: return "stun(open cone)"; | 543 case NAT_OPEN_CONE: return "stun(open cone)"; |
(...skipping 2114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2655 EXPECT_EQ(1UL, port->Candidates().size()); | 2658 EXPECT_EQ(1UL, port->Candidates().size()); |
2656 port->SetIceParameters(1, "ufrag2", "password2"); | 2659 port->SetIceParameters(1, "ufrag2", "password2"); |
2657 EXPECT_EQ(1, port->component()); | 2660 EXPECT_EQ(1, port->component()); |
2658 EXPECT_EQ("ufrag2", port->username_fragment()); | 2661 EXPECT_EQ("ufrag2", port->username_fragment()); |
2659 EXPECT_EQ("password2", port->password()); | 2662 EXPECT_EQ("password2", port->password()); |
2660 const Candidate& candidate = port->Candidates()[0]; | 2663 const Candidate& candidate = port->Candidates()[0]; |
2661 EXPECT_EQ(1, candidate.component()); | 2664 EXPECT_EQ(1, candidate.component()); |
2662 EXPECT_EQ("ufrag2", candidate.username()); | 2665 EXPECT_EQ("ufrag2", candidate.username()); |
2663 EXPECT_EQ("password2", candidate.password()); | 2666 EXPECT_EQ("password2", candidate.password()); |
2664 } | 2667 } |
OLD | NEW |