|
@@ -12981,9 +12981,11 @@ mg_unlock_context(struct mg_context *ctx)
|
|
#if defined(USE_WEBSOCKET)
|
|
#if defined(USE_WEBSOCKET)
|
|
|
|
|
|
#if !defined(NO_SSL_DL)
|
|
#if !defined(NO_SSL_DL)
|
|
|
|
+#if !defined(OPENSSL_API_3_0)
|
|
#define SHA_API static
|
|
#define SHA_API static
|
|
#include "sha1.inl"
|
|
#include "sha1.inl"
|
|
#endif
|
|
#endif
|
|
|
|
+#endif
|
|
|
|
|
|
static int
|
|
static int
|
|
send_websocket_handshake(struct mg_connection *conn, const char *websock_key)
|
|
send_websocket_handshake(struct mg_connection *conn, const char *websock_key)
|
|
@@ -12991,6 +12993,9 @@ send_websocket_handshake(struct mg_connection *conn, const char *websock_key)
|
|
static const char *magic = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
|
|
static const char *magic = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
|
|
char buf[100], sha[20], b64_sha[sizeof(sha) * 2];
|
|
char buf[100], sha[20], b64_sha[sizeof(sha) * 2];
|
|
size_t dst_len = sizeof(b64_sha);
|
|
size_t dst_len = sizeof(b64_sha);
|
|
|
|
+#if !defined(OPENSSL_API_3_0)
|
|
|
|
+ SHA_CTX sha_ctx;
|
|
|
|
+#endif
|
|
int truncated;
|
|
int truncated;
|
|
|
|
|
|
/* Calculate Sec-WebSocket-Accept reply from Sec-WebSocket-Key. */
|
|
/* Calculate Sec-WebSocket-Accept reply from Sec-WebSocket-Key. */
|
|
@@ -13002,8 +13007,14 @@ send_websocket_handshake(struct mg_connection *conn, const char *websock_key)
|
|
|
|
|
|
DEBUG_TRACE("%s", "Send websocket handshake");
|
|
DEBUG_TRACE("%s", "Send websocket handshake");
|
|
|
|
|
|
|
|
+#if defined(OPENSSL_API_3_0)
|
|
EVP_Digest((unsigned char *)buf, (uint32_t)strlen(buf), (unsigned char *)sha,
|
|
EVP_Digest((unsigned char *)buf, (uint32_t)strlen(buf), (unsigned char *)sha,
|
|
NULL, EVP_get_digestbyname("sha1"), NULL);
|
|
NULL, EVP_get_digestbyname("sha1"), NULL);
|
|
|
|
+#else
|
|
|
|
+ SHA1_Init(&sha_ctx);
|
|
|
|
+ SHA1_Update(&sha_ctx, (unsigned char *)buf, (uint32_t)strlen(buf));
|
|
|
|
+ SHA1_Final((unsigned char *)sha, &sha_ctx);
|
|
|
|
+#endif
|
|
mg_base64_encode((unsigned char *)sha, sizeof(sha), b64_sha, &dst_len);
|
|
mg_base64_encode((unsigned char *)sha, sizeof(sha), b64_sha, &dst_len);
|
|
mg_printf(conn,
|
|
mg_printf(conn,
|
|
"HTTP/1.1 101 Switching Protocols\r\n"
|
|
"HTTP/1.1 101 Switching Protocols\r\n"
|
|
@@ -22221,12 +22232,12 @@ mg_get_handler_info(struct mg_context *ctx,
|
|
mg_lock_context(ctx);
|
|
mg_lock_context(ctx);
|
|
|
|
|
|
for (tmp_rh = ctx->dd.handlers; tmp_rh != NULL; tmp_rh = tmp_rh->next) {
|
|
for (tmp_rh = ctx->dd.handlers; tmp_rh != NULL; tmp_rh = tmp_rh->next) {
|
|
-
|
|
|
|
|
|
+
|
|
if (buflen > handler_info_len+ tmp_rh->uri_len) {
|
|
if (buflen > handler_info_len+ tmp_rh->uri_len) {
|
|
memcpy(buffer+handler_info_len, tmp_rh->uri, tmp_rh->uri_len);
|
|
memcpy(buffer+handler_info_len, tmp_rh->uri, tmp_rh->uri_len);
|
|
}
|
|
}
|
|
handler_info_len += tmp_rh->uri_len;
|
|
handler_info_len += tmp_rh->uri_len;
|
|
-
|
|
|
|
|
|
+
|
|
switch (tmp_rh->handler_type) {
|
|
switch (tmp_rh->handler_type) {
|
|
case REQUEST_HANDLER:
|
|
case REQUEST_HANDLER:
|
|
(void)tmp_rh->handler;
|
|
(void)tmp_rh->handler;
|
|
@@ -22235,12 +22246,12 @@ mg_get_handler_info(struct mg_context *ctx,
|
|
(void)tmp_rh->connect_handler;
|
|
(void)tmp_rh->connect_handler;
|
|
(void) tmp_rh->ready_handler;
|
|
(void) tmp_rh->ready_handler;
|
|
(void) tmp_rh->data_handler;
|
|
(void) tmp_rh->data_handler;
|
|
- (void) tmp_rh->close_handler;
|
|
|
|
|
|
+ (void) tmp_rh->close_handler;
|
|
break;
|
|
break;
|
|
case AUTH_HANDLER:
|
|
case AUTH_HANDLER:
|
|
- (void) tmp_rh->auth_handler;
|
|
|
|
|
|
+ (void) tmp_rh->auth_handler;
|
|
break;
|
|
break;
|
|
- }
|
|
|
|
|
|
+ }
|
|
(void)cbdata;
|
|
(void)cbdata;
|
|
}
|
|
}
|
|
|
|
|