Change the size of the ICE ufrag to 4 bytes.

This is the minumum allowed size, and will allow STUN pings to be smaller.
The unit tests on the the Gturn are also modified. A username with length of 16 bytes will be generated for Gturn only.

Review-Url: https://codereview.webrtc.org/1848083002
Cr-Commit-Position: refs/heads/master@{#12876}
This commit is contained in:
zhihuang
2016-05-24 10:13:32 -07:00
committed by Commit bot
parent 6670483db8
commit 6d0d4bf31d
5 changed files with 12 additions and 10 deletions

View File

@ -21,9 +21,8 @@ const char CN_OTHER[] = "main";
const char GROUP_TYPE_BUNDLE[] = "BUNDLE";
// Minimum ufrag length is 4 characters as per RFC5245. We chose 16 because
// some internal systems expect username to be 16 bytes.
const int ICE_UFRAG_LENGTH = 16;
// Minimum ufrag length is 4 characters as per RFC5245.
const int ICE_UFRAG_LENGTH = 4;
// Minimum password length of 22 characters as per RFC5245. We chose 24 because
// some internal systems expect password to be multiple of 4.
const int ICE_PWD_LENGTH = 24;

View File

@ -90,8 +90,8 @@ static const SocketAddress kTurnUdpExtAddr("99.99.99.5", 0);
static const cricket::RelayCredentials kRelayCredentials("test", "test");
// Based on ICE_UFRAG_LENGTH
static const char* kIceUfrag[4] = {"TESTICEUFRAG0000", "TESTICEUFRAG0001",
"TESTICEUFRAG0002", "TESTICEUFRAG0003"};
static const char* kIceUfrag[4] = {"UF00", "UF01",
"UF02", "UF03"};
// Based on ICE_PWD_LENGTH
static const char* kIcePwd[4] = {"TESTICEPWD00000000000000",
"TESTICEPWD00000000000001",

View File

@ -76,6 +76,8 @@ static const int kTiebreaker2 = 22222;
static const char* data = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
static const int kGturnUserNameLength = 16;
static Candidate GetCandidate(Port* port) {
assert(port->Candidates().size() >= 1);
return port->Candidates()[0];
@ -525,9 +527,10 @@ class PortTest : public testing::Test, public sigslot::has_slots<> {
}
RelayPort* CreateGturnPort(const SocketAddress& addr) {
// TODO(pthatcher): Remove GTURN.
return RelayPort::Create(main_, &socket_factory_, &network_,
addr.ipaddr(), 0, 0,
username_, password_);
// Generate a username with length of 16 for Gturn only.
std::string username = rtc::CreateRandomString(kGturnUserNameLength);
return RelayPort::Create(main_, &socket_factory_, &network_, addr.ipaddr(),
0, 0, username, password_);
// TODO: Add an external address for ext_proto, so that the
// other side can connect to this port using a non-UDP protocol.
}

View File

@ -18,7 +18,7 @@
static const char kSessionId[] = "session id";
static const char kContentName[] = "test content";
// Based on ICE_UFRAG_LENGTH
static const char kIceUfrag[] = "TESTICEUFRAG0000";
static const char kIceUfrag[] = "UF00";
// Based on ICE_PWD_LENGTH
static const char kIcePwd[] = "TESTICEPWD00000000000000";
static const char kTurnUsername[] = "test";

View File

@ -64,7 +64,7 @@ static const int kMinPort = 10000;
static const int kMaxPort = 10099;
// Based on ICE_UFRAG_LENGTH
static const char kIceUfrag0[] = "TESTICEUFRAG0000";
static const char kIceUfrag0[] = "UF00";
// Based on ICE_PWD_LENGTH
static const char kIcePwd0[] = "TESTICEPWD00000000000000";