Adrien Béraud | 612b55b | 2023-05-29 10:42:04 -0400 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Adrien Béraud | 67ff077 | 2023-07-12 11:22:29 -0400 | [diff] [blame] | 3 | #include "ip_utils.h" |
| 4 | |
Adrien Béraud | 612b55b | 2023-05-29 10:42:04 -0400 | [diff] [blame] | 5 | #include <functional> |
| 6 | #include <vector> |
| 7 | #include <string> |
Adrien Béraud | 67ff077 | 2023-07-12 11:22:29 -0400 | [diff] [blame] | 8 | #include <memory> |
Adrien Béraud | 612b55b | 2023-05-29 10:42:04 -0400 | [diff] [blame] | 9 | |
Adrien Béraud | 1ae60aa | 2023-07-07 09:55:09 -0400 | [diff] [blame] | 10 | namespace dhtnet { |
Adrien Béraud | 612b55b | 2023-05-29 10:42:04 -0400 | [diff] [blame] | 11 | |
Adrien Béraud | 25c30c4 | 2023-07-05 13:46:54 -0400 | [diff] [blame] | 12 | namespace upnp { |
| 13 | class UPnPContext; |
| 14 | } |
| 15 | |
Adrien Béraud | 612b55b | 2023-05-29 10:42:04 -0400 | [diff] [blame] | 16 | class IceTransportFactory; |
| 17 | using IceTransportCompleteCb = std::function<void(bool)>; |
| 18 | |
| 19 | struct StunServerInfo |
| 20 | { |
| 21 | inline StunServerInfo& setUri(const std::string& args) { |
| 22 | uri = args; |
| 23 | return *this; |
| 24 | } |
| 25 | |
| 26 | std::string uri; // server URI, mandatory |
| 27 | }; |
| 28 | |
| 29 | struct TurnServerInfo |
| 30 | { |
| 31 | inline TurnServerInfo& setUri(const std::string& args) { |
| 32 | uri = args; |
| 33 | return *this; |
| 34 | } |
| 35 | inline TurnServerInfo& setUsername(const std::string& args) { |
| 36 | username = args; |
| 37 | return *this; |
| 38 | } |
| 39 | inline TurnServerInfo& setPassword(const std::string& args) { |
| 40 | password = args; |
| 41 | return *this; |
| 42 | } |
| 43 | inline TurnServerInfo& setRealm(const std::string& args) { |
| 44 | realm = args; |
| 45 | return *this; |
| 46 | } |
| 47 | |
| 48 | std::string uri; // server URI, mandatory |
| 49 | std::string username; // credentials username (optional, empty if not used) |
| 50 | std::string password; // credentials password (optional, empty if not used) |
| 51 | std::string realm; // credentials realm (optional, empty if not used) |
| 52 | }; |
| 53 | |
| 54 | struct IceTransportOptions |
| 55 | { |
| 56 | IceTransportFactory* factory {nullptr}; |
| 57 | bool master {true}; |
| 58 | unsigned streamsCount {1}; |
| 59 | unsigned compCountPerStream {1}; |
| 60 | bool upnpEnable {false}; |
| 61 | IceTransportCompleteCb onInitDone {}; |
| 62 | IceTransportCompleteCb onNegoDone {}; |
| 63 | std::vector<StunServerInfo> stunServers; |
| 64 | std::vector<TurnServerInfo> turnServers; |
| 65 | bool tcpEnable {false}; |
| 66 | // Addresses used by the account owning the transport instance. |
| 67 | IpAddr accountLocalAddr {}; |
| 68 | IpAddr accountPublicAddr {}; |
Adrien Béraud | 25c30c4 | 2023-07-05 13:46:54 -0400 | [diff] [blame] | 69 | std::shared_ptr<upnp::UPnPContext> upnpContext {}; |
Adrien Béraud | 612b55b | 2023-05-29 10:42:04 -0400 | [diff] [blame] | 70 | }; |
| 71 | |
| 72 | } |