Browse Source

Added dummy proxyServer placeholder to WebSocket configuration

Paul-Louis Ageneau 3 years ago
parent
commit
3edffae68c
5 changed files with 18 additions and 4 deletions
  1. 1 0
      include/rtc/rtc.h
  2. 2 0
      include/rtc/websocket.hpp
  3. 4 0
      src/capi.cpp
  4. 10 0
      src/impl/websocket.cpp
  5. 1 4
      src/websocket.cpp

+ 1 - 0
include/rtc/rtc.h

@@ -365,6 +365,7 @@ int rtcSetSsrcForType(const char *mediaType, const char *sdp, char *buffer, cons
 
 typedef struct {
 	bool disableTlsVerification; // if true, don't verify the TLS certificate
+	const char *proxyServer;     // unsupported for now
 } rtcWsConfiguration;
 
 RTC_EXPORT int rtcCreateWebSocket(const char *url); // returns ws id

+ 2 - 0
include/rtc/websocket.hpp

@@ -23,6 +23,7 @@
 
 #include "channel.hpp"
 #include "common.hpp"
+#include "configuration.hpp"
 
 namespace rtc {
 
@@ -43,6 +44,7 @@ public:
 
 	struct Configuration {
 		bool disableTlsVerification = false; // if true, don't verify the TLS certificate
+		optional<ProxyServer> proxyServer;   // unsupported for now
 		std::vector<string> protocols;
 	};
 

+ 4 - 0
src/capi.cpp

@@ -1284,6 +1284,10 @@ int rtcCreateWebSocketEx(const char *url, const rtcWsConfiguration *config) {
 
 		WebSocket::Configuration c;
 		c.disableTlsVerification = config->disableTlsVerification;
+
+		if (config->proxyServer)
+			c.proxyServer.emplace(config->proxyServer);
+
 		auto webSocket = std::make_shared<WebSocket>(std::move(c));
 		webSocket->open(url);
 		return emplaceWebSocket(webSocket);

+ 10 - 0
src/impl/websocket.cpp

@@ -57,6 +57,10 @@ void WebSocket::open(const string &url) {
 	if (state != State::Closed)
 		throw std::logic_error("WebSocket must be closed before opening");
 
+	if (config.proxyServer) {
+		PLOG_WARNING << "Proxy server support for WebSocket is not implemented";
+	}
+
 	// Modified regex from RFC 3986, see https://www.rfc-editor.org/rfc/rfc3986.html#appendix-B
 	static const char *rs =
 	    R"(^(([^:.@/?#]+):)?(/{0,2}((([^:@]*)(:([^@]*))?)@)?(([^:/?#]*)(:([^/?#]*))?))?([^?#]*)(\?([^#]*))?(#(.*))?)";
@@ -76,6 +80,12 @@ void WebSocket::open(const string &url) {
 
 	mIsSecure = (scheme != "ws");
 
+	string username = m[6];
+	string password = m[8];
+	if (!username.empty() || !password.empty()) {
+		PLOG_WARNING << "HTTP authentication support for WebSocket is not implemented";
+	}
+
 	string host;
 	string hostname = m[10];
 	string service = m[12];

+ 1 - 4
src/websocket.cpp

@@ -53,10 +53,7 @@ bool WebSocket::isClosed() const { return impl()->state.load() == State::Closed;
 
 size_t WebSocket::maxMessageSize() const { return DEFAULT_MAX_MESSAGE_SIZE; }
 
-void WebSocket::open(const string &url) {
-	PLOG_VERBOSE << "Opening WebSocket to URL: " << url;
-	impl()->open(url);
-}
+void WebSocket::open(const string &url) { impl()->open(url); }
 
 void WebSocket::close() { impl()->close(); }