summaryrefslogtreecommitdiff
path: root/modules/websocket
diff options
context:
space:
mode:
Diffstat (limited to 'modules/websocket')
-rw-r--r--modules/websocket/SCsub117
-rw-r--r--modules/websocket/doc_classes/WebSocketClient.xml2
-rw-r--r--modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml2
-rw-r--r--modules/websocket/doc_classes/WebSocketPeer.xml2
-rw-r--r--modules/websocket/doc_classes/WebSocketServer.xml2
-rw-r--r--modules/websocket/lws_client.cpp12
-rw-r--r--modules/websocket/lws_peer.cpp2
-rw-r--r--modules/websocket/lws_server.cpp4
-rw-r--r--modules/websocket/packet_buffer.h8
-rw-r--r--modules/websocket/websocket_multiplayer_peer.cpp6
10 files changed, 83 insertions, 74 deletions
diff --git a/modules/websocket/SCsub b/modules/websocket/SCsub
index b67a836fe8..0345e533bc 100644
--- a/modules/websocket/SCsub
+++ b/modules/websocket/SCsub
@@ -9,85 +9,90 @@ env_lws = env_modules.Clone()
if env['builtin_libwebsockets'] and not env["platform"] == "javascript": # already builtin for javascript
thirdparty_dir = "#thirdparty/libwebsockets/"
- helper_dir = "win32helpers/"
+ helper_dir = "#thirdparty/libwebsockets/win32helpers/"
thirdparty_sources = [
- "core/alloc.c",
- "core/context.c",
- "core/libwebsockets.c",
- "core/output.c",
- "core/pollfd.c",
- "core/service.c",
-
- "event-libs/poll/poll.c",
-
- "misc/base64-decode.c",
- "misc/lejp.c",
- "misc/sha-1.c",
-
- "roles/h1/ops-h1.c",
- "roles/http/header.c",
- "roles/http/client/client.c",
- "roles/http/client/client-handshake.c",
- "roles/http/server/fops-zip.c",
- "roles/http/server/lejp-conf.c",
- "roles/http/server/parsers.c",
- "roles/http/server/server.c",
- "roles/listen/ops-listen.c",
- "roles/pipe/ops-pipe.c",
- "roles/raw/ops-raw.c",
-
- "roles/ws/client-ws.c",
- "roles/ws/client-parser-ws.c",
- "roles/ws/ops-ws.c",
- "roles/ws/server-ws.c",
-
- "tls/tls.c",
- "tls/tls-client.c",
- "tls/tls-server.c",
-
- "tls/mbedtls/wrapper/library/ssl_cert.c",
- "tls/mbedtls/wrapper/library/ssl_pkey.c",
- "tls/mbedtls/wrapper/library/ssl_stack.c",
- "tls/mbedtls/wrapper/library/ssl_methods.c",
- "tls/mbedtls/wrapper/library/ssl_lib.c",
- "tls/mbedtls/wrapper/library/ssl_x509.c",
- "tls/mbedtls/wrapper/platform/ssl_port.c",
- "tls/mbedtls/wrapper/platform/ssl_pm.c",
- "tls/mbedtls/lws-genhash.c",
- "tls/mbedtls/mbedtls-client.c",
- "tls/mbedtls/lws-genrsa.c",
- "tls/mbedtls/ssl.c",
- "tls/mbedtls/mbedtls-server.c"
+ "lib/core/adopt.c",
+ "lib/core/alloc.c",
+ "lib/core/connect.c",
+ "lib/core/context.c",
+ "lib/core/dummy-callback.c",
+ "lib/core/libwebsockets.c",
+ "lib/core/output.c",
+ "lib/core/pollfd.c",
+ "lib/core/service.c",
+
+ "lib/event-libs/poll/poll.c",
+
+ "lib/misc/base64-decode.c",
+ "lib/misc/lejp.c",
+ "lib/misc/sha-1.c",
+
+ "lib/roles/h1/ops-h1.c",
+ "lib/roles/http/header.c",
+ "lib/roles/http/client/client.c",
+ "lib/roles/http/client/client-handshake.c",
+ "lib/roles/http/server/fops-zip.c",
+ "lib/roles/http/server/lejp-conf.c",
+ "lib/roles/http/server/parsers.c",
+ "lib/roles/http/server/server.c",
+ "lib/roles/listen/ops-listen.c",
+ "lib/roles/pipe/ops-pipe.c",
+ "lib/roles/raw-skt/ops-raw-skt.c",
+ "lib/roles/raw-file/ops-raw-file.c",
+
+ "lib/roles/ws/client-ws.c",
+ "lib/roles/ws/client-parser-ws.c",
+ "lib/roles/ws/ops-ws.c",
+ "lib/roles/ws/server-ws.c",
+
+ "lib/tls/tls.c",
+ "lib/tls/tls-client.c",
+ "lib/tls/tls-server.c",
+
+ "lib/tls/mbedtls/wrapper/library/ssl_cert.c",
+ "lib/tls/mbedtls/wrapper/library/ssl_pkey.c",
+ "lib/tls/mbedtls/wrapper/library/ssl_stack.c",
+ "lib/tls/mbedtls/wrapper/library/ssl_methods.c",
+ "lib/tls/mbedtls/wrapper/library/ssl_lib.c",
+ "lib/tls/mbedtls/wrapper/library/ssl_x509.c",
+ "lib/tls/mbedtls/wrapper/platform/ssl_port.c",
+ "lib/tls/mbedtls/wrapper/platform/ssl_pm.c",
+ "lib/tls/mbedtls/lws-genhash.c",
+ "lib/tls/mbedtls/mbedtls-client.c",
+ "lib/tls/mbedtls/lws-genrsa.c",
+ "lib/tls/mbedtls/ssl.c",
+ "lib/tls/mbedtls/mbedtls-server.c"
]
if env["platform"] == "android": # Builtin getifaddrs
- thirdparty_sources += ["misc/getifaddrs.c"]
+ thirdparty_sources += ["lib/misc/getifaddrs.c"]
+
+ thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
if env["platform"] == "windows" or env["platform"] == "uwp": # Winsock
- thirdparty_sources += ["plat/lws-plat-win.c", helper_dir + "getopt.c", helper_dir + "getopt_long.c", helper_dir + "gettimeofday.c"]
+ thirdparty_sources += Glob(thirdparty_dir + "lib/plat/windows/*.c") + [helper_dir + src for src in ["getopt.c", "getopt_long.c", "gettimeofday.c"]]
else: # Unix socket
- thirdparty_sources += ["plat/lws-plat-unix.c"]
-
- thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
+ thirdparty_sources += Glob(thirdparty_dir + "lib/plat/unix/*.c")
- env_lws.Append(CPPPATH=[thirdparty_dir])
+ env_lws.Append(CPPPATH=[thirdparty_dir + 'include/'])
if env['builtin_mbedtls']:
mbedtls_includes = "#thirdparty/mbedtls/include"
env_lws.Prepend(CPPPATH=[mbedtls_includes])
- wrapper_includes = ["#thirdparty/libwebsockets/tls/mbedtls/wrapper/include/" + inc for inc in ["internal", "openssl", "platform", ""]]
+ wrapper_includes = ["#thirdparty/libwebsockets/lib/tls/mbedtls/wrapper/include/" + inc for inc in ["internal", "openssl", "platform", ""]]
env_lws.Prepend(CPPPATH=wrapper_includes)
if env["platform"] == "windows" or env["platform"] == "uwp":
- env_lws.Append(CPPPATH=[thirdparty_dir + helper_dir])
+ env_lws.Append(CPPPATH=[helper_dir])
if env["platform"] == "uwp":
env_lws.Append(CCFLAGS=["/DLWS_MINGW_SUPPORT"])
env_thirdparty = env_lws.Clone()
env_thirdparty.disable_warnings()
+ env_thirdparty.Append(CPPPATH=[thirdparty_dir + 'lib/'])
env_thirdparty.add_source_files(env.modules_sources, thirdparty_sources)
env_lws.add_source_files(env.modules_sources, "*.cpp")
diff --git a/modules/websocket/doc_classes/WebSocketClient.xml b/modules/websocket/doc_classes/WebSocketClient.xml
index ffb6d40e30..cb85fe864d 100644
--- a/modules/websocket/doc_classes/WebSocketClient.xml
+++ b/modules/websocket/doc_classes/WebSocketClient.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="WebSocketClient" inherits="WebSocketMultiplayerPeer" category="Core" version="3.1">
+<class name="WebSocketClient" inherits="WebSocketMultiplayerPeer" category="Core" version="3.2">
<brief_description>
A WebSocket client implementation
</brief_description>
diff --git a/modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml b/modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml
index 1a841f85ed..139480c31f 100644
--- a/modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml
+++ b/modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="WebSocketMultiplayerPeer" inherits="NetworkedMultiplayerPeer" category="Core" version="3.1">
+<class name="WebSocketMultiplayerPeer" inherits="NetworkedMultiplayerPeer" category="Core" version="3.2">
<brief_description>
Base class for WebSocket server and client.
</brief_description>
diff --git a/modules/websocket/doc_classes/WebSocketPeer.xml b/modules/websocket/doc_classes/WebSocketPeer.xml
index 5dda012899..3b3692dd87 100644
--- a/modules/websocket/doc_classes/WebSocketPeer.xml
+++ b/modules/websocket/doc_classes/WebSocketPeer.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="WebSocketPeer" inherits="PacketPeer" category="Core" version="3.1">
+<class name="WebSocketPeer" inherits="PacketPeer" category="Core" version="3.2">
<brief_description>
A class representing a specific WebSocket connection.
</brief_description>
diff --git a/modules/websocket/doc_classes/WebSocketServer.xml b/modules/websocket/doc_classes/WebSocketServer.xml
index 2932bf782a..4740bd6dcf 100644
--- a/modules/websocket/doc_classes/WebSocketServer.xml
+++ b/modules/websocket/doc_classes/WebSocketServer.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="WebSocketServer" inherits="WebSocketMultiplayerPeer" category="Core" version="3.1">
+<class name="WebSocketServer" inherits="WebSocketMultiplayerPeer" category="Core" version="3.2">
<brief_description>
A WebSocket server implementation
</brief_description>
diff --git a/modules/websocket/lws_client.cpp b/modules/websocket/lws_client.cpp
index 2fbb46f3e2..d09558ab22 100644
--- a/modules/websocket/lws_client.cpp
+++ b/modules/websocket/lws_client.cpp
@@ -34,7 +34,10 @@
#include "core/io/ip.h"
#include "core/io/stream_peer_ssl.h"
#include "core/project_settings.h"
-#include "tls/mbedtls/wrapper/include/openssl/ssl.h"
+#if defined(LWS_OPENSSL_SUPPORT)
+// Not openssl, just the mbedtls wrapper
+#include "openssl/ssl.h"
+#endif
Error LWSClient::connect_to_host(String p_host, String p_path, uint16_t p_port, bool p_ssl, PoolVector<String> p_protocols) {
@@ -121,6 +124,7 @@ int LWSClient::_handle_cb(struct lws *wsi, enum lws_callback_reasons reason, voi
LWSPeer::PeerData *peer_data = (LWSPeer::PeerData *)user;
switch (reason) {
+#if defined(LWS_OPENSSL_SUPPORT)
case LWS_CALLBACK_OPENSSL_LOAD_EXTRA_CLIENT_VERIFY_CERTS: {
PoolByteArray arr = StreamPeerSSL::get_project_cert_array();
if (arr.size() > 0)
@@ -128,7 +132,7 @@ int LWSClient::_handle_cb(struct lws *wsi, enum lws_callback_reasons reason, voi
else if (verify_ssl)
WARN_PRINTS("No CA cert specified in project settings, SSL will not work");
} break;
-
+#endif
case LWS_CALLBACK_CLIENT_ESTABLISHED:
peer->set_wsi(wsi, _in_buf_size, _in_pkt_size, _out_buf_size, _out_pkt_size);
peer_data->peer_id = 0;
@@ -144,9 +148,9 @@ int LWSClient::_handle_cb(struct lws *wsi, enum lws_callback_reasons reason, voi
case LWS_CALLBACK_WS_PEER_INITIATED_CLOSE: {
int code;
- String reason = peer->get_close_reason(in, len, code);
+ String reason2 = peer->get_close_reason(in, len, code);
peer_data->clean_close = true;
- _on_close_request(code, reason);
+ _on_close_request(code, reason2);
return 0;
}
diff --git a/modules/websocket/lws_peer.cpp b/modules/websocket/lws_peer.cpp
index 8afcdfe62e..a7c85450fa 100644
--- a/modules/websocket/lws_peer.cpp
+++ b/modules/websocket/lws_peer.cpp
@@ -102,7 +102,7 @@ Error LWSPeer::write_wsi() {
return OK;
int read = 0;
- uint8_t is_string;
+ uint8_t is_string = 0;
PoolVector<uint8_t>::Write rw = _packet_buffer.write();
_out_buffer.read_packet(&(rw[LWS_PRE]), _packet_buffer.size() - LWS_PRE, &is_string, read);
diff --git a/modules/websocket/lws_server.cpp b/modules/websocket/lws_server.cpp
index fe7da99a9f..61ccdca74a 100644
--- a/modules/websocket/lws_server.cpp
+++ b/modules/websocket/lws_server.cpp
@@ -109,9 +109,9 @@ int LWSServer::_handle_cb(struct lws *wsi, enum lws_callback_reasons reason, voi
if (_peer_map.has(id)) {
int code;
Ref<LWSPeer> peer = _peer_map[id];
- String reason = peer->get_close_reason(in, len, code);
+ String reason2 = peer->get_close_reason(in, len, code);
peer_data->clean_close = true;
- _on_close_request(id, code, reason);
+ _on_close_request(id, code, reason2);
}
return 0;
}
diff --git a/modules/websocket/packet_buffer.h b/modules/websocket/packet_buffer.h
index 5794288c2b..057fecfb56 100644
--- a/modules/websocket/packet_buffer.h
+++ b/modules/websocket/packet_buffer.h
@@ -50,7 +50,7 @@ public:
Error write_packet(const uint8_t *p_payload, uint32_t p_size, const T *p_info) {
#ifdef TOOLS_ENABLED
// Verbose buffer warnings
- if (p_payload && _payload.space_left() < p_size) {
+ if (p_payload && _payload.space_left() < (int32_t)p_size) {
ERR_PRINT("Buffer payload full! Dropping data.");
ERR_FAIL_V(ERR_OUT_OF_MEMORY);
}
@@ -59,7 +59,7 @@ public:
ERR_FAIL_V(ERR_OUT_OF_MEMORY);
}
#else
- ERR_FAIL_COND_V(p_payload && _payload.space_left() < p_size, ERR_OUT_OF_MEMORY);
+ ERR_FAIL_COND_V(p_payload && (uint32_t)_payload.space_left() < p_size, ERR_OUT_OF_MEMORY);
ERR_FAIL_COND_V(p_info && _packets.space_left() < 1, ERR_OUT_OF_MEMORY);
#endif
@@ -83,8 +83,8 @@ public:
ERR_FAIL_COND_V(_packets.data_left() < 1, ERR_UNAVAILABLE);
_Packet p;
_packets.read(&p, 1);
- ERR_FAIL_COND_V(_payload.data_left() < p.size, ERR_BUG);
- ERR_FAIL_COND_V(p_bytes < p.size, ERR_OUT_OF_MEMORY);
+ ERR_FAIL_COND_V(_payload.data_left() < (int)p.size, ERR_BUG);
+ ERR_FAIL_COND_V(p_bytes < (int)p.size, ERR_OUT_OF_MEMORY);
r_read = p.size;
copymem(r_info, &p.info, sizeof(T));
diff --git a/modules/websocket/websocket_multiplayer_peer.cpp b/modules/websocket/websocket_multiplayer_peer.cpp
index a48738b6a4..6aab8a7e81 100644
--- a/modules/websocket/websocket_multiplayer_peer.cpp
+++ b/modules/websocket/websocket_multiplayer_peer.cpp
@@ -213,7 +213,7 @@ void WebSocketMultiplayerPeer::_send_add(int32_t p_peer_id) {
_send_sys(get_peer(p_peer_id), SYS_ADD, 1);
for (Map<int, Ref<WebSocketPeer> >::Element *E = _peer_map.front(); E; E = E->next()) {
- uint32_t id = E->key();
+ int32_t id = E->key();
if (p_peer_id == id)
continue; // Skip the newwly added peer (already confirmed)
@@ -226,7 +226,7 @@ void WebSocketMultiplayerPeer::_send_add(int32_t p_peer_id) {
void WebSocketMultiplayerPeer::_send_del(int32_t p_peer_id) {
for (Map<int, Ref<WebSocketPeer> >::Element *E = _peer_map.front(); E; E = E->next()) {
- uint32_t id = E->key();
+ int32_t id = E->key();
if (p_peer_id != id)
_send_sys(get_peer(id), SYS_DEL, p_peer_id);
}
@@ -288,7 +288,7 @@ void WebSocketMultiplayerPeer::_process_multiplayer(Ref<WebSocketPeer> p_peer, u
data_size = size - PROTO_SIZE;
uint8_t type = 0;
- int32_t from = 0;
+ uint32_t from = 0;
int32_t to = 0;
copymem(&type, in_buffer, 1);
copymem(&from, &in_buffer[1], 4);