diff --git a/src/account_schema.h b/src/account_schema.h index 820463a80dc6851d22360a0d93268b690a735420..f5a187fcf90f456b623b54ea5111ccec04d1301f 100644 --- a/src/account_schema.h +++ b/src/account_schema.h @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2004-2021 Savoir-faire Linux Inc. * * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> @@ -53,6 +53,7 @@ static const char* const CONFIG_PRESENCE_NOTE = "Account.presenceNote"; static const char* const CONFIG_ACCOUNT_HOSTNAME = "Account.hostname"; static const char* const CONFIG_ACCOUNT_USERNAME = "Account.username"; static const char* const CONFIG_ACCOUNT_ROUTESET = "Account.routeset"; +static const char* const CONFIG_ACCOUNT_IP_REWRITE = "Account.allowViaRewrite"; static const char* const CONFIG_ACCOUNT_PASSWORD = "Account.password"; static const char* const CONFIG_ACCOUNT_REALM = "Account.realm"; static const char* const CONFIG_ACCOUNT_USERAGENT = "Account.useragent"; diff --git a/src/sip/sipaccount.cpp b/src/sip/sipaccount.cpp index f61181d3883061e53f2c9398ce40bb4b8f92406b..5657dc7264ec86079233297e1fa0570de47052ca 100644 --- a/src/sip/sipaccount.cpp +++ b/src/sip/sipaccount.cpp @@ -84,6 +84,7 @@ namespace jami { using yaml_utils::parseValue; +using yaml_utils::parseValueOptional; using yaml_utils::parseVectorMap; using sip_utils::CONST_PJ_STR; @@ -152,7 +153,7 @@ SIPAccount::SIPAccount(const std::string& accountID, bool presenceEnabled) , contactBuffer_() , contact_ {contactBuffer_, 0} , contactRewriteMethod_(2) - , allowViaRewrite_(true) + , allowViaRewrite_(false) , allowContactRewrite_(1) , contactOverwritten_(false) , via_tp_(nullptr) @@ -456,6 +457,7 @@ SIPAccount::serialize(YAML::Emitter& out) const out << YAML::Key << Preferences::REGISTRATION_EXPIRE_KEY << YAML::Value << registrationExpire_; out << YAML::Key << Conf::SERVICE_ROUTE_KEY << YAML::Value << serviceRoute_; + out << YAML::Key << Conf::ALLOW_VIA_REWRITE << YAML::Value << allowViaRewrite_; // tls submap out << YAML::Key << Conf::TLS_KEY << YAML::Value << YAML::BeginMap; @@ -532,6 +534,8 @@ SIPAccount::unserialize(const YAML::Node& node) parseValue(node, Preferences::REGISTRATION_EXPIRE_KEY, registrationExpire_); parseValue(node, Conf::KEEP_ALIVE_ENABLED, keepAliveEnabled_); parseValue(node, Conf::SERVICE_ROUTE_KEY, serviceRoute_); + parseValueOptional(node, Conf::ALLOW_VIA_REWRITE, allowViaRewrite_); + const auto& credsNode = node[Conf::CRED_KEY]; setCredentials(parseVectorMap(credsNode, {Conf::CONFIG_ACCOUNT_REALM, @@ -608,6 +612,7 @@ SIPAccount::setAccountDetails(const std::map<std::string, std::string>& details) // SIP specific account settings parseString(details, Conf::CONFIG_BIND_ADDRESS, bindAddress_); parseString(details, Conf::CONFIG_ACCOUNT_ROUTESET, serviceRoute_); + parseBool(details, Conf::CONFIG_ACCOUNT_IP_REWRITE, allowViaRewrite_); if (not publishedSameasLocal_) usePublishedAddressPortInVIA(); @@ -685,6 +690,7 @@ SIPAccount::getAccountDetails() const a.emplace(Conf::CONFIG_BIND_ADDRESS, bindAddress_); a.emplace(Conf::CONFIG_LOCAL_PORT, std::to_string(localPort_)); a.emplace(Conf::CONFIG_ACCOUNT_ROUTESET, serviceRoute_); + a.emplace(Conf::CONFIG_ACCOUNT_IP_REWRITE, allowViaRewrite_ ? TRUE_STR : FALSE_STR); a.emplace(Conf::CONFIG_ACCOUNT_REGISTRATION_EXPIRE, std::to_string(registrationExpire_)); a.emplace(Conf::CONFIG_KEEP_ALIVE_ENABLED, keepAliveEnabled_ ? TRUE_STR : FALSE_STR); diff --git a/src/sip/sipaccountbase.h b/src/sip/sipaccountbase.h index 8472a65aca2d789ae2fc21e897641b5a6151e8a7..6fb154c6e937de2abf58a60bb16c10810f12fa8a 100644 --- a/src/sip/sipaccountbase.h +++ b/src/sip/sipaccountbase.h @@ -66,6 +66,7 @@ const char* const PUBLISH_PORT_KEY = "publishPort"; const char* const SAME_AS_LOCAL_KEY = "sameasLocal"; const char* const DTMF_TYPE_KEY = "dtmfType"; const char* const SERVICE_ROUTE_KEY = "serviceRoute"; +const char* const ALLOW_VIA_REWRITE = "allowViaRewrite"; const char* const PRESENCE_ENABLED_KEY = "presenceEnabled"; const char* const PRESENCE_PUBLISH_SUPPORTED_KEY = "presencePublishSupported"; const char* const PRESENCE_SUBSCRIBE_SUPPORTED_KEY = "presenceSubscribeSupported";