Select Git revision
fileutils.cpp
-
Emmanuel Lepage Vallee authored
Not all warnings have been enabled, only the most useful ones. This fix some outstanding issues and try to mute most deprecated warnings in dependencies headers. * Add missing "defined()" macro function * Undefine an improper macro * Disable warnings for legacy code include * Add missing cases for enum classes based switch * Add a warning for potentially dangerous code * Change ICE "onRecv()" prototype to return void * Fix an apparently accidental virtual override signature problem * Change a std::basic_string constructor to avoid ambiguity Refs #74147 Change-Id: I1361fc5d16c63fd7590f8d68ffdb0e2588a8b635
Emmanuel Lepage Vallee authoredNot all warnings have been enabled, only the most useful ones. This fix some outstanding issues and try to mute most deprecated warnings in dependencies headers. * Add missing "defined()" macro function * Undefine an improper macro * Disable warnings for legacy code include * Add missing cases for enum classes based switch * Add a warning for potentially dangerous code * Change ICE "onRecv()" prototype to return void * Fix an apparently accidental virtual override signature problem * Change a std::basic_string constructor to avoid ambiguity Refs #74147 Change-Id: I1361fc5d16c63fd7590f8d68ffdb0e2588a8b635
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
connectionmanager.cpp 61.14 KiB
/*
* Copyright (C) 2019-2023 Savoir-faire Linux Inc.
* Author: Sébastien Blin <sebastien.blin@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "connectionmanager.h"
#include "peer_connection.h"
#include "upnp/upnp_control.h"
#include "certstore.h"
#include "fileutils.h"
#include "sip_utils.h"
#include "string_utils.h"
#include <opendht/crypto.h>
#include <opendht/thread_pool.h>
#include <opendht/value.h>
#include <asio.hpp>
#include <algorithm>
#include <mutex>
#include <map>
#include <condition_variable>
#include <set>
#include <charconv>
namespace jami {
static constexpr std::chrono::seconds DHT_MSG_TIMEOUT {30};
static constexpr uint64_t ID_MAX_VAL = 9007199254740992;
using ValueIdDist = std::uniform_int_distribution<dht::Value::Id>;
using CallbackId = std::pair<jami::DeviceId, dht::Value::Id>;
struct ConnectionInfo
{
~ConnectionInfo()
{
if (socket_)
socket_->join();
}
std::mutex mutex_ {};
bool responseReceived_ {false};
PeerConnectionRequest response_ {};
std::unique_ptr<IceTransport> ice_ {nullptr};
// Used to store currently non ready TLS Socket
std::unique_ptr<TlsSocketEndpoint> tls_ {nullptr};
std::shared_ptr<MultiplexedSocket> socket_ {};
std::set<CallbackId> cbIds_ {};
std::function<void(bool)> onConnected_;
std::unique_ptr<asio::steady_timer> waitForAnswer_ {};
};
/**
* returns whether or not UPnP is enabled and active_
* ie: if it is able to make port mappings
*/
bool