Amna | 3876830 | 2023-08-21 11:51:56 -0400 | [diff] [blame] | 1 | /* |
Amna | 2f3539b | 2023-09-18 13:59:22 -0400 | [diff] [blame] | 2 | * Copyright (C) 2023 Savoir-faire Linux Inc. |
Amna | 3876830 | 2023-08-21 11:51:56 -0400 | [diff] [blame] | 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 <opendht/crypto.h> |
Amna | c75ffe9 | 2024-02-08 17:23:29 -0500 | [diff] [blame] | 18 | #include <filesystem> |
Adrien BĂ©raud | 6c6a962 | 2023-08-27 12:49:31 -0400 | [diff] [blame] | 19 | #include "connectionmanager.h" |
| 20 | #include "multiplexed_socket.h" |
| 21 | #include "ice_transport_factory.h" |
| 22 | #include "certstore.h" |
Amna | 3876830 | 2023-08-21 11:51:56 -0400 | [diff] [blame] | 23 | |
Amna | 45db776 | 2024-07-24 18:33:48 -0400 | [diff] [blame] | 24 | #include "upnp/upnp_control.h" |
| 25 | #include "upnp/upnp_context.h" |
| 26 | |
Amna | 3876830 | 2023-08-21 11:51:56 -0400 | [diff] [blame] | 27 | namespace dhtnet { |
| 28 | |
Amna | c03c4b5 | 2024-07-24 17:57:25 -0400 | [diff] [blame] | 29 | #define Log(...) do { fmt::print(__VA_ARGS__); std::fflush(stdout); } while (0) |
| 30 | |
Amna | 3876830 | 2023-08-21 11:51:56 -0400 | [diff] [blame] | 31 | using Buffer = std::shared_ptr<std::vector<uint8_t>>; |
Amna | 2f3539b | 2023-09-18 13:59:22 -0400 | [diff] [blame] | 32 | constexpr size_t BUFFER_SIZE = 64 * 1024; |
Amna | 0e5f076 | 2024-05-06 15:40:14 -0400 | [diff] [blame] | 33 | |
| 34 | std::filesystem::path cachePath(); |
Amna | 3876830 | 2023-08-21 11:51:56 -0400 | [diff] [blame] | 35 | |
Amna | 2f3539b | 2023-09-18 13:59:22 -0400 | [diff] [blame] | 36 | std::unique_ptr<ConnectionManager::Config> connectionManagerConfig( |
Amna | 2f3539b | 2023-09-18 13:59:22 -0400 | [diff] [blame] | 37 | dht::crypto::Identity identity, |
| 38 | const std::string& bootstrap, |
| 39 | std::shared_ptr<Logger> logger, |
| 40 | std::shared_ptr<tls::CertificateStore> certStore, |
| 41 | std::shared_ptr<asio::io_context> ioContext, |
| 42 | std::shared_ptr<dhtnet::IceTransportFactory> iceFactory, |
| 43 | const std::string& turn_host ="", |
| 44 | const std::string& turn_user="", |
| 45 | const std::string& turn_pass="", |
Amna | 45db776 | 2024-07-24 18:33:48 -0400 | [diff] [blame] | 46 | const std::string& turn_realm="", |
| 47 | const bool enable_upnp=true); |
Amna | 3876830 | 2023-08-21 11:51:56 -0400 | [diff] [blame] | 48 | // add ioContext to readFromStdin |
| 49 | |
Amna | 2f3539b | 2023-09-18 13:59:22 -0400 | [diff] [blame] | 50 | template<typename T> |
Amna | 3876830 | 2023-08-21 11:51:56 -0400 | [diff] [blame] | 51 | void readFromPipe(std::shared_ptr<ChannelSocket> socket, T input, Buffer buffer); |
| 52 | |
| 53 | } // namespace dhtnet |