diff --git a/git-teaspeak b/git-teaspeak index 8fca354..1a18e58 160000 --- a/git-teaspeak +++ b/git-teaspeak @@ -1 +1 @@ -Subproject commit 8fca354e65c2fd37414d1527e60800ed4669ea07 +Subproject commit 1a18e5809c467954c9d46783269387e492312851 diff --git a/server/src/Configuration.cpp b/server/src/Configuration.cpp index e892608..332089e 100644 --- a/server/src/Configuration.cpp +++ b/server/src/Configuration.cpp @@ -123,7 +123,9 @@ bool config::web::activated; std::deque<std::tuple<std::string, std::string, std::string>> config::web::ssl::certificates; uint16_t config::web::webrtc_port_max; uint16_t config::web::webrtc_port_min; -deque<string> config::web::ice_servers; +bool config::web::stun_enabled; +std::string config::web::stun_host; +uint16_t config::web::stun_port; bool config::web::enable_upnp; size_t config::log::vs_size; @@ -495,26 +497,6 @@ vector<string> config::parseConfig(const std::string& path) { auto bindings = create_bindings(); read_bindings(config, bindings); build_comments(comments, bindings); - - for(const auto& entry : config::web::ice_servers) { - auto dp = entry.find(':'); - if(dp == string::npos) { - errors.emplace_back("Invalid ice server entry! Missing port"); - continue; - } - auto host = entry.substr(0, dp); - auto port = entry.substr(dp + 1); - if(port.find_last_not_of("0123456789") != string::npos) { - errors.push_back("Invalid ice server entry! Invalid port (" + port + ")"); - continue; - } - - try { - stoi(port); - } catch(std::exception& ex) { - errors.push_back("Invalid ice server entry! Invalid port (" + port + ")"); - } - } } auto currentVersion = config::server::default_version(); @@ -1490,9 +1472,22 @@ std::deque<std::shared_ptr<EntryBinding>> config::create_bindings() { ADD_NOTE("These ports must opened to use the voice bridge (Protocol: UDP)"); } { - CREATE_BINDING("webrtc.ice", 0); - BIND_VECTOR(config::web::ice_servers, {"stun.l.google.com:19302"}); - ADD_DESCRIPTION("A list of possible offered ice servers"); + CREATE_BINDING("webrtc.stun.enabled", 0); + BIND_INTEGRAL(config::web::stun_enabled, false, false, true); + ADD_DESCRIPTION("Whatever to use a STUN server"); + ADD_NOTE_RELOADABLE(); + } + { + CREATE_BINDING("webrtc.stun.host", 0); + BIND_STRING(config::web::stun_host, "stun.l.google.com"); + ADD_DESCRIPTION("Stun hostname"); + ADD_NOTE_RELOADABLE(); + } + { + CREATE_BINDING("webrtc.stun.port", 0); + BIND_INTEGRAL(config::web::stun_port, 19302, 1, 65565); + ADD_DESCRIPTION("Port of the stun server"); + ADD_NOTE_RELOADABLE(); } } { diff --git a/server/src/Configuration.h b/server/src/Configuration.h index b117541..eeb6fc2 100644 --- a/server/src/Configuration.h +++ b/server/src/Configuration.h @@ -208,8 +208,12 @@ namespace ts::config { extern uint16_t webrtc_port_min; extern uint16_t webrtc_port_max; - extern std::deque<std::string> ice_servers; + extern bool enable_upnp; + + extern bool stun_enabled; + extern std::string stun_host; + extern uint16_t stun_port; } namespace threads { diff --git a/server/src/client/web/VoiceBridge.cpp b/server/src/client/web/VoiceBridge.cpp index 04297ab..3882e0e 100644 --- a/server/src/client/web/VoiceBridge.cpp +++ b/server/src/client/web/VoiceBridge.cpp @@ -69,20 +69,8 @@ VoiceBridge::VoiceBridge(const shared_ptr<WebClient>& owner) : _owner(owner) { config->nice_config = make_shared<rtc::NiceWrapper::Config>(); config->nice_config->ice_port_range = {config::web::webrtc_port_min, config::web::webrtc_port_max}; - for(const auto& entry : config::web::ice_servers) { - auto dp = entry.find(':'); - if(dp == string::npos) continue; - auto host = entry.substr(0, dp); - auto port = entry.substr(dp + 1); - if(port.find_last_not_of("0123456789") != string::npos) continue; - - if(host == "stun.l.google.com" && port == "9302") - port = "19302"; /* fix for the invalid config value until 1.3.14beta1 :) */ - - try { - config->nice_config->stun_server = {host,(uint16_t) stoi(port)}; - } catch(std::exception& ex) {} - } + if(config::web::stun_enabled) + config->nice_config->stun_server = { config::web::stun_host, config::web::stun_port }; config->nice_config->allow_ice_udp = true; config->nice_config->allow_ice_tcp = false;