blob: dd6a4ea616c9e43e019619ad4986f5d293dedab1 [file] [log] [blame]
Amna4a70f5c2023-09-14 17:32:05 -04001/*
2 * Copyright (C) 2023 Savoir-faire Linux Inc.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17#include "connectionmanager.h"
18#include "multiplexed_socket.h"
19#include "ice_transport_factory.h"
20#include "certstore.h"
21
22#include <asio.hpp>
23
24namespace dhtnet {
25
26class Dsh
27{
28public:
29 // Build a server
30 Dsh(const std::filesystem::path& path,
31 dht::crypto::Identity identity,
Amna2b5b07f2024-01-22 17:04:36 -050032 const std::string& bootstrap,
33 const std::string& turn_host,
34 const std::string& turn_user,
35 const std::string& turn_pass,
Amna4325f0f2024-01-22 16:11:00 -050036 const std::string& turn_realm,
37 const bool anonymous);
Amna4a70f5c2023-09-14 17:32:05 -040038 // Build a client
39 Dsh(const std::filesystem::path& path,
40 dht::crypto::Identity identity,
41 const std::string& bootstrap,
42 dht::InfoHash peer_id,
Amna2b5b07f2024-01-22 17:04:36 -050043 const std::string& binary,
44 const std::string& turn_host,
45 const std::string& turn_user,
46 const std::string& turn_pass,
47 const std::string& turn_realm);
Amna4a70f5c2023-09-14 17:32:05 -040048 ~Dsh();
49 void run();
50
51private:
52 std::unique_ptr<ConnectionManager> connectionManager;
53 std::shared_ptr<Logger> logger;
54 std::shared_ptr<tls::CertificateStore> certStore {nullptr};
Amnaa5452cf2024-01-22 16:07:24 -050055 std::shared_ptr<dhtnet::IceTransportFactory> iceFactory {nullptr};
Amna4a70f5c2023-09-14 17:32:05 -040056 std::shared_ptr<asio::io_context> ioContext;
57 std::thread ioContextRunner;
Amna4325f0f2024-01-22 16:11:00 -050058 std::shared_ptr<tls::TrustStore> trustStore;
59
Amna4a70f5c2023-09-14 17:32:05 -040060};
61
62} // namespace dhtnet