blob: ec983a2f79acb41dcb461f7aa33bd563b1733d47 [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
Amnac75ffe92024-02-08 17:23:29 -050030 Dsh(dht::crypto::Identity identity,
Amna2b5b07f2024-01-22 17:04:36 -050031 const std::string& bootstrap,
32 const std::string& turn_host,
33 const std::string& turn_user,
34 const std::string& turn_pass,
Amna4325f0f2024-01-22 16:11:00 -050035 const std::string& turn_realm,
36 const bool anonymous);
Amna4a70f5c2023-09-14 17:32:05 -040037 // Build a client
Amnac75ffe92024-02-08 17:23:29 -050038 Dsh(dht::crypto::Identity identity,
Amna4a70f5c2023-09-14 17:32:05 -040039 const std::string& bootstrap,
40 dht::InfoHash peer_id,
Amna2b5b07f2024-01-22 17:04:36 -050041 const std::string& binary,
42 const std::string& turn_host,
43 const std::string& turn_user,
44 const std::string& turn_pass,
45 const std::string& turn_realm);
Amna4a70f5c2023-09-14 17:32:05 -040046 ~Dsh();
47 void run();
48
49private:
50 std::unique_ptr<ConnectionManager> connectionManager;
51 std::shared_ptr<Logger> logger;
52 std::shared_ptr<tls::CertificateStore> certStore {nullptr};
Amnaa5452cf2024-01-22 16:07:24 -050053 std::shared_ptr<dhtnet::IceTransportFactory> iceFactory {nullptr};
Amna4a70f5c2023-09-14 17:32:05 -040054 std::shared_ptr<asio::io_context> ioContext;
55 std::thread ioContextRunner;
Amna4325f0f2024-01-22 16:11:00 -050056 std::shared_ptr<tls::TrustStore> trustStore;
57
Amna4a70f5c2023-09-14 17:32:05 -040058};
59
60} // namespace dhtnet