blob: 37626b88d4788dd58030533ddb6abaa06c44bf90 [file] [log] [blame]
Adrien Bérauda1d294f2023-07-17 22:42:13 -04001/*
2 * Copyright (C) 2004-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#pragma once
18
19#include "ip_utils.h"
François-Simon Fauteux-Chapleau2ef5b662024-03-27 12:30:26 -040020#include "pj_init_lock.h"
Adrien Bérauda1d294f2023-07-17 22:42:13 -040021#include "turn_params.h"
22
23#include <opendht/logger.h>
24
25#include <functional>
26#include <memory>
27#include <string>
28
29namespace dht {
30namespace log {
Adrien Béraud9132a812023-07-21 11:20:40 -040031struct Logger;
Adrien Bérauda1d294f2023-07-17 22:42:13 -040032}
33}
34
35namespace dhtnet {
36
37using Logger = dht::log::Logger;
38
39/**
40 * This class is used to test connection to TURN servers
41 * No other logic is implemented.
42 */
43class TurnTransport
44{
45public:
46 TurnTransport(const TurnTransportParams& param, std::function<void(bool)>&& cb, const std::shared_ptr<Logger>& logger = {});
47 ~TurnTransport();
48 void shutdown();
49
50private:
51 TurnTransport() = delete;
François-Simon Fauteux-Chapleau2ef5b662024-03-27 12:30:26 -040052 PjInitLock pjInitLock_;
Adrien Bérauda1d294f2023-07-17 22:42:13 -040053 class Impl;
54 std::unique_ptr<Impl> pimpl_;
55};
56
Sébastien Blin464bdff2023-07-19 08:02:53 -040057} // namespace dhtnet