Skip to content

Commit

Permalink
Allow overriding ICE ufrag and pwd fields
Browse files Browse the repository at this point in the history
Adds two new optional config keys - `iceUfrag` and `icePwd` which
are passed to libjuice.

Refs: paullouisageneau#1166
  • Loading branch information
achingbrain committed Jun 5, 2024
1 parent 541d646 commit ca2a98c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 4 additions & 0 deletions include/rtc/configuration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ struct RTC_CPP_EXPORT Configuration {
optional<string> certificatePemFile;
optional<string> keyPemFile;
optional<string> keyPemPass;

// Overriding ICE ufrag/pwd
optional<string> iceUfrag;
optional<string> icePwd;
};

#ifdef RTC_ENABLE_WEBSOCKET
Expand Down
10 changes: 8 additions & 2 deletions src/impl/icetransport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,16 @@ IceTransport::IceTransport(const Configuration &config, candidate_callback candi
}

// Create agent
mAgent = decltype(mAgent)(juice_create(&jconfig), juice_destroy);
if (!mAgent)
auto agent = juice_create(&jconfig);
if (!agent)
throw std::runtime_error("Failed to create the ICE agent");

if (config.iceUfrag && config.icePwd) {
juice_set_local_ice_attributes(agent, (char*)config.iceUfrag->c_str(), (char*)config.icePwd->c_str());
}

mAgent = decltype(mAgent)(agent, juice_destroy);

// Add TURN servers
for (const auto &server : servers)
if (!server.hostname.empty() && server.type != IceServer::Type::Stun)
Expand Down

0 comments on commit ca2a98c

Please sign in to comment.