diff --git a/configure.ac b/configure.ac index 276131346a59272342921b2719a5cbfc140a9867..10e7970da289b3ec8e2d07ff5df498aef1c881fb 100644 --- a/configure.ac +++ b/configure.ac @@ -413,19 +413,8 @@ AS_IF([test "x$enable_video" != "xno"], AM_CONDITIONAL(RING_VIDEO, false) ]); -dnl TLS support is enabled if it's installed and up to date -AC_ARG_WITH([tls], - [AS_HELP_STRING([--with-tls], - [support tls @<:@default=check@:>@])], - [], - [with_tls=check]) -AS_CASE(["$with_tls"], - [yes], [PKG_CHECK_MODULES([GNUTLS], [gnutls >= 3.3], [HAVE_GNUTLS=1])], - [no], [HAVE_GNUTLS=0], - [PKG_CHECK_MODULES([GNUTLS], [gnutls >= 3.3], [HAVE_GNUTLS=1], [HAVE_GNUTLS=0])]) - -AC_DEFINE_UNQUOTED([HAVE_TLS], `if test $HAVE_GNUTLS -eq 1; then echo 1; else echo 0; fi`, [Define if you have tls support]) -AM_CONDITIONAL(BUILD_TLS, test "$HAVE_GNUTLS" -eq 1) +dnl check for GnuTLS +PKG_CHECK_MODULES([GNUTLS], [gnutls >= 3.4.14], [HAVE_GNUTLS=1], [HAVE_GNUTLS=0]) # PTHREAD @@ -521,20 +510,8 @@ AS_CASE(["$with_opus"], [PKG_CHECK_MODULES([opus], [opus], [HAVE_OPUS=1], [HAVE_OPUS=0])]) AM_CONDITIONAL([BUILD_OPUS], [test "$HAVE_OPUS" -eq 1]) -# dht is default-enabled, but requires gnutls -AC_ARG_ENABLE([dht], - AS_HELP_STRING([--disable-dht], [disable support for dht])) - -AS_IF([test "x$enable_dht" != "xno" -a "$HAVE_GNUTLS" -eq 1], - [AC_DEFINE([HAVE_DHT], 1, [Define to enable dht]) - PKG_CHECK_MODULES([OPENDHT], opendht, - AC_DEFINE([HAVE_DHT], 1, [Define to enable dht]) - AM_CONDITIONAL(USE_DHT, true), - AC_DEFINE([HAVE_DHT], 0, [Define to enable dht]) - AM_CONDITIONAL(USE_DHT, false) - AC_MSG_WARN([Missing OpenDHT]))], - [AC_DEFINE([HAVE_DHT], 0, [Define to enable dht]) - AM_CONDITIONAL(USE_DHT, false)]) +dnl check for openDHT +PKG_CHECK_MODULES([OPENDHT], [opendht >= 0.6.1],, AC_MSG_WARN([Missing OpenDHT])) dnl IPv6 mode is default-disabled AC_ARG_ENABLE([ipv6], AS_HELP_STRING([--enable-ipv6], [Enable IPv6 support])) diff --git a/src/Makefile.am b/src/Makefile.am index 355fa00950cf061ba18b95587eb8fb50c7dc69f8..ffbca3f9ec3032975a39f288096a99f7f77c86e7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -52,14 +52,10 @@ libring_la_LDFLAGS = \ @SPEEXDSP_LIBS@ \ @LIBUPNP_LIBS@ \ @PORTAUDIO_LIBS@ \ - $(TLS_LIB) \ - $(IM_LIB) \ + @GNUTLS_LIBS@ \ + @OPENDHT_LIBS@ \ $(PCRE_LIBS) -if USE_DHT -libring_la_LDFLAGS += $(OPENDHT_LIBS) -endif - if HAVE_OSX #FIXME necessary for -lintl libring_la_LDFLAGS += -L/usr/local/opt/gettext/lib @@ -73,14 +69,11 @@ libring_la_CFLAGS = \ @LIBUPNP_CFLAGS@ \ @SPEEXDSP_CFLAGS@ \ @PORTAUDIO_CFLAGS@ \ - $(TLS_CFLAGS) + @GNUTLS_CFLAGS@ \ + @OPENDHT_CFLAGS@ libring_la_CXXFLAGS = @JSONCPP_CFLAGS@ -if USE_DHT -libring_la_CFLAGS += $(OPENDHT_CFLAGS) -endif - libring_la_SOURCES = \ buildinfo.cpp \ conference.cpp \ diff --git a/src/account.cpp b/src/account.cpp index b1cdbcb77fb4af326473c7de1366e4f34820928b..f7cd8faaf5ac5d525e9d6107382869ab7077a024 100644 --- a/src/account.cpp +++ b/src/account.cpp @@ -36,12 +36,8 @@ #include "logger.h" #include "manager.h" -#if HAVE_DHT #include <opendht/rng.h> using random_device = dht::crypto::random_device; -#else -using random_device = std::random_device; -#endif #include "client/ring_signal.h" #include "account_schema.h" diff --git a/src/account_factory.cpp b/src/account_factory.cpp index 3feb7360a8de900069f1eee9eda3929590255864..51233721f9120183d421930a7fcab590a6de321e 100644 --- a/src/account_factory.cpp +++ b/src/account_factory.cpp @@ -25,9 +25,7 @@ #include "account_factory.h" #include "sip/sipaccount.h" -#if HAVE_DHT #include "ringdht/ringaccount.h" -#endif #include <stdexcept> @@ -40,11 +38,9 @@ AccountFactory::AccountFactory() auto sipfunc = [](const std::string& id){ return std::make_shared<SIPAccount>(id, true); }; generators_.insert(std::make_pair(SIPAccount::ACCOUNT_TYPE, sipfunc)); RING_DBG("registered %s account", SIPAccount::ACCOUNT_TYPE); -#if HAVE_DHT auto dhtfunc = [](const std::string& id){ return std::make_shared<RingAccount>(id, false); }; generators_.insert(std::make_pair(RingAccount::ACCOUNT_TYPE, dhtfunc)); RING_DBG("registered %s account", RingAccount::ACCOUNT_TYPE); -#endif } std::shared_ptr<Account> diff --git a/src/client/configurationmanager.cpp b/src/client/configurationmanager.cpp index b1338c199f456d87f371d424ac4c9372f714f66b..233e335df87c24592a5ce5e19658e723ed8ee5cc 100644 --- a/src/client/configurationmanager.cpp +++ b/src/client/configurationmanager.cpp @@ -28,10 +28,8 @@ #include "configurationmanager_interface.h" #include "account_schema.h" #include "manager.h" -#if HAVE_TLS && HAVE_DHT #include "security/tlsvalidator.h" #include "security/certstore.h" -#endif #include "logger.h" #include "fileutils.h" #include "archiver.h" @@ -119,17 +117,12 @@ std::map<std::string, std::string> validateCertificate(const std::string&, const std::string& certificate) { -#if HAVE_TLS && HAVE_DHT try { return TlsValidator{CertificateStore::instance().getCertificate(certificate)}.getSerializedChecks(); } catch(const std::runtime_error& e) { RING_WARN("Certificate loading failed: %s", e.what()); return {{Certificate::ChecksNames::EXIST, Certificate::CheckValuesNames::FAILED}}; } -#else - RING_WARN("TLS not supported"); - return {}; -#endif } std::map<std::string, std::string> @@ -139,38 +132,28 @@ validateCertificatePath(const std::string&, const std::string& privateKeyPass, const std::string& caList) { -#if HAVE_TLS && HAVE_DHT try { return TlsValidator{certificate, privateKey, privateKeyPass, caList}.getSerializedChecks(); } catch(const std::runtime_error& e) { RING_WARN("Certificate loading failed: %s", e.what()); return {{Certificate::ChecksNames::EXIST, Certificate::CheckValuesNames::FAILED}}; } -#else - RING_WARN("TLS not supported"); - return {}; -#endif } std::map<std::string, std::string> getCertificateDetails(const std::string& certificate) { -#if HAVE_TLS && HAVE_DHT try { return TlsValidator{CertificateStore::instance().getCertificate(certificate)}.getSerializedDetails(); } catch(const std::runtime_error& e) { RING_WARN("Certificate loading failed: %s", e.what()); } -#else - RING_WARN("TLS not supported"); -#endif return {}; } std::map<std::string, std::string> getCertificateDetailsPath(const std::string& certificate, const std::string& privateKey, const std::string& privateKeyPassword) { -#if HAVE_TLS && HAVE_DHT try { auto crt = std::make_shared<dht::crypto::Certificate>(ring::fileutils::loadFile(certificate)); TlsValidator validator {certificate, privateKey, privateKeyPassword}; @@ -179,20 +162,13 @@ getCertificateDetailsPath(const std::string& certificate, const std::string& pri } catch(const std::runtime_error& e) { RING_WARN("Certificate loading failed: %s", e.what()); } -#else - RING_WARN("TLS not supported"); -#endif return {}; } std::vector<std::string> getPinnedCertificates() { -#if HAVE_TLS && HAVE_DHT return ring::tls::CertificateStore::instance().getPinnedCertificates(); -#else - RING_WARN("TLS not supported"); -#endif return {}; } @@ -390,11 +366,9 @@ getSupportedTlsMethod() std::vector<std::string> getSupportedCiphers(const std::string& accountID) { -#if HAVE_TLS if (auto sipaccount = ring::Manager::instance().getAccount<SIPAccount>(accountID)) return SIPAccount::getSupportedTlsCiphers(); RING_ERR("SIP account %s doesn't exist", accountID.c_str()); -#endif return {}; } diff --git a/src/manager.cpp b/src/manager.cpp index 4ed2b1240493bea3e7410ff9539d838eb367b085..91d1b745616f27075c1da59aacb67d9898b06f41 100644 --- a/src/manager.cpp +++ b/src/manager.cpp @@ -39,13 +39,9 @@ #include "map_utils.h" #include "account.h" #include "string_utils.h" -#if HAVE_DHT #include "ringdht/ringaccount.h" #include <opendht/rng.h> using random_device = dht::crypto::random_device; -#else -using random_device = std::random_device; -#endif #include "call_factory.h" @@ -149,7 +145,6 @@ setSipLogLevel() pj_log_set_level(level); } -#if HAVE_TLS /** * Set gnutls's log level based on the RING_TLS_LOGLEVEL environment variable. * RING_TLS_LOGLEVEL = 0 minimum logging (default) @@ -182,7 +177,6 @@ setGnuTlsLogLevel() gnutls_global_set_log_level(level); gnutls_global_set_log_function(tls_print_logs); } -#endif // HAVE_TLS Manager& Manager::instance() @@ -276,10 +270,8 @@ Manager::init(const std::string &config_file) RING_DBG("pjsip version %s for %s initialized", pj_get_version(), PJ_OS_NAME); -#if HAVE_TLS setGnuTlsLogLevel(); RING_DBG("GNU TLS version %s initialized", gnutls_check_version(nullptr)); -#endif ice_tf_.reset(new IceTransportFactory()); @@ -2823,7 +2815,6 @@ Manager::newOutgoingCall(const std::string& toUrl, { auto preferred = getAccount(preferredAccountId); -#if HAVE_DHT if (toUrl.find("ring:") != std::string::npos) { if (preferred && preferred->getAccountType() == RingAccount::ACCOUNT_TYPE) return preferred->newOutgoingCall(toUrl); @@ -2832,7 +2823,6 @@ Manager::newOutgoingCall(const std::string& toUrl, if (acc->isEnabled()) return acc->newOutgoingCall(toUrl); } -#endif // If peer url is an IP, and the preferred account is not an "IP2IP like", // we try to find a suitable one in all SIPAccount's. auto strippedToUrl = toUrl; diff --git a/src/ringdht/Makefile.am b/src/ringdht/Makefile.am index 1ee66dc804589e072cc16a1071a9edae70f8729c..1b9219f452758236b474502e1e3a2f855d9e8079 100644 --- a/src/ringdht/Makefile.am +++ b/src/ringdht/Makefile.am @@ -1,7 +1,5 @@ include $(top_srcdir)/globals.mak -if USE_DHT - noinst_LTLIBRARIES = libringacc.la libringacc_la_CXXFLAGS = @CXXFLAGS@ @@ -14,5 +12,3 @@ libringacc_la_SOURCES = \ sip_transport_ice.h \ sips_transport_ice.cpp \ sips_transport_ice.h - -endif diff --git a/src/sip/sdp.cpp b/src/sip/sdp.cpp index baf675a48124aed8251e1c31753723360b944300..8e5299bfd6af2f0b6870d5b44213acc8fc4353bb 100644 --- a/src/sip/sdp.cpp +++ b/src/sip/sdp.cpp @@ -41,12 +41,8 @@ #include "system_codec_container.h" #include "intrin.h" // for UNUSED -#if HAVE_DHT #include <opendht/rng.h> using random_device = dht::crypto::random_device; -#else -using random_device = std::random_device; -#endif #include <algorithm> #include <cassert> diff --git a/src/sip/sipaccount.cpp b/src/sip/sipaccount.cpp index 0fab6b84360e4ee633ca348f203a858bea72b354..712480e259b500f539a927822416a37d4b9965e0 100644 --- a/src/sip/sipaccount.cpp +++ b/src/sip/sipaccount.cpp @@ -185,10 +185,8 @@ SIPAccount::newOutgoingCall(const std::string& toUrl) family = ipv6 ? pj_AF_INET6() : pj_AF_INET(); // TODO: resolve remote host using SIPVoIPLink::resolveSrvName - std::shared_ptr<SipTransport> t = -#if HAVE_TLS - isTlsEnabled() ? link_->sipTransportBroker->getTlsTransport(tlsListener_, IpAddr(sip_utils::getHostFromUri(to))) : -#endif + std::shared_ptr<SipTransport> t = isTlsEnabled() ? + link_->sipTransportBroker->getTlsTransport(tlsListener_, IpAddr(sip_utils::getHostFromUri(to))) : transport_; setTransport(t); call->setTransport(t); @@ -655,7 +653,6 @@ SIPAccount::getVolatileAccountDetails() const a.emplace(Conf::CONFIG_PRESENCE_NOTE, presence_->getNote()); } -#if HAVE_TLS if (transport_ and transport_->isSecure() and transport_->isConnected()) { const auto& tlsInfos = transport_->getTlsInfos(); auto cipher = pj_ssl_cipher_name(tlsInfos.cipher); @@ -673,7 +670,6 @@ SIPAccount::getVolatileAccountDetails() const } a.emplace(DRing::TlsTransport::TLS_PEER_CA_NUM, ring::to_string(n)); } -#endif return a; } @@ -788,7 +784,6 @@ void SIPAccount::doRegister2_() ipv6 = hostIp_.isIpv6(); #endif -#if HAVE_TLS // Init TLS settings if the user wants to use TLS if (tlsEnable_) { RING_DBG("TLS is enabled for account %s", accountID_.c_str()); @@ -810,9 +805,7 @@ void SIPAccount::doRegister2_() return; } } - } else -#endif - { + } else { tlsListener_.reset(); transportType_ = ipv6 ? PJSIP_TRANSPORT_UDP6 : PJSIP_TRANSPORT_UDP; } @@ -837,12 +830,9 @@ void SIPAccount::doRegister2_() try { RING_WARN("Creating transport"); transport_.reset(); -#if HAVE_TLS if (isTlsEnabled()) { setTransport(link_->sipTransportBroker->getTlsTransport(tlsListener_, hostIp_, tlsServerName_.empty() ? hostname_ : tlsServerName_)); - } else -#endif - { + } else { setTransport(link_->sipTransportBroker->getUdpTransport( SipTransportDescr { getTransportType(), getLocalPort(), getLocalInterface() } )); @@ -1143,7 +1133,6 @@ SIPAccount::sendUnregister() } } -#if HAVE_TLS pj_uint32_t SIPAccount::tlsProtocolFromString(const std::string& method) { @@ -1231,8 +1220,6 @@ void SIPAccount::initTlsConfiguration() tlsSetting_.qos_ignore_error = PJ_TRUE; } -#endif - void SIPAccount::initStunConfiguration() { size_t pos; @@ -1260,13 +1247,10 @@ void SIPAccount::loadConfig() if (registrationExpire_ == 0) registrationExpire_ = DEFAULT_REGISTRATION_TIME; /** Default expire value for registration */ -#if HAVE_TLS - if (tlsEnable_) { initTlsConfiguration(); transportType_ = PJSIP_TRANSPORT_TLS; } else -#endif transportType_ = PJSIP_TRANSPORT_UDP; } diff --git a/src/sip/sipaccount.h b/src/sip/sipaccount.h index 7a63bf4dcb01fca5751450763aeb1f11f3d96543..5ad7e2942778ed49ba47d69d41a498570fc2cd0f 100644 --- a/src/sip/sipaccount.h +++ b/src/sip/sipaccount.h @@ -571,8 +571,6 @@ class SIPAccount : public SIPAccountBase { */ pjsip_transport_type_e transportType_ {PJSIP_TRANSPORT_UNSPECIFIED}; -#if HAVE_TLS - /** * Maps a string description of the SSL method * to the corresponding enum value in pjsip_ssl_method. @@ -592,8 +590,6 @@ class SIPAccount : public SIPAccountBase { */ void trimCiphers(); -#endif - /** * Initializes STUN config from the config file */ diff --git a/src/sip/siptransport.cpp b/src/sip/siptransport.cpp index 7119f92d331b9706639be15c28f397a840336cf8..a9f4f28855394a9b121776e06c73b261f5a2bc27 100644 --- a/src/sip/siptransport.cpp +++ b/src/sip/siptransport.cpp @@ -32,10 +32,8 @@ #include <pjsip.h> #include <pjsip/sip_types.h> -#if HAVE_TLS #include <pjsip/sip_transport_tls.h> #include <pj/ssl_sock.h> -#endif #include <pjnath.h> #include <pjnath/stun_config.h> #include <pjlib.h> @@ -123,7 +121,6 @@ SipTransport::stateCallback(pjsip_transport_state state, { connected_ = state == PJSIP_TP_STATE_CONNECTED; -#if HAVE_TLS auto extInfo = static_cast<const pjsip_tls_state_info*>(info->ext_info); if (isSecure() && extInfo && extInfo->ssl_sock_info && extInfo->ssl_sock_info->established) { auto tlsInfo = extInfo->ssl_sock_info; @@ -142,7 +139,6 @@ SipTransport::stateCallback(pjsip_transport_state state, } else { tlsInfos_ = {}; } -#endif std::vector<SipTransportStateCallback> cbs; { @@ -180,11 +176,11 @@ SipTransportBroker::SipTransportBroker(pjsip_endpoint *endpt, pj_caching_pool& cp, pj_pool_t& pool) : cp_(cp), pool_(pool), endpt_(endpt) { -/*#if HAVE_DHT +/* pjsip_transport_register_type(PJSIP_TRANSPORT_DATAGRAM, "ICE", pjsip_transport_get_default_port_for_type(PJSIP_TRANSPORT_UDP), &ice_pj_transport_type_); -#endif*/ +*/ RING_DBG("SipTransportBroker@%p", this); } @@ -353,7 +349,6 @@ SipTransportBroker::createUdpTransport(const SipTransportDescr& d) return ret; } -#if HAVE_TLS std::shared_ptr<TlsListener> SipTransportBroker::getTlsListener(const SipTransportDescr& d, const pjsip_tls_setting* settings) { @@ -423,9 +418,7 @@ SipTransportBroker::getTlsTransport(const std::shared_ptr<TlsListener>& l, const } return ret; } -#endif -#if HAVE_DHT std::shared_ptr<SipTransport> SipTransportBroker::getIceTransport(const std::shared_ptr<IceTransport> ice, unsigned comp_id) @@ -464,6 +457,5 @@ SipTransportBroker::getTlsIceTransport(const std::shared_ptr<ring::IceTransport> } return sip_tr; } -#endif } // namespace ring diff --git a/src/sip/siptransport.h b/src/sip/siptransport.h index 9a636b3c5ba40596b7155e2a8558d621249ecb25..b12a0948bc8f8ba6d91b65e0fc9c22afcf3c03aa 100644 --- a/src/sip/siptransport.h +++ b/src/sip/siptransport.h @@ -169,22 +169,18 @@ public: std::shared_ptr<SipTransport> getUdpTransport(const SipTransportDescr&); -#if HAVE_TLS std::shared_ptr<TlsListener> getTlsListener(const SipTransportDescr&, const pjsip_tls_setting*); std::shared_ptr<SipTransport> getTlsTransport(const std::shared_ptr<TlsListener>&, const IpAddr& remote, const std::string& remote_name = {}); -#endif -#if HAVE_DHT std::shared_ptr<SipTransport> getIceTransport(const std::shared_ptr<IceTransport>, unsigned comp_id); std::shared_ptr<SipTransport> getTlsIceTransport(const std::shared_ptr<IceTransport>, unsigned comp_id, const tls::TlsParams&); -#endif std::shared_ptr<SipTransport> addTransport(pjsip_transport*); @@ -221,9 +217,7 @@ private: /** * Storage for SIP/ICE transport instances. */ -#if HAVE_DHT int ice_pj_transport_type_ {PJSIP_TRANSPORT_START_OTHER}; -#endif pj_caching_pool& cp_; pj_pool_t& pool_; diff --git a/src/sip/sipvoiplink.cpp b/src/sip/sipvoiplink.cpp index ce26c4805e8fafd68310c5d65182e58d02ebbdbd..88745210a09167ec1b8663d321b6653583aa2c42 100644 --- a/src/sip/sipvoiplink.cpp +++ b/src/sip/sipvoiplink.cpp @@ -32,9 +32,7 @@ #include "sipcall.h" #include "sipaccount.h" -#if HAVE_DHT #include "ringdht/ringaccount.h" -#endif #include "manager.h" #if HAVE_SDES @@ -634,7 +632,6 @@ SIPVoIPLink::guessAccount(const std::string& userName, std::shared_ptr<SIPAccountBase> IP2IPAccount; MatchRank best = MatchRank::NONE; -#if HAVE_DHT // DHT accounts for (const auto& account : Manager::instance().getAllAccounts<RingAccount>()) { if (!account) @@ -649,7 +646,6 @@ SIPVoIPLink::guessAccount(const std::string& userName, result = account; } } -#endif // SIP accounts for (const auto& account : Manager::instance().getAllAccounts<SIPAccount>()) { diff --git a/src/upnp/upnp_context.cpp b/src/upnp/upnp_context.cpp index a994dd8b903ea810968f5310f3a266cf64804701..8c95f4ab116e0bf8b72c18f054fcc4a01b9e7a4c 100644 --- a/src/upnp/upnp_context.cpp +++ b/src/upnp/upnp_context.cpp @@ -43,12 +43,8 @@ #include "upnp_igd.h" #include "intrin.h" -#if HAVE_DHT #include <opendht/rng.h> using random_device = dht::crypto::random_device; -#else -using random_device = std::random_device; -#endif namespace ring { namespace upnp {