Amna | 4a70f5c | 2023-09-14 17:32:05 -0400 | [diff] [blame] | 1 | /* |
| 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 | |
| 24 | namespace dhtnet { |
| 25 | |
| 26 | class Dsh |
| 27 | { |
| 28 | public: |
| 29 | // Build a server |
Amna | c75ffe9 | 2024-02-08 17:23:29 -0500 | [diff] [blame] | 30 | Dsh(dht::crypto::Identity identity, |
Amna | 2b5b07f | 2024-01-22 17:04:36 -0500 | [diff] [blame] | 31 | const std::string& bootstrap, |
| 32 | const std::string& turn_host, |
| 33 | const std::string& turn_user, |
| 34 | const std::string& turn_pass, |
Amna | 4325f0f | 2024-01-22 16:11:00 -0500 | [diff] [blame] | 35 | const std::string& turn_realm, |
| 36 | const bool anonymous); |
Amna | 4a70f5c | 2023-09-14 17:32:05 -0400 | [diff] [blame] | 37 | // Build a client |
Amna | c75ffe9 | 2024-02-08 17:23:29 -0500 | [diff] [blame] | 38 | Dsh(dht::crypto::Identity identity, |
Amna | 4a70f5c | 2023-09-14 17:32:05 -0400 | [diff] [blame] | 39 | const std::string& bootstrap, |
| 40 | dht::InfoHash peer_id, |
Amna | 2b5b07f | 2024-01-22 17:04:36 -0500 | [diff] [blame] | 41 | 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); |
Amna | 4a70f5c | 2023-09-14 17:32:05 -0400 | [diff] [blame] | 46 | ~Dsh(); |
| 47 | void run(); |
| 48 | |
| 49 | private: |
| 50 | std::unique_ptr<ConnectionManager> connectionManager; |
| 51 | std::shared_ptr<Logger> logger; |
| 52 | std::shared_ptr<tls::CertificateStore> certStore {nullptr}; |
Amna | a5452cf | 2024-01-22 16:07:24 -0500 | [diff] [blame] | 53 | std::shared_ptr<dhtnet::IceTransportFactory> iceFactory {nullptr}; |
Amna | 4a70f5c | 2023-09-14 17:32:05 -0400 | [diff] [blame] | 54 | std::shared_ptr<asio::io_context> ioContext; |
Amna | 4325f0f | 2024-01-22 16:11:00 -0500 | [diff] [blame] | 55 | std::shared_ptr<tls::TrustStore> trustStore; |
| 56 | |
Amna | 4a70f5c | 2023-09-14 17:32:05 -0400 | [diff] [blame] | 57 | }; |
| 58 | |
| 59 | } // namespace dhtnet |