blob: c349619abb73e22e6bb343cb254238631b5ba4e7 [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,
36 const std::string& turn_realm);
Amna4a70f5c2023-09-14 17:32:05 -040037 // Build a client
38 Dsh(const std::filesystem::path& path,
39 dht::crypto::Identity identity,
40 const std::string& bootstrap,
41 dht::InfoHash peer_id,
Amna2b5b07f2024-01-22 17:04:36 -050042 const std::string& binary,
43 const std::string& turn_host,
44 const std::string& turn_user,
45 const std::string& turn_pass,
46 const std::string& turn_realm);
Amna4a70f5c2023-09-14 17:32:05 -040047 ~Dsh();
48 void run();
49
50private:
51 std::unique_ptr<ConnectionManager> connectionManager;
52 std::shared_ptr<Logger> logger;
53 std::shared_ptr<tls::CertificateStore> certStore {nullptr};
54 std::shared_ptr<dhtnet::IceTransportFactory> factory {nullptr};
55 std::shared_ptr<asio::io_context> ioContext;
56 std::thread ioContextRunner;
57};
58
59} // namespace dhtnet