From 299abb884cde97246c47453310cbbff32599ac3a Mon Sep 17 00:00:00 2001
From: Guillaume Roguez <guillaume.roguez@savoirfairelinux.com>
Date: Thu, 25 Aug 2016 21:14:40 -0400
Subject: [PATCH] ring: use turn.ring.cx as default TURN server

Give a default TURN server at Ring account creation.
This server is a proposed by Savoir-faire Linux.

Reviewed-by: Alexandre Viau <alexandre.viau@savoirfairelinux.com>
Change-Id: I076849fa54ade84744983e445d3513aac407afd9
---
 src/ringdht/ringaccount.cpp | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/ringdht/ringaccount.cpp b/src/ringdht/ringaccount.cpp
index 4dd5c8dad8..7236220259 100644
--- a/src/ringdht/ringaccount.cpp
+++ b/src/ringdht/ringaccount.cpp
@@ -86,6 +86,10 @@ static constexpr auto TLS_TIMEOUT = std::chrono::seconds(30);
 const constexpr auto EXPORT_KEY_RENEWAL_TIME = std::chrono::minutes(20);
 
 static constexpr const char * const RING_URI_PREFIX = "ring:";
+static constexpr const char * DEFAULT_TURN_SERVER = "turn.ring.cx";
+static constexpr const char * DEFAULT_TURN_USERNAME = "ring";
+static constexpr const char * DEFAULT_TURN_PWD = "ring";
+static constexpr const char * DEFAULT_TURN_REALM = "ring";
 
 constexpr const char* const RingAccount::ACCOUNT_TYPE;
 /* constexpr */ const std::pair<uint16_t, uint16_t> RingAccount::DHT_PORT_RANGE {4000, 8888};
@@ -161,7 +165,14 @@ RingAccount::RingAccount(const std::string& accountID, bool /* presenceEnabled *
     cachePath_(fileutils::get_cache_dir()+DIR_SEPARATOR_STR+getAccountID()),
     dataPath_(cachePath_ + DIR_SEPARATOR_STR "values"),
     idPath_(fileutils::get_data_dir()+DIR_SEPARATOR_STR+getAccountID())
-{}
+{
+    // Force the SFL turn server if none provided yet
+    turnServer_ = DEFAULT_TURN_SERVER;
+    turnServerUserName_ = DEFAULT_TURN_USERNAME;
+    turnServerPwd_ = DEFAULT_TURN_PWD;
+    turnServerRealm_ = DEFAULT_TURN_REALM;
+    turnEnabled_ = true;
+}
 
 RingAccount::~RingAccount()
 {
-- 
GitLab