Commit d6d447a6 authored by Ming Rui Zhang's avatar Ming Rui Zhang Committed by Sébastien Blin

jamiaccount: add accountPublish setting

This patch also change the expiration to one minute.

Change-Id: Ib9e11de7c367311841bcf2058365fdd95a051b36
Reviewed-by: Sébastien Blin's avatarSébastien Blin <sebastien.blin@savoirfairelinux.com>
parent 093537a6
......@@ -142,7 +142,8 @@ constexpr static const char PROXY_ENABLED [] = "Account.proxyEnabled";
constexpr static const char PROXY_SERVER [] = "Account.proxyServer";
constexpr static const char PROXY_PUSH_TOKEN [] = "Account.proxyPushToken";
constexpr static const char DHT_PEER_DISCOVERY [] = "Account.peerDiscovery";
constexpr static const char ACCOUNT_PEER_DISCOVERY [] = "Account.accountDiscovery";
constexpr static const char ACCOUNT_PEER_DISCOVERY [] = "Account.accountDiscovery";
constexpr static const char ACCOUNT_PUBLISH [] = "Account.accountPublish";
namespace Audio {
......
......@@ -230,7 +230,7 @@ static constexpr const char * DEFAULT_TURN_PWD = "ring";
static constexpr const char * DEFAULT_TURN_REALM = "ring";
static const auto PROXY_REGEX = std::regex("(https?://)?([\\w\\.]+)(:(\\d+)|:\\[(.+)-(.+)\\])?");
static const std::string PEER_DISCOVERY_JAMI_SERVICE = "jami";
const constexpr auto PEER_DISCOVERY_EXPIRATION = std::chrono::minutes(15);
const constexpr auto PEER_DISCOVERY_EXPIRATION = std::chrono::minutes(1);
constexpr const char* const JamiAccount::ACCOUNT_TYPE;
......@@ -691,6 +691,7 @@ void JamiAccount::serialize(YAML::Emitter &out) const
out << YAML::Key << Conf::DHT_ALLOW_PEERS_FROM_TRUSTED << YAML::Value << allowPeersFromTrusted_;
out << YAML::Key << DRing::Account::ConfProperties::DHT_PEER_DISCOVERY << YAML::Value << dhtPeerDiscovery_;
out << YAML::Key << DRing::Account::ConfProperties::ACCOUNT_PEER_DISCOVERY << YAML::Value << accountPeerDiscovery_;
out << YAML::Key << DRing::Account::ConfProperties::ACCOUNT_PUBLISH << YAML::Value << accountPublish_;
out << YAML::Key << Conf::PROXY_ENABLED_KEY << YAML::Value << proxyEnabled_;
out << YAML::Key << Conf::PROXY_SERVER_KEY << YAML::Value << proxyServer_;
......@@ -765,6 +766,7 @@ void JamiAccount::unserialize(const YAML::Node &node)
parseValueOptional(node, DRing::Account::ConfProperties::DHT_PEER_DISCOVERY, dhtPeerDiscovery_);
parseValueOptional(node, DRing::Account::ConfProperties::ACCOUNT_PEER_DISCOVERY, accountPeerDiscovery_);
parseValueOptional(node, DRing::Account::ConfProperties::ACCOUNT_PUBLISH, accountPublish_);
#if HAVE_RINGNS
parseValueOptional(node, DRing::Account::ConfProperties::RingNS::URI, nameServer_);
......@@ -1562,6 +1564,7 @@ JamiAccount::setAccountDetails(const std::map<std::string, std::string>& details
parseBool(details, Conf::CONFIG_DHT_PUBLIC_IN_CALLS, dhtPublicInCalls_);
parseBool(details, DRing::Account::ConfProperties::DHT_PEER_DISCOVERY, dhtPeerDiscovery_);
parseBool(details, DRing::Account::ConfProperties::ACCOUNT_PEER_DISCOVERY, accountPeerDiscovery_);
parseBool(details, DRing::Account::ConfProperties::ACCOUNT_PUBLISH, accountPublish_);
parseBool(details, DRing::Account::ConfProperties::ALLOW_CERT_FROM_HISTORY, allowPeersFromHistory_);
parseBool(details, DRing::Account::ConfProperties::ALLOW_CERT_FROM_CONTACT, allowPeersFromContact_);
parseBool(details, DRing::Account::ConfProperties::ALLOW_CERT_FROM_TRUSTED, allowPeersFromTrusted_);
......@@ -1622,6 +1625,7 @@ JamiAccount::getAccountDetails() const
a.emplace(Conf::CONFIG_DHT_PUBLIC_IN_CALLS, dhtPublicInCalls_ ? TRUE_STR : FALSE_STR);
a.emplace(DRing::Account::ConfProperties::DHT_PEER_DISCOVERY, dhtPeerDiscovery_ ? TRUE_STR : FALSE_STR);
a.emplace(DRing::Account::ConfProperties::ACCOUNT_PEER_DISCOVERY, accountPeerDiscovery_ ? TRUE_STR : FALSE_STR);
a.emplace(DRing::Account::ConfProperties::ACCOUNT_PUBLISH, accountPublish_ ? TRUE_STR : FALSE_STR);
a.emplace(DRing::Account::ConfProperties::RING_DEVICE_ID, ringDeviceId_);
a.emplace(DRing::Account::ConfProperties::RING_DEVICE_NAME, ringDeviceName_);
a.emplace(DRing::Account::ConfProperties::Presence::SUPPORT_SUBSCRIBE, TRUE_STR);
......@@ -2172,11 +2176,13 @@ JamiAccount::doRegister_()
}
//check if dht peer service is enabled
if(accountPeerDiscovery_){
if(accountPeerDiscovery_ || accountPublish_){
peerDiscovery_ = std::make_shared<dht::PeerDiscovery>();
JAMI_INFO("Start Jami account discovering.....");
startAccountDiscovery();
startAccountPublish();
if(accountPeerDiscovery_)
startAccountDiscovery();
if(accountPublish_)
startAccountPublish();
}
dht::DhtRunner::Context context {};
context.peerDiscovery = peerDiscovery_;
......
......@@ -702,6 +702,7 @@ class JamiAccount : public SIPAccountBase {
std::map<dht::InfoHash, DiscoveredPeer> discoveredPeers_;
std::map<std::string, std::string> discoveredPeerMap_;
bool accountPeerDiscovery_ {true};
bool accountPublish_ {false};
std::shared_ptr<RepeatedTask> eventHandler {};
void checkPendingCallsTask();
......
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