blob: d3a9e83f3fa3bcce7bb193451f3eb49e879df1f0 [file] [log] [blame]
Adrien Béraud612b55b2023-05-29 10:42:04 -04001#pragma once
2
Adrien Béraud67ff0772023-07-12 11:22:29 -04003#include "ip_utils.h"
4
Adrien Béraud612b55b2023-05-29 10:42:04 -04005#include <functional>
6#include <vector>
7#include <string>
Adrien Béraud67ff0772023-07-12 11:22:29 -04008#include <memory>
Adrien Béraud612b55b2023-05-29 10:42:04 -04009
Adrien Béraud1ae60aa2023-07-07 09:55:09 -040010namespace dhtnet {
Adrien Béraud612b55b2023-05-29 10:42:04 -040011
Adrien Béraud25c30c42023-07-05 13:46:54 -040012namespace upnp {
13class UPnPContext;
14}
15
Adrien Béraud612b55b2023-05-29 10:42:04 -040016class IceTransportFactory;
17using IceTransportCompleteCb = std::function<void(bool)>;
18
19struct 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
29struct 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
54struct 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éraud25c30c42023-07-05 13:46:54 -040069 std::shared_ptr<upnp::UPnPContext> upnpContext {};
Adrien Béraud612b55b2023-05-29 10:42:04 -040070};
71
72}