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