Skip to content
Snippets Groups Projects
Commit 84bf4184 authored by Sébastien Blin's avatar Sébastien Blin
Browse files

connectionmanager: pass turn_cache to config

This allow upper layers to manage the configuration of the cache.

Change-Id: I2c79fb1946f22b23a0de955728811618ab84272c
parent 883c7657
Branches
No related tags found
No related merge requests found
......@@ -18,6 +18,7 @@
#include "ice_options.h"
#include "multiplexed_socket.h"
#include "turn_cache.h"
#include <opendht/dhtrunner.h>
#include <opendht/infohash.h>
......@@ -237,9 +238,7 @@ struct ConnectionManager::Config
std::string turnServerPwd;
std::string turnServerRealm;
mutable std::mutex cachedTurnMutex {};
dht::SockAddr cacheTurnV4 {};
dht::SockAddr cacheTurnV6 {};
std::shared_ptr<TurnCache> turnCache;
std::string cachePath {};
......
......@@ -1408,15 +1408,21 @@ ConnectionManager::Impl::getIceOptions() const noexcept
if (config_->stunEnabled)
opts.stunServers.emplace_back(StunServerInfo().setUri(config_->stunServer));
if (config_->turnEnabled) {
auto cached = false;
std::lock_guard<std::mutex> lk(config_->cachedTurnMutex);
cached = config_->cacheTurnV4 || config_->cacheTurnV6;
if (config_->cacheTurnV4) {
if (config_->turnCache) {
auto turnAddr = config_->turnCache->getResolvedTurn();
if (turnAddr != std::nullopt) {
opts.turnServers.emplace_back(TurnServerInfo()
.setUri(turnAddr->toString())
.setUsername(config_->turnServerUserName)
.setPassword(config_->turnServerPwd)
.setRealm(config_->turnServerRealm));
}
} else {
opts.turnServers.emplace_back(TurnServerInfo()
.setUri(config_->cacheTurnV4.toString())
.setUsername(config_->turnServerUserName)
.setPassword(config_->turnServerPwd)
.setRealm(config_->turnServerRealm));
.setUri(config_->turnServer)
.setUsername(config_->turnServerUserName)
.setPassword(config_->turnServerPwd)
.setRealm(config_->turnServerRealm));
}
// NOTE: first test with ipv6 turn was not concluant and resulted in multiple
// co issues. So this needs some debug. for now just disable
......@@ -1427,14 +1433,6 @@ ConnectionManager::Impl::getIceOptions() const noexcept
// .setPassword(turnServerPwd_)
// .setRealm(turnServerRealm_));
//}
// Nothing cached, so do the resolution
if (!cached) {
opts.turnServers.emplace_back(TurnServerInfo()
.setUri(config_->turnServer)
.setUsername(config_->turnServerUserName)
.setPassword(config_->turnServerPwd)
.setRealm(config_->turnServerRealm));
}
}
return opts;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment