Commit 5ae29872 authored by Emmanuel Lepage Vallee's avatar Emmanuel Lepage Vallee Committed by Guillaume Roguez

account: Add 2 client settings to setup the allowed certificates

Also replace a '== ""' by an '.empty()'
Also add a setting to limit the number of calls (per account)

Refs #76374

Change-Id: I14c28957ed95a804bf73f29312d6721d257c930f
parent 8700cae2
......@@ -66,30 +66,31 @@
namespace ring {
const char * const Account::ALL_CODECS_KEY = "allCodecs";
const char * const Account::VIDEO_CODEC_ENABLED = "enabled";
const char * const Account::VIDEO_CODEC_NAME = "name";
const char * const Account::VIDEO_CODEC_PARAMETERS = "parameters";
const char * const Account::VIDEO_CODEC_BITRATE = "bitrate";
const char * const Account::RINGTONE_PATH_KEY = "ringtonePath";
const char * const Account::RINGTONE_ENABLED_KEY = "ringtoneEnabled";
const char * const Account::VIDEO_ENABLED_KEY = "videoEnabled";
const char * const Account::DISPLAY_NAME_KEY = "displayName";
const char * const Account::ALIAS_KEY = "alias";
const char * const Account::TYPE_KEY = "type";
const char * const Account::ID_KEY = "id";
const char * const Account::USERNAME_KEY = "username";
const char * const Account::AUTHENTICATION_USERNAME_KEY = "authenticationUsername";
const char * const Account::PASSWORD_KEY = "password";
const char * const Account::HOSTNAME_KEY = "hostname";
const char * const Account::ACCOUNT_ENABLE_KEY = "enable";
const char * const Account::ACCOUNT_AUTOANSWER_KEY = "autoAnswer";
const char * const Account::MAILBOX_KEY = "mailbox";
const char * const Account::DEFAULT_USER_AGENT = PACKAGE_NAME "/" PACKAGE_VERSION;
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::ALL_CODECS_KEY = "allCodecs";
const char * const Account::VIDEO_CODEC_ENABLED = "enabled";
const char * const Account::VIDEO_CODEC_NAME = "name";
const char * const Account::VIDEO_CODEC_PARAMETERS = "parameters";
const char * const Account::VIDEO_CODEC_BITRATE = "bitrate";
const char * const Account::RINGTONE_PATH_KEY = "ringtonePath";
const char * const Account::RINGTONE_ENABLED_KEY = "ringtoneEnabled";
const char * const Account::VIDEO_ENABLED_KEY = "videoEnabled";
const char * const Account::DISPLAY_NAME_KEY = "displayName";
const char * const Account::ALIAS_KEY = "alias";
const char * const Account::TYPE_KEY = "type";
const char * const Account::ID_KEY = "id";
const char * const Account::USERNAME_KEY = "username";
const char * const Account::AUTHENTICATION_USERNAME_KEY = "authenticationUsername";
const char * const Account::PASSWORD_KEY = "password";
const char * const Account::HOSTNAME_KEY = "hostname";
const char * const Account::ACCOUNT_ENABLE_KEY = "enable";
const char * const Account::ACCOUNT_AUTOANSWER_KEY = "autoAnswer";
const char * const Account::ACCOUNT_ACTIVE_CALL_LIMIT_KEY = "activeCallLimit";
const char * const Account::MAILBOX_KEY = "mailbox";
const char * const Account::DEFAULT_USER_AGENT = PACKAGE_NAME "/" PACKAGE_VERSION;
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";
Account::Account(const std::string &accountID)
: accountID_(accountID)
......@@ -210,6 +211,7 @@ Account::serialize(YAML::Emitter &out)
out << YAML::Key << ALL_CODECS_KEY << YAML::Value << allCodecStr_;
out << YAML::Key << MAILBOX_KEY << YAML::Value << mailBox_;
out << YAML::Key << ACCOUNT_AUTOANSWER_KEY << YAML::Value << autoAnswerEnabled_;
out << YAML::Key << ACCOUNT_ACTIVE_CALL_LIMIT_KEY << YAML::Value << activeCallLimit_;
out << YAML::Key << RINGTONE_ENABLED_KEY << YAML::Value << ringtoneEnabled_;
out << YAML::Key << RINGTONE_PATH_KEY << YAML::Value << ringtonePath_;
out << YAML::Key << HAS_CUSTOM_USER_AGENT_KEY << YAML::Value << hasCustomUserAgent_;
......@@ -229,6 +231,7 @@ Account::unserialize(const YAML::Node &node)
parseValue(node, ACCOUNT_ENABLE_KEY, enabled_);
parseValue(node, USERNAME_KEY, username_);
parseValue(node, ACCOUNT_AUTOANSWER_KEY, autoAnswerEnabled_);
parseValue(node, ACCOUNT_ACTIVE_CALL_LIMIT_KEY, activeCallLimit_);
//parseValue(node, PASSWORD_KEY, password_);
parseValue(node, MAILBOX_KEY, mailBox_);
......@@ -261,6 +264,7 @@ Account::setAccountDetails(const std::map<std::string, std::string> &details)
parseString(details, Conf::CONFIG_ACCOUNT_MAILBOX, mailBox_);
parseString(details, Conf::CONFIG_ACCOUNT_USERAGENT, userAgent_);
parseBool(details, Conf::CONFIG_ACCOUNT_AUTOANSWER, autoAnswerEnabled_);
parseInt(details, DRing::Account::ConfProperties::ACTIVE_CALL_LIMIT, activeCallLimit_);
parseBool(details, Conf::CONFIG_RINGTONE_ENABLED, ringtoneEnabled_);
parseString(details, Conf::CONFIG_RINGTONE_PATH, ringtonePath_);
parseBool(details, Conf::CONFIG_ACCOUNT_HAS_CUSTOM_USERAGENT, hasCustomUserAgent_);
......@@ -287,6 +291,7 @@ Account::getAccountDetails() const
{Conf::CONFIG_ACCOUNT_USERAGENT, hasCustomUserAgent_ ? userAgent_ : DEFAULT_USER_AGENT},
{Conf::CONFIG_ACCOUNT_HAS_CUSTOM_USERAGENT, hasCustomUserAgent_ ? userAgent_ : DEFAULT_USER_AGENT},
{Conf::CONFIG_ACCOUNT_AUTOANSWER, autoAnswerEnabled_ ? TRUE_STR : FALSE_STR},
{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, upnpEnabled_ ? TRUE_STR : FALSE_STR},
......
......@@ -320,6 +320,7 @@ class Account : public Serializable, public std::enable_shared_from_this<Account
static const char * const HOSTNAME_KEY;
static const char * const ACCOUNT_ENABLE_KEY;
static const char * const ACCOUNT_AUTOANSWER_KEY;
static const char * const ACCOUNT_ACTIVE_CALL_LIMIT_KEY;
static const char * const MAILBOX_KEY;
static const char * const USER_AGENT_KEY;
static const char * const HAS_CUSTOM_USER_AGENT_KEY;
......@@ -359,6 +360,15 @@ class Account : public Serializable, public std::enable_shared_from_this<Account
/* If true, automatically answer calls to this account */
bool autoAnswerEnabled_;
/**
* The number of concurrent calls for the account
* -1: Unlimited
* 0: Do not disturb
* 1: Single call
* +: Multi line
*/
int activeCallLimit_ {-1} ;
/*
* The general, protocol neutral registration
* state of the account
......
......@@ -90,27 +90,30 @@ constexpr static const char STATE_DESC [] = "Transport.statusDesc
namespace ConfProperties {
constexpr static const char ID [] = "Account.id";
constexpr static const char TYPE [] = "Account.type";
constexpr static const char ALIAS [] = "Account.alias";
constexpr static const char DISPLAYNAME [] = "Account.displayName";
constexpr static const char ENABLED [] = "Account.enable";
constexpr static const char MAILBOX [] = "Account.mailbox";
constexpr static const char DTMF_TYPE [] = "Account.dtmfType";
constexpr static const char AUTOANSWER [] = "Account.autoAnswer";
constexpr static const char HOSTNAME [] = "Account.hostname";
constexpr static const char USERNAME [] = "Account.username";
constexpr static const char ROUTE [] = "Account.routeset";
constexpr static const char PASSWORD [] = "Account.password";
constexpr static const char REALM [] = "Account.realm";
constexpr static const char LOCAL_INTERFACE [] = "Account.localInterface";
constexpr static const char PUBLISHED_SAMEAS_LOCAL[] = "Account.publishedSameAsLocal";
constexpr static const char LOCAL_PORT [] = "Account.localPort";
constexpr static const char PUBLISHED_PORT [] = "Account.publishedPort";
constexpr static const char PUBLISHED_ADDRESS [] = "Account.publishedAddress";
constexpr static const char USER_AGENT [] = "Account.useragent";
constexpr static const char UPNP_ENABLED [] = "Account.upnpEnabled";
constexpr static const char HAS_CUSTOM_USER_AGENT [] = "Account.hasCustomUserAgent";
constexpr static const char ID [] = "Account.id";
constexpr static const char TYPE [] = "Account.type";
constexpr static const char ALIAS [] = "Account.alias";
constexpr static const char DISPLAYNAME [] = "Account.displayName";
constexpr static const char ENABLED [] = "Account.enable";
constexpr static const char MAILBOX [] = "Account.mailbox";
constexpr static const char DTMF_TYPE [] = "Account.dtmfType";
constexpr static const char AUTOANSWER [] = "Account.autoAnswer";
constexpr static const char ACTIVE_CALL_LIMIT [] = "Account.activeCallLimit";
constexpr static const char HOSTNAME [] = "Account.hostname";
constexpr static const char USERNAME [] = "Account.username";
constexpr static const char ROUTE [] = "Account.routeset";
constexpr static const char PASSWORD [] = "Account.password";
constexpr static const char REALM [] = "Account.realm";
constexpr static const char LOCAL_INTERFACE [] = "Account.localInterface";
constexpr static const char PUBLISHED_SAMEAS_LOCAL [] = "Account.publishedSameAsLocal";
constexpr static const char LOCAL_PORT [] = "Account.localPort";
constexpr static const char PUBLISHED_PORT [] = "Account.publishedPort";
constexpr static const char PUBLISHED_ADDRESS [] = "Account.publishedAddress";
constexpr static const char USER_AGENT [] = "Account.useragent";
constexpr static const char UPNP_ENABLED [] = "Account.upnpEnabled";
constexpr static const char HAS_CUSTOM_USER_AGENT [] = "Account.hasCustomUserAgent";
constexpr static const char ALLOW_CERT_FROM_HISTORY [] = "Account.allowCertFromHistory";
constexpr static const char ALLOW_CERT_FROM_CONTACT [] = "Account.allowCertFromContact";
namespace Audio {
......
......@@ -46,6 +46,7 @@
#include "client/ring_signal.h"
#include "dring/call_const.h"
#include "dring/account_const.h"
#include "upnp/upnp_control.h"
#include "system_codec_container.h"
......@@ -385,6 +386,8 @@ void RingAccount::serialize(YAML::Emitter &out)
SIPAccountBase::serialize(out);
out << YAML::Key << Conf::DHT_PORT_KEY << YAML::Value << dhtPort_;
out << YAML::Key << Conf::DHT_PUBLIC_IN_CALLS << YAML::Value << dhtPublicInCalls_;
out << YAML::Key << Conf::DHT_ALLOW_PEERS_FROM_HISTORY << YAML::Value << allowPeersFromHistory_;
out << YAML::Key << Conf::DHT_ALLOW_PEERS_FROM_CONTACT << YAML::Value << allowPeersFromContact_;
// tls submap
out << YAML::Key << Conf::TLS_KEY << YAML::Value << YAML::BeginMap;
......@@ -400,6 +403,8 @@ void RingAccount::unserialize(const YAML::Node &node)
SIPAccountBase::unserialize(node);
parseValue(node, Conf::DHT_PORT_KEY, dhtPort_);
parseValue(node, Conf::DHT_ALLOW_PEERS_FROM_HISTORY, allowPeersFromHistory_);
parseValue(node, Conf::DHT_ALLOW_PEERS_FROM_CONTACT, allowPeersFromContact_);
if (not dhtPort_)
dhtPort_ = getRandomEvenPort(DHT_PORT_RANGE);
dhtPortUsed_ = dhtPort_;
......@@ -483,10 +488,12 @@ RingAccount::saveIdentity(const dht::crypto::Identity id, const std::string& pat
void RingAccount::setAccountDetails(const std::map<std::string, std::string> &details)
{
SIPAccountBase::setAccountDetails(details);
if (hostname_ == "")
if (hostname_.empty())
hostname_ = DHT_DEFAULT_BOOTSTRAP;
parseInt(details, Conf::CONFIG_DHT_PORT, dhtPort_);
parseBool(details, Conf::CONFIG_DHT_PUBLIC_IN_CALLS, dhtPublicInCalls_);
parseBool(details, DRing::Account::ConfProperties::ALLOW_CERT_FROM_HISTORY, allowPeersFromHistory_);
parseBool(details, DRing::Account::ConfProperties::ALLOW_CERT_FROM_CONTACT, allowPeersFromContact_);
if (not dhtPort_)
dhtPort_ = getRandomEvenPort(DHT_PORT_RANGE);
dhtPortUsed_ = dhtPort_;
......@@ -511,6 +518,8 @@ std::map<std::string, std::string> RingAccount::getAccountDetails() const
a.emplace(Conf::CONFIG_TLS_VERIFY_SERVER, TRUE_STR);
a.emplace(Conf::CONFIG_TLS_VERIFY_CLIENT, TRUE_STR);
a.emplace(Conf::CONFIG_TLS_REQUIRE_CLIENT_CERTIFICATE, TRUE_STR);
a.emplace(DRing::Account::ConfProperties::ALLOW_CERT_FROM_HISTORY, allowPeersFromHistory_?TRUE_STR:FALSE_STR);
a.emplace(DRing::Account::ConfProperties::ALLOW_CERT_FROM_CONTACT, allowPeersFromContact_?TRUE_STR:FALSE_STR);
/* GNUTLS_DEFAULT_HANDSHAKE_TIMEOUT is defined as -1 */
a.emplace(Conf::CONFIG_TLS_NEGOTIATION_TIMEOUT_SEC, "-1");
......
......@@ -71,6 +71,8 @@ const char *const DHT_VALUES_PATH_KEY = "dhtValuesPath";
const char *const DHT_CONTACTS = "dhtContacts";
const char *const DHT_PUBLIC_PROFILE = "dhtPublicProfile";
const char *const DHT_PUBLIC_IN_CALLS = "dhtPublicInCalls";
const char *const DHT_ALLOW_PEERS_FROM_HISTORY = "allowPeersFromHistory";
const char *const DHT_ALLOW_PEERS_FROM_CONTACT = "allowPeersFromContact";
}
class IceTransport;
......@@ -379,6 +381,8 @@ class RingAccount : public SIPAccountBase {
std::shared_future<std::unique_ptr<gnutls_dh_params_int, decltype(gnutls_dh_params_deinit)&>> dhParams_;
std::mutex dhParamsMtx_;
std::condition_variable dhParamsCv_;
bool allowPeersFromHistory_;
bool allowPeersFromContact_;
/**
* Optional: "received" parameter from VIA header
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment