feat: updated engine
This commit is contained in:
parent
cbe99774ff
commit
f4cf6b3999
6607 changed files with 910135 additions and 430025 deletions
|
|
@ -33,20 +33,15 @@
|
|||
#ifndef WEB_ENABLED
|
||||
|
||||
#include "core/io/stream_peer_tls.h"
|
||||
|
||||
CryptoCore::RandomGenerator *WSLPeer::_static_rng = nullptr;
|
||||
#include "core/object/class_db.h"
|
||||
#include "core/os/os.h"
|
||||
|
||||
void WSLPeer::initialize() {
|
||||
WebSocketPeer::_create = WSLPeer::_create;
|
||||
_static_rng = memnew(CryptoCore::RandomGenerator);
|
||||
_static_rng->init();
|
||||
}
|
||||
|
||||
void WSLPeer::deinitialize() {
|
||||
if (_static_rng) {
|
||||
memdelete(_static_rng);
|
||||
_static_rng = nullptr;
|
||||
}
|
||||
WebSocketPeer *WSLPeer::_create(bool p_notify_postinitialize) {
|
||||
return static_cast<WebSocketPeer *>(ClassDB::creator<WSLPeer>(p_notify_postinitialize));
|
||||
}
|
||||
|
||||
///
|
||||
|
|
@ -175,7 +170,7 @@ bool WSLPeer::_parse_client_request() {
|
|||
}
|
||||
requested_host = headers.has("host") ? headers.get("host") : "";
|
||||
requested_url = (use_tls ? "wss://" : "ws://") + requested_host + req[1];
|
||||
#define WSL_CHECK(NAME, VALUE) \
|
||||
#define WSL_CHECK(NAME, VALUE) \
|
||||
ERR_FAIL_COND_V_MSG(!headers.has(NAME) || headers[NAME].to_lower() != VALUE, false, \
|
||||
"Missing or invalid header '" + String(NAME) + "'. Expected value '" + VALUE + "'.");
|
||||
#define WSL_CHECK_EX(NAME) \
|
||||
|
|
@ -297,7 +292,7 @@ Error WSLPeer::_do_server_handshake() {
|
|||
wslay_event_context_server_init(&wsl_ctx, &_wsl_callbacks, this);
|
||||
wslay_event_config_set_no_buffering(wsl_ctx, 1);
|
||||
wslay_event_config_set_max_recv_msg_length(wsl_ctx, inbound_buffer_size);
|
||||
in_buffer.resize(nearest_shift((uint32_t)inbound_buffer_size), max_queued_packets);
|
||||
in_buffer.resize(Math::nearest_shift((uint32_t)inbound_buffer_size), max_queued_packets);
|
||||
packet_buffer.resize(inbound_buffer_size);
|
||||
ready_state = STATE_OPEN;
|
||||
}
|
||||
|
|
@ -406,7 +401,7 @@ void WSLPeer::_do_client_handshake() {
|
|||
wslay_event_context_client_init(&wsl_ctx, &_wsl_callbacks, this);
|
||||
wslay_event_config_set_no_buffering(wsl_ctx, 1);
|
||||
wslay_event_config_set_max_recv_msg_length(wsl_ctx, inbound_buffer_size);
|
||||
in_buffer.resize(nearest_shift((uint32_t)inbound_buffer_size), max_queued_packets);
|
||||
in_buffer.resize(Math::nearest_shift((uint32_t)inbound_buffer_size), max_queued_packets);
|
||||
packet_buffer.resize(inbound_buffer_size);
|
||||
ready_state = STATE_OPEN;
|
||||
break;
|
||||
|
|
@ -440,10 +435,10 @@ bool WSLPeer::_verify_server_response() {
|
|||
}
|
||||
}
|
||||
|
||||
#define WSL_CHECK(NAME, VALUE) \
|
||||
#define WSL_CHECK(NAME, VALUE) \
|
||||
ERR_FAIL_COND_V_MSG(!headers.has(NAME) || headers[NAME].to_lower() != VALUE, false, \
|
||||
"Missing or invalid header '" + String(NAME) + "'. Expected value '" + VALUE + "'.");
|
||||
#define WSL_CHECK_NC(NAME, VALUE) \
|
||||
#define WSL_CHECK_NC(NAME, VALUE) \
|
||||
ERR_FAIL_COND_V_MSG(!headers.has(NAME) || headers[NAME] != VALUE, false, \
|
||||
"Missing or invalid header '" + String(NAME) + "'. Expected value '" + VALUE + "'.");
|
||||
WSL_CHECK("connection", "upgrade");
|
||||
|
|
@ -632,8 +627,7 @@ ssize_t WSLPeer::_wsl_send_callback(wslay_event_context_ptr ctx, const uint8_t *
|
|||
}
|
||||
|
||||
int WSLPeer::_wsl_genmask_callback(wslay_event_context_ptr ctx, uint8_t *buf, size_t len, void *user_data) {
|
||||
ERR_FAIL_NULL_V(_static_rng, WSLAY_ERR_CALLBACK_FAILURE);
|
||||
Error err = _static_rng->get_random_bytes(buf, len);
|
||||
Error err = CryptoCore::generate_random(buf, len);
|
||||
ERR_FAIL_COND_V(err != OK, WSLAY_ERR_CALLBACK_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue