2
0

configuration.hpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /**
  2. * Copyright (c) 2019 Paul-Louis Ageneau
  3. *
  4. * This Source Code Form is subject to the terms of the Mozilla Public
  5. * License, v. 2.0. If a copy of the MPL was not distributed with this
  6. * file, You can obtain one at https://mozilla.org/MPL/2.0/.
  7. */
  8. #ifndef RTC_ICE_CONFIGURATION_H
  9. #define RTC_ICE_CONFIGURATION_H
  10. #include "common.hpp"
  11. #include <vector>
  12. namespace rtc {
  13. struct RTC_CPP_EXPORT IceServer {
  14. enum class Type { Stun, Turn };
  15. enum class RelayType { TurnUdp, TurnTcp, TurnTls };
  16. // Any type
  17. IceServer(const string &url);
  18. // STUN
  19. IceServer(string hostname_, uint16_t port_);
  20. IceServer(string hostname_, string service_);
  21. // TURN
  22. IceServer(string hostname_, uint16_t port, string username_, string password_,
  23. RelayType relayType_ = RelayType::TurnUdp);
  24. IceServer(string hostname_, string service_, string username_, string password_,
  25. RelayType relayType_ = RelayType::TurnUdp);
  26. string hostname;
  27. uint16_t port;
  28. Type type;
  29. string username;
  30. string password;
  31. RelayType relayType;
  32. };
  33. struct RTC_CPP_EXPORT ProxyServer {
  34. enum class Type { Http, Socks5 };
  35. ProxyServer(const string &url);
  36. ProxyServer(Type type_, string hostname_, uint16_t port_);
  37. ProxyServer(Type type_, string hostname_, uint16_t port_, string username_, string password_);
  38. Type type;
  39. string hostname;
  40. uint16_t port;
  41. optional<string> username;
  42. optional<string> password;
  43. };
  44. enum class CertificateType {
  45. Default = RTC_CERTIFICATE_DEFAULT, // ECDSA
  46. Ecdsa = RTC_CERTIFICATE_ECDSA,
  47. Rsa = RTC_CERTIFICATE_RSA
  48. };
  49. enum class TransportPolicy { All = RTC_TRANSPORT_POLICY_ALL, Relay = RTC_TRANSPORT_POLICY_RELAY };
  50. struct RTC_CPP_EXPORT Configuration {
  51. // ICE settings
  52. std::vector<IceServer> iceServers;
  53. optional<ProxyServer> proxyServer; // libnice only
  54. optional<string> bindAddress; // libjuice only, default any
  55. // Options
  56. CertificateType certificateType = CertificateType::Default;
  57. TransportPolicy iceTransportPolicy = TransportPolicy::All;
  58. bool enableIceTcp = false; // libnice only
  59. bool enableIceUdpMux = false; // libjuice only
  60. bool disableAutoNegotiation = false;
  61. bool disableAutoGathering = false;
  62. bool forceMediaTransport = false;
  63. bool disableFingerprintVerification = false;
  64. // Port range
  65. uint16_t portRangeBegin = 1024;
  66. uint16_t portRangeEnd = 65535;
  67. // Network MTU
  68. optional<size_t> mtu;
  69. // Local maximum message size for Data Channels
  70. optional<size_t> maxMessageSize;
  71. // Certificates and private keys
  72. optional<string> certificatePemFile;
  73. optional<string> keyPemFile;
  74. optional<string> keyPemPass;
  75. };
  76. #ifdef RTC_ENABLE_WEBSOCKET
  77. struct WebSocketConfiguration {
  78. bool disableTlsVerification = false; // if true, don't verify the TLS certificate
  79. optional<ProxyServer> proxyServer; // only non-authenticated http supported for now
  80. std::vector<string> protocols;
  81. optional<std::chrono::milliseconds> connectionTimeout; // zero to disable
  82. optional<std::chrono::milliseconds> pingInterval; // zero to disable
  83. optional<int> maxOutstandingPings;
  84. optional<string> caCertificatePemFile;
  85. optional<string> certificatePemFile;
  86. optional<string> keyPemFile;
  87. optional<string> keyPemPass;
  88. optional<size_t> maxMessageSize;
  89. };
  90. struct WebSocketServerConfiguration {
  91. uint16_t port = 8080;
  92. bool enableTls = false;
  93. optional<string> certificatePemFile;
  94. optional<string> keyPemFile;
  95. optional<string> keyPemPass;
  96. optional<string> bindAddress;
  97. optional<std::chrono::milliseconds> connectionTimeout;
  98. optional<size_t> maxMessageSize;
  99. };
  100. #endif
  101. } // namespace rtc
  102. #endif