Skip to content

Commit 6edf2ef

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 8dfaa11 + f71e3d4 commit 6edf2ef

File tree

6 files changed

+41
-31
lines changed

6 files changed

+41
-31
lines changed

.github/workflows/push.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ jobs:
2121
- name: Build Tests
2222
run: bash ./.github/scripts/on-push.sh ${{ matrix.board }} 0 1
2323

24-
build-pio:
25-
name: PlatformIO for ${{ matrix.board }} on ${{ matrix.os }}
26-
runs-on: ${{ matrix.os }}
27-
strategy:
28-
matrix:
29-
os: [ubuntu-latest, windows-latest, macOS-latest]
30-
board: [esp32, esp8266]
31-
steps:
32-
- uses: actions/checkout@v1
33-
- name: Build Tests
34-
run: bash ./.github/scripts/on-push.sh ${{ matrix.board }} 1 1
24+
# build-pio:
25+
# name: PlatformIO for ${{ matrix.board }} on ${{ matrix.os }}
26+
# runs-on: ${{ matrix.os }}
27+
# strategy:
28+
# matrix:
29+
# os: [ubuntu-latest, windows-latest, macOS-latest]
30+
# board: [esp32, esp8266]
31+
# steps:
32+
# - uses: actions/checkout@v1
33+
# - name: Build Tests
34+
# run: bash ./.github/scripts/on-push.sh ${{ matrix.board }} 1 1

library.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,15 @@
1818
"platforms": ["espressif8266", "espressif32"],
1919
"dependencies": [
2020
{
21+
"owner": "me-no-dev",
2122
"name": "ESPAsyncTCP",
23+
"version": "^1.2.2",
2224
"platforms": "espressif8266"
2325
},
2426
{
27+
"owner": "me-no-dev",
2528
"name": "AsyncTCP",
29+
"version": "^1.1.1",
2630
"platforms": "espressif32"
2731
},
2832
{

src/AsyncJson.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@
4141
#if ARDUINOJSON_VERSION_MAJOR == 5
4242
#define ARDUINOJSON_5_COMPATIBILITY
4343
#else
44-
#define DYNAMIC_JSON_DOCUMENT_SIZE 1024
44+
#ifndef DYNAMIC_JSON_DOCUMENT_SIZE
45+
#define DYNAMIC_JSON_DOCUMENT_SIZE 1024
46+
#endif
4547
#endif
4648

4749
constexpr const char* JSON_MIMETYPE = "application/json";

src/AsyncWebSocket.cpp

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,7 @@
2424
#include <libb64/cencode.h>
2525

2626
#ifndef ESP8266
27-
extern "C" {
28-
typedef struct {
29-
uint32_t state[5];
30-
uint32_t count[2];
31-
unsigned char buffer[64];
32-
} SHA1_CTX;
33-
34-
void SHA1Transform(uint32_t state[5], const unsigned char buffer[64]);
35-
void SHA1Init(SHA1_CTX* context);
36-
void SHA1Update(SHA1_CTX* context, const unsigned char* data, uint32_t len);
37-
void SHA1Final(unsigned char digest[20], SHA1_CTX* context);
38-
}
27+
#include "mbedtls/sha1.h"
3928
#else
4029
#include <Hash.h>
4130
#endif
@@ -1268,10 +1257,12 @@ AsyncWebSocketResponse::AsyncWebSocketResponse(const String& key, AsyncWebSocket
12681257
sha1(key + WS_STR_UUID, hash);
12691258
#else
12701259
(String&)key += WS_STR_UUID;
1271-
SHA1_CTX ctx;
1272-
SHA1Init(&ctx);
1273-
SHA1Update(&ctx, (const unsigned char*)key.c_str(), key.length());
1274-
SHA1Final(hash, &ctx);
1260+
mbedtls_sha1_context ctx;
1261+
mbedtls_sha1_init(&ctx);
1262+
mbedtls_sha1_starts_ret(&ctx);
1263+
mbedtls_sha1_update_ret(&ctx, (const unsigned char*)key.c_str(), key.length());
1264+
mbedtls_sha1_finish_ret(&ctx, hash);
1265+
mbedtls_sha1_free(&ctx);
12751266
#endif
12761267
base64_encodestate _state;
12771268
base64_init_encodestate(&_state);

src/WebAuthentication.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ static bool getMD5(uint8_t * data, uint16_t len, char * output){//33 bytes or mo
7171
memset(_buf, 0x00, 16);
7272
#ifdef ESP32
7373
mbedtls_md5_init(&_ctx);
74-
mbedtls_md5_starts(&_ctx);
75-
mbedtls_md5_update(&_ctx, data, len);
76-
mbedtls_md5_finish(&_ctx, _buf);
74+
mbedtls_md5_starts_ret(&_ctx);
75+
mbedtls_md5_update_ret(&_ctx, data, len);
76+
mbedtls_md5_finish_ret(&_ctx, _buf);
7777
#else
7878
MD5Init(&_ctx);
7979
MD5Update(&_ctx, data, len);

src/WebHandlerImpl.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,13 @@ class AsyncCallbackWebHandler: public AsyncWebHandler {
105105
}
106106
} else
107107
#endif
108+
if (_uri.length() && _uri.startsWith("/*.")) {
109+
String uriTemplate = String (_uri);
110+
uriTemplate = uriTemplate.substring(uriTemplate.lastIndexOf("."));
111+
if (!request->url().endsWith(uriTemplate))
112+
return false;
113+
}
114+
else
108115
if (_uri.length() && _uri.endsWith("*")) {
109116
String uriTemplate = String(_uri);
110117
uriTemplate = uriTemplate.substring(0, uriTemplate.length() - 1);
@@ -119,16 +126,22 @@ class AsyncCallbackWebHandler: public AsyncWebHandler {
119126
}
120127

121128
virtual void handleRequest(AsyncWebServerRequest *request) override final {
129+
if((_username != "" && _password != "") && !request->authenticate(_username.c_str(), _password.c_str()))
130+
return request->requestAuthentication();
122131
if(_onRequest)
123132
_onRequest(request);
124133
else
125134
request->send(500);
126135
}
127136
virtual void handleUpload(AsyncWebServerRequest *request, const String& filename, size_t index, uint8_t *data, size_t len, bool final) override final {
137+
if((_username != "" && _password != "") && !request->authenticate(_username.c_str(), _password.c_str()))
138+
return request->requestAuthentication();
128139
if(_onUpload)
129140
_onUpload(request, filename, index, data, len, final);
130141
}
131142
virtual void handleBody(AsyncWebServerRequest *request, uint8_t *data, size_t len, size_t index, size_t total) override final {
143+
if((_username != "" && _password != "") && !request->authenticate(_username.c_str(), _password.c_str()))
144+
return request->requestAuthentication();
132145
if(_onBody)
133146
_onBody(request, data, len, index, total);
134147
}

0 commit comments

Comments
 (0)