diff --git a/src/account.cpp b/src/account.cpp index 51c1f284086c98d8fc2e6c0d898bcf03b0700306..fe9e475c46711d64b236ffa56d8699f4d6667350 100644 --- a/src/account.cpp +++ b/src/account.cpp @@ -85,9 +85,6 @@ const char * const Account::USER_AGENT_KEY = "useragent"; const char * const Account::HAS_CUSTOM_USER_AGENT_KEY = "hasCustomUserAgent"; const char * const Account::PRESENCE_MODULE_ENABLED_KEY = "presenceModuleEnabled"; const char * const Account::UPNP_ENABLED_KEY = "upnpEnabled"; -const char * const Account::PROXY_ENABLED_KEY = "proxyEnabled"; -const char * const Account::PROXY_SERVER_KEY = "proxyServer"; -const char * const Account::PROXY_PUSH_TOKEN_KEY = "proxyPushToken"; Account::Account(const std::string &accountID) : accountID_(accountID) @@ -104,9 +101,6 @@ Account::Account(const std::string &accountID) , displayName_("") , userAgent_(DEFAULT_USER_AGENT) , hasCustomUserAgent_(false) - , proxyEnabled_(false) - , proxyServer_("") - , deviceKey_("") , mailBox_() { random_device rdev; @@ -234,9 +228,6 @@ Account::serialize(YAML::Emitter& out) out << YAML::Key << DISPLAY_NAME_KEY << YAML::Value << displayName_; out << YAML::Key << HOSTNAME_KEY << YAML::Value << hostname_; out << YAML::Key << UPNP_ENABLED_KEY << YAML::Value << bool(upnp_); - out << YAML::Key << PROXY_ENABLED_KEY << YAML::Value << proxyEnabled_; - out << YAML::Key << PROXY_SERVER_KEY << YAML::Value << proxyServer_; - out << YAML::Key << PROXY_PUSH_TOKEN_KEY << YAML::Value << deviceKey_; } void @@ -267,10 +258,6 @@ Account::unserialize(const YAML::Node& node) bool enabled; parseValue(node, UPNP_ENABLED_KEY, enabled); enableUpnp(enabled); - - parseValue(node, PROXY_ENABLED_KEY, proxyEnabled_); - parseValue(node, PROXY_SERVER_KEY, proxyServer_); - parseValue(node, PROXY_PUSH_TOKEN_KEY, deviceKey_); } void @@ -295,9 +282,6 @@ Account::setAccountDetails(const std::map<std::string, std::string> &details) bool enabled; parseBool(details, Conf::CONFIG_UPNP_ENABLED, enabled); enableUpnp(enabled); - parseBool(details, DRing::Account::ConfProperties::PROXY_ENABLED, proxyEnabled_); - parseString(details, DRing::Account::ConfProperties::PROXY_SERVER, proxyServer_); - parseString(details, DRing::Account::ConfProperties::PROXY_PUSH_TOKEN, deviceKey_); } std::map<std::string, std::string> @@ -317,10 +301,7 @@ Account::getAccountDetails() const {DRing::Account::ConfProperties::ACTIVE_CALL_LIMIT, ring::to_string(activeCallLimit_)}, {Conf::CONFIG_RINGTONE_ENABLED, ringtoneEnabled_ ? TRUE_STR : FALSE_STR}, {Conf::CONFIG_RINGTONE_PATH, ringtonePath_}, - {Conf::CONFIG_UPNP_ENABLED, upnp_ ? TRUE_STR : FALSE_STR}, - {DRing::Account::ConfProperties::PROXY_ENABLED, proxyEnabled_ ? TRUE_STR : FALSE_STR}, - {DRing::Account::ConfProperties::PROXY_SERVER, proxyServer_}, - {DRing::Account::ConfProperties::PROXY_PUSH_TOKEN, deviceKey_}, + {Conf::CONFIG_UPNP_ENABLED, upnp_ ? TRUE_STR : FALSE_STR} }; } diff --git a/src/account.h b/src/account.h index dac434907a5abf671b6eae62366335c29fed7335..c71d8e55da945f885109ffc22eaf14b4269e258e 100644 --- a/src/account.h +++ b/src/account.h @@ -472,13 +472,6 @@ class Account : public Serializable, public std::enable_shared_from_this<Account std::unique_ptr<ring::upnp::Controller> upnp_; mutable std::mutex upnp_mtx {}; - /** - * Proxy - */ - bool proxyEnabled_; - std::string proxyServer_; - std::string deviceKey_; - /** * private account codec searching functions */ diff --git a/src/ringdht/configkeys.h b/src/ringdht/configkeys.h index 373557f3a5ea2f754a8adbbef398ee188f436958..ca4e092551d9d0d28c3a9ccd56aaf1ad06df821d 100644 --- a/src/ringdht/configkeys.h +++ b/src/ringdht/configkeys.h @@ -38,6 +38,10 @@ constexpr const char* const RING_ACCOUNT_RECEIPT = "ringAccountReceipt"; constexpr const char* const RING_ACCOUNT_RECEIPT_SIG = "ringAccountReceiptSignature"; constexpr const char* const RING_ACCOUNT_CRL = "ringAccountCRL"; constexpr const char* const RING_ACCOUNT_CONTACTS = "ringAccountContacts"; +constexpr const char* const PROXY_ENABLED_KEY = "proxyEnabled"; +constexpr const char* const PROXY_SERVER_KEY = "proxyServer"; +constexpr const char* const PROXY_PUSH_TOKEN_KEY = "proxyPushToken"; + } } diff --git a/src/ringdht/ringaccount.cpp b/src/ringdht/ringaccount.cpp index 573659388fb4860c12b25210c8bc939211112ee3..b755794743e54b456dc9fc639dc9376c7b30daa8 100644 --- a/src/ringdht/ringaccount.cpp +++ b/src/ringdht/ringaccount.cpp @@ -279,6 +279,9 @@ RingAccount::RingAccount(const std::string& accountID, bool /* presenceEnabled * , cachePath_(fileutils::get_cache_dir()+DIR_SEPARATOR_STR+getAccountID()) , dataPath_(cachePath_ + DIR_SEPARATOR_STR "values") , dhtPeerConnector_ {new DhtPeerConnector {*this}} + , proxyEnabled_(false) + , proxyServer_("") + , deviceKey_("") { // Force the SFL turn server if none provided yet turnServer_ = DEFAULT_TURN_SERVER; @@ -628,6 +631,10 @@ void RingAccount::serialize(YAML::Emitter &out) out << YAML::Key << Conf::DHT_ALLOW_PEERS_FROM_CONTACT << YAML::Value << allowPeersFromContact_; out << YAML::Key << Conf::DHT_ALLOW_PEERS_FROM_TRUSTED << YAML::Value << allowPeersFromTrusted_; + out << YAML::Key << Conf::PROXY_ENABLED_KEY << YAML::Value << proxyEnabled_; + out << YAML::Key << Conf::PROXY_SERVER_KEY << YAML::Value << proxyServer_; + out << YAML::Key << Conf::PROXY_PUSH_TOKEN_KEY << YAML::Value << deviceKey_; + #if HAVE_RINGNS out << YAML::Key << DRing::Account::ConfProperties::RingNS::URI << YAML::Value << nameServer_; #endif @@ -665,6 +672,11 @@ void RingAccount::unserialize(const YAML::Node &node) parseValue(node, Conf::DHT_ALLOW_PEERS_FROM_HISTORY, allowPeersFromHistory_); parseValue(node, Conf::DHT_ALLOW_PEERS_FROM_CONTACT, allowPeersFromContact_); parseValue(node, Conf::DHT_ALLOW_PEERS_FROM_TRUSTED, allowPeersFromTrusted_); + + parseValue(node, Conf::PROXY_ENABLED_KEY, proxyEnabled_); + parseValue(node, Conf::PROXY_SERVER_KEY, proxyServer_); + parseValue(node, Conf::PROXY_PUSH_TOKEN_KEY, deviceKey_); + try { parseValue(node, DRing::Account::ConfProperties::RING_DEVICE_NAME, ringDeviceName_); } catch (const std::exception& e) { @@ -1481,6 +1493,12 @@ RingAccount::setAccountDetails(const std::map<std::string, std::string>& details parsePath(details, DRing::Account::ConfProperties::ARCHIVE_PATH, archive_path, idPath_); parseString(details, DRing::Account::ConfProperties::RING_DEVICE_NAME, ringDeviceName_); + parseBool(details, DRing::Account::ConfProperties::PROXY_ENABLED, proxyEnabled_); + parseString(details, DRing::Account::ConfProperties::PROXY_SERVER, proxyServer_); + parseString(details, DRing::Account::ConfProperties::PROXY_PUSH_TOKEN, deviceKey_); + if (proxyServer_.empty()) + proxyServer_ = DHT_DEFAULT_PROXY; + #if HAVE_RINGNS parseString(details, DRing::Account::ConfProperties::RingNS::URI, nameServer_); nameDir_ = NameDirectory::instance(nameServer_); @@ -1531,6 +1549,9 @@ RingAccount::getAccountDetails() const a.emplace(DRing::Account::ConfProperties::ALLOW_CERT_FROM_TRUSTED, allowPeersFromTrusted_?TRUE_STR:FALSE_STR); /* GNUTLS_DEFAULT_HANDSHAKE_TIMEOUT is defined as -1 */ a.emplace(Conf::CONFIG_TLS_NEGOTIATION_TIMEOUT_SEC, "-1"); + a.emplace(DRing::Account::ConfProperties::PROXY_ENABLED, proxyEnabled_ ? TRUE_STR : FALSE_STR); + a.emplace(DRing::Account::ConfProperties::PROXY_SERVER, proxyServer_); + a.emplace(DRing::Account::ConfProperties::PROXY_PUSH_TOKEN, deviceKey_); //a.emplace(DRing::Account::ConfProperties::ETH::KEY_FILE, ethPath_); a.emplace(DRing::Account::ConfProperties::RingNS::ACCOUNT, ethAccount_); diff --git a/src/ringdht/ringaccount.h b/src/ringdht/ringaccount.h index d5c80a77fa6f9504ba2402c95e30871900913711..c1cb49a66a996fb32486f16735c2c15d4a7e9705 100644 --- a/src/ringdht/ringaccount.h +++ b/src/ringdht/ringaccount.h @@ -84,6 +84,7 @@ class RingAccount : public SIPAccountBase { constexpr static const char* const ACCOUNT_TYPE = "RING"; constexpr static const in_port_t DHT_DEFAULT_PORT = 4222; constexpr static const char* const DHT_DEFAULT_BOOTSTRAP = "bootstrap.ring.cx"; + constexpr static const char* const DHT_DEFAULT_PROXY = "dhtproxy.ring.cx"; constexpr static const char* const DHT_TYPE_NS = "cx.ring"; /* constexpr */ static const std::pair<uint16_t, uint16_t> DHT_PORT_RANGE; @@ -597,6 +598,13 @@ class RingAccount : public SIPAccountBase { */ UsedPort dhtPortUsed_ {}; + /** + * Proxy + */ + bool proxyEnabled_; + std::string proxyServer_; + std::string deviceKey_; + /** * The TLS settings, used only if tls is chosen as a sip transport. */