diff --git a/daemon/src/managerimpl.cpp b/daemon/src/managerimpl.cpp index 1615e92ab41ca7d452de94d73c3bd5daa7da5550..e130892b5bef3d0188bcfdc506409a9df821ce08 100644 --- a/daemon/src/managerimpl.cpp +++ b/daemon/src/managerimpl.cpp @@ -2841,6 +2841,18 @@ void ManagerImpl::startAudioDriverStream() audiodriver_->startStream(); } +void +ManagerImpl::freeAccount(const std::string& accountID) +{ + Account *account = getAccount(accountID); + if (!account) + return; + std::vector<Call*> account_calls(account->getVoIPLink()->getCalls(accountID)); + for (const auto& call : account_calls) + hangupCall(call->getCallId()); + account->unregisterVoIPLink(); +} + void ManagerImpl::registerAccounts() { diff --git a/daemon/src/managerimpl.h b/daemon/src/managerimpl.h index 9fcd4d350608de25fc9729762234b444a89c3fca..256f2430d33f1f0e5b72801901f937fecdd2176e 100644 --- a/daemon/src/managerimpl.h +++ b/daemon/src/managerimpl.h @@ -975,7 +975,7 @@ class ManagerImpl { IAXAccount *getIaxAccount(const std::string& accountID) const; #endif - /** + /** * Get a pointer to the IP2IP account * @return SIPAccount * Pointer to the IP2IP account */ @@ -995,6 +995,12 @@ class ManagerImpl { */ VoIPLink* getAccountLink(const std::string& accountID); + /** + * Free all ressources related to this account. + * ***Current calls using this account are HANG-UP*** + */ + void freeAccount(const std::string& accountID); + /** * Send registration to all enabled accounts */ diff --git a/daemon/src/sip/sipaccount.cpp b/daemon/src/sip/sipaccount.cpp index 61e0f8891c1faf73b060bb18b2c14175368b8dc5..5851d52738cf804fedf1e5bad6254c1d75f421a4 100644 --- a/daemon/src/sip/sipaccount.cpp +++ b/daemon/src/sip/sipaccount.cpp @@ -897,6 +897,12 @@ void SIPAccount::registerVoIPLink() // Init TLS settings if the user wants to use TLS if (tlsEnable_) { DEBUG("TLS is enabled for account %s", accountID_.c_str()); + + // Dropping current calls already using the transport is currently required + // with TLS. + Manager::instance().freeAccount(accountID_); + + // PJSIP does not currently support TLS over IPv6 transportType_ = PJSIP_TRANSPORT_TLS; initTlsConfiguration(); } else { @@ -1899,6 +1905,9 @@ SIPAccount::autoReregTimerCb(pj_timer_heap_t * /*th*/, pj_timer_entry *te) void SIPAccount::scheduleReregistration(pjsip_endpoint *endpt) { + if (!isEnabled()) + return; + /* Cancel any re-registration timer */ if (auto_rereg_.timer.id) { auto_rereg_.timer.id = PJ_FALSE;