Skip to content

Commit ca2a98c

Browse files
committed
Allow overriding ICE ufrag and pwd fields
Adds two new optional config keys - `iceUfrag` and `icePwd` which are passed to libjuice. Refs: paullouisageneau#1166
1 parent 541d646 commit ca2a98c

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

include/rtc/configuration.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ struct RTC_CPP_EXPORT Configuration {
9393
optional<string> certificatePemFile;
9494
optional<string> keyPemFile;
9595
optional<string> keyPemPass;
96+
97+
// Overriding ICE ufrag/pwd
98+
optional<string> iceUfrag;
99+
optional<string> icePwd;
96100
};
97101

98102
#ifdef RTC_ENABLE_WEBSOCKET

src/impl/icetransport.cpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,16 @@ IceTransport::IceTransport(const Configuration &config, candidate_callback candi
130130
}
131131

132132
// Create agent
133-
mAgent = decltype(mAgent)(juice_create(&jconfig), juice_destroy);
134-
if (!mAgent)
133+
auto agent = juice_create(&jconfig);
134+
if (!agent)
135135
throw std::runtime_error("Failed to create the ICE agent");
136136

137+
if (config.iceUfrag && config.icePwd) {
138+
juice_set_local_ice_attributes(agent, (char*)config.iceUfrag->c_str(), (char*)config.icePwd->c_str());
139+
}
140+
141+
mAgent = decltype(mAgent)(agent, juice_destroy);
142+
137143
// Add TURN servers
138144
for (const auto &server : servers)
139145
if (!server.hostname.empty() && server.type != IceServer::Type::Stun)

0 commit comments

Comments
 (0)