Compare commits

...

11 Commits

Author SHA1 Message Date
f6e730c2b4 fix _fingerprint is set checks for ESP32
see #633 and #632
2021-03-06 09:24:07 +01:00
7c3b1b7408 install libgtk-3-0 2021-03-06 08:59:21 +01:00
738e43fda4 install libgtk-3-0 2021-03-06 08:56:08 +01:00
f55bf8d4ed bump version to 2.3.5 2021-02-09 18:26:21 +01:00
a484da47ed Merge branch 'eio_4_ping_handling' 2021-01-31 20:32:25 +01:00
4355199120 bump version 2.3.4 2021-01-31 20:31:52 +01:00
0a4fcd44c2 EIO=4 ping handling #611 2021-01-31 20:27:56 +01:00
3a2b757155 EIO=4 ping handling #611 2021-01-31 10:28:15 +01:00
900d81e534 make WSclient_t * newClient(WEBSOCKETS_NETWORK_CLASS * TCPclient); public 2021-01-19 16:59:03 +01:00
0ecef8c552 Fixing WebSocket Close see #610 2021-01-19 16:58:37 +01:00
410489f7c5 bump version to 2.3.3 2021-01-07 10:27:42 +01:00
10 changed files with 55 additions and 20 deletions

View File

@ -25,7 +25,7 @@ jobs:
prepare_example_json: prepare_example_json:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: generate examples - name: generate examples
@ -60,7 +60,7 @@ jobs:
env: env:
IDE_VERSION: ${{ matrix.IDE_VERSION }} IDE_VERSION: ${{ matrix.IDE_VERSION }}
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Get Date - name: Get Date
@ -121,6 +121,10 @@ jobs:
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: install libgtk2.0-0
run: |
sudo apt-get install -y libgtk2.0-0
- name: Get Date - name: Get Date
id: get-date id: get-date
run: | run: |
@ -134,7 +138,7 @@ jobs:
/home/runner/arduino_ide /home/runner/arduino_ide
/home/runner/Arduino /home/runner/Arduino
key: ${{ runner.os }}-${{ steps.get-date.outputs.date }}-${{ matrix.ideversion }} key: ${{ runner.os }}-${{ steps.get-date.outputs.date }}-${{ matrix.ideversion }}
- name: install python serial - name: install python serial
if: matrix.cpu == 'esp32' if: matrix.cpu == 'esp32'
run: | run: |
@ -157,7 +161,7 @@ jobs:
run: | run: |
mkdir -p $HOME/Arduino/libraries/ mkdir -p $HOME/Arduino/libraries/
cp -r $GITHUB_WORKSPACE $HOME/Arduino/libraries/arduinoWebSockets cp -r $GITHUB_WORKSPACE $HOME/Arduino/libraries/arduinoWebSockets
- name: config IDE - name: config IDE
run: | run: |
export DISPLAY=:1.0 export DISPLAY=:1.0

View File

@ -21,5 +21,5 @@
"type": "git", "type": "git",
"url": "https://github.com/Links2004/arduinoWebSockets.git" "url": "https://github.com/Links2004/arduinoWebSockets.git"
}, },
"version": "2.3.2" "version": "2.3.5"
} }

View File

@ -1,5 +1,5 @@
name=WebSockets name=WebSockets
version=2.3.2 version=2.3.5
author=Markus Sattler author=Markus Sattler
maintainer=Markus Sattler maintainer=Markus Sattler
sentence=WebSockets for Arduino (Server + Client) sentence=WebSockets for Arduino (Server + Client)

View File

@ -18,31 +18,37 @@ SocketIOclient::~SocketIOclient() {
void SocketIOclient::begin(const char * host, uint16_t port, const char * url, const char * protocol) { void SocketIOclient::begin(const char * host, uint16_t port, const char * url, const char * protocol) {
WebSocketsClient::beginSocketIO(host, port, url, protocol); WebSocketsClient::beginSocketIO(host, port, url, protocol);
WebSocketsClient::enableHeartbeat(60 * 1000, 90 * 1000, 5); WebSocketsClient::enableHeartbeat(60 * 1000, 90 * 1000, 5);
initClient();
} }
void SocketIOclient::begin(String host, uint16_t port, String url, String protocol) { void SocketIOclient::begin(String host, uint16_t port, String url, String protocol) {
WebSocketsClient::beginSocketIO(host, port, url, protocol); WebSocketsClient::beginSocketIO(host, port, url, protocol);
WebSocketsClient::enableHeartbeat(60 * 1000, 90 * 1000, 5); WebSocketsClient::enableHeartbeat(60 * 1000, 90 * 1000, 5);
initClient();
} }
#if defined(HAS_SSL) #if defined(HAS_SSL)
void SocketIOclient::beginSSL(const char * host, uint16_t port, const char * url, const char * protocol) { void SocketIOclient::beginSSL(const char * host, uint16_t port, const char * url, const char * protocol) {
WebSocketsClient::beginSocketIOSSL(host, port, url, protocol); WebSocketsClient::beginSocketIOSSL(host, port, url, protocol);
WebSocketsClient::enableHeartbeat(60 * 1000, 90 * 1000, 5); WebSocketsClient::enableHeartbeat(60 * 1000, 90 * 1000, 5);
initClient();
} }
void SocketIOclient::beginSSL(String host, uint16_t port, String url, String protocol) { void SocketIOclient::beginSSL(String host, uint16_t port, String url, String protocol) {
WebSocketsClient::beginSocketIOSSL(host, port, url, protocol); WebSocketsClient::beginSocketIOSSL(host, port, url, protocol);
WebSocketsClient::enableHeartbeat(60 * 1000, 90 * 1000, 5); WebSocketsClient::enableHeartbeat(60 * 1000, 90 * 1000, 5);
initClient();
} }
#if !defined(SSL_AXTLS) #if defined(SSL_BARESSL)
void SocketIOclient::beginSSLWithCA(const char * host, uint16_t port, const char * url, const char * CA_cert, const char * protocol) { void SocketIOclient::beginSSLWithCA(const char * host, uint16_t port, const char * url, const char * CA_cert, const char * protocol) {
WebSocketsClient::beginSocketIOSSLWithCA(host, port, url, CA_cert, protocol); WebSocketsClient::beginSocketIOSSLWithCA(host, port, url, CA_cert, protocol);
WebSocketsClient::enableHeartbeat(60 * 1000, 90 * 1000, 5); WebSocketsClient::enableHeartbeat(60 * 1000, 90 * 1000, 5);
initClient();
} }
void SocketIOclient::beginSSLWithCA(const char * host, uint16_t port, const char * url, BearSSL::X509List * CA_cert, const char * protocol) { void SocketIOclient::beginSSLWithCA(const char * host, uint16_t port, const char * url, BearSSL::X509List * CA_cert, const char * protocol) {
WebSocketsClient::beginSocketIOSSLWithCA(host, port, url, CA_cert, protocol); WebSocketsClient::beginSocketIOSSLWithCA(host, port, url, CA_cert, protocol);
WebSocketsClient::enableHeartbeat(60 * 1000, 90 * 1000, 5); WebSocketsClient::enableHeartbeat(60 * 1000, 90 * 1000, 5);
initClient();
} }
void SocketIOclient::setSSLClientCertKey(const char * clientCert, const char * clientPrivateKey) { void SocketIOclient::setSSLClientCertKey(const char * clientCert, const char * clientPrivateKey) {
@ -55,6 +61,18 @@ void SocketIOclient::setSSLClientCertKey(BearSSL::X509List * clientCert, BearSSL
#endif #endif
#endif #endif
void SocketIOclient::configureEIOping(bool disableHeartbeat) {
_disableHeartbeat = disableHeartbeat;
}
void SocketIOclient::initClient(void) {
if(_client.cUrl.indexOf("EIO=4") != -1) {
DEBUG_WEBSOCKETS("[wsIOc] found EIO=4 disable EIO ping on client\n");
configureEIOping(true);
}
}
/** /**
* set callback function * set callback function
* @param cbEvent SocketIOclientEvent * @param cbEvent SocketIOclientEvent
@ -148,8 +166,8 @@ bool SocketIOclient::sendEVENT(String & payload) {
void SocketIOclient::loop(void) { void SocketIOclient::loop(void) {
WebSocketsClient::loop(); WebSocketsClient::loop();
unsigned long t = millis(); unsigned long t = millis();
if((t - _lastConnectionFail) > EIO_HEARTBEAT_INTERVAL) { if(!_disableHeartbeat && (t - _lastHeartbeat) > EIO_HEARTBEAT_INTERVAL) {
_lastConnectionFail = t; _lastHeartbeat = t;
DEBUG_WEBSOCKETS("[wsIOc] send ping\n"); DEBUG_WEBSOCKETS("[wsIOc] send ping\n");
WebSocketsClient::sendTXT(eIOtype_PING); WebSocketsClient::sendTXT(eIOtype_PING);
} }

View File

@ -77,7 +77,10 @@ class SocketIOclient : protected WebSocketsClient {
void loop(void); void loop(void);
void configureEIOping(bool disableHeartbeat = false);
protected: protected:
bool _disableHeartbeat = false;
uint64_t _lastHeartbeat = 0; uint64_t _lastHeartbeat = 0;
SocketIOclientEvent _cbEvent; SocketIOclientEvent _cbEvent;
virtual void runIOCbEvent(socketIOmessageType_t type, uint8_t * payload, size_t length) { virtual void runIOCbEvent(socketIOmessageType_t type, uint8_t * payload, size_t length) {
@ -86,6 +89,8 @@ class SocketIOclient : protected WebSocketsClient {
} }
} }
void initClient(void);
// Handeling events from websocket layer // Handeling events from websocket layer
virtual void runCbEvent(WStype_t type, uint8_t * payload, size_t length) { virtual void runCbEvent(WStype_t type, uint8_t * payload, size_t length) {
handleCbEvent(type, payload, length); handleCbEvent(type, payload, length);

View File

@ -229,8 +229,11 @@ void WebSocketsClient::loop(void) {
#else #else
#error setCACert not implemented #error setCACert not implemented
#endif #endif
#if defined(SSL_BARESSL) #if defined(ESP32)
} else if(_fingerprint) { } else if(!SSL_FINGERPRINT_IS_SET) {
_client.ssl->setInsecure();
#elif defined(SSL_BARESSL)
} else if(SSL_FINGERPRINT_IS_SET) {
_client.ssl->setFingerprint(_fingerprint); _client.ssl->setFingerprint(_fingerprint);
} else { } else {
_client.ssl->setInsecure(); _client.ssl->setInsecure();
@ -865,14 +868,14 @@ void WebSocketsClient::connectedCb() {
#if defined(HAS_SSL) #if defined(HAS_SSL)
#if defined(SSL_AXTLS) || defined(ESP32) #if defined(SSL_AXTLS) || defined(ESP32)
if(_client.isSSL && _fingerprint.length()) { if(_client.isSSL && SSL_FINGERPRINT_IS_SET) {
if(!_client.ssl->verify(_fingerprint.c_str(), _host.c_str())) { if(!_client.ssl->verify(_fingerprint.c_str(), _host.c_str())) {
DEBUG_WEBSOCKETS("[WS-Client] certificate mismatch\n"); DEBUG_WEBSOCKETS("[WS-Client] certificate mismatch\n");
WebSockets::clientDisconnect(&_client, 1000); WebSockets::clientDisconnect(&_client, 1000);
return; return;
} }
#else #else
if(_client.isSSL && _fingerprint) { if(_client.isSSL && SSL_FINGERPRINT_IS_SET) {
#endif #endif
} else if(_client.isSSL && !_CA_cert) { } else if(_client.isSSL && !_CA_cert) {
#if defined(SSL_BARESSL) #if defined(SSL_BARESSL)
@ -945,6 +948,9 @@ void WebSocketsClient::handleHBPing() {
if(sendPing()) { if(sendPing()) {
_client.lastPing = millis(); _client.lastPing = millis();
_client.pongReceived = false; _client.pongReceived = false;
} else {
DEBUG_WEBSOCKETS("[WS-Client] sending HB ping failed\n");
WebSockets::clientDisconnect(&_client, 1000);
} }
} }
} }

View File

@ -112,12 +112,14 @@ class WebSocketsClient : protected WebSockets {
#ifdef SSL_AXTLS #ifdef SSL_AXTLS
String _fingerprint; String _fingerprint;
const char * _CA_cert; const char * _CA_cert;
#define SSL_FINGERPRINT_IS_SET (_fingerprint.length())
#define SSL_FINGERPRINT_NULL "" #define SSL_FINGERPRINT_NULL ""
#else #else
const uint8_t * _fingerprint; const uint8_t * _fingerprint;
BearSSL::X509List * _CA_cert; BearSSL::X509List * _CA_cert;
BearSSL::X509List * _client_cert; BearSSL::X509List * _client_cert;
BearSSL::PrivateKey * _client_key; BearSSL::PrivateKey * _client_key;
#define SSL_FINGERPRINT_IS_SET (_fingerprint != NULL)
#define SSL_FINGERPRINT_NULL NULL #define SSL_FINGERPRINT_NULL NULL
#endif #endif

View File

@ -914,7 +914,7 @@ void WebSocketsServer::begin(void) {
} }
void WebSocketsServer::close(void) { void WebSocketsServer::close(void) {
WebSocketsServer::close(); WebSocketsServerCore::close();
#if(WEBSOCKETS_NETWORK_TYPE == NETWORK_ESP8266) #if(WEBSOCKETS_NETWORK_TYPE == NETWORK_ESP8266)
_server->close(); _server->close();
#elif(WEBSOCKETS_NETWORK_TYPE == NETWORK_ESP32) || (WEBSOCKETS_NETWORK_TYPE == NETWORK_ESP8266_ASYNC) #elif(WEBSOCKETS_NETWORK_TYPE == NETWORK_ESP32) || (WEBSOCKETS_NETWORK_TYPE == NETWORK_ESP8266_ASYNC)

View File

@ -98,6 +98,8 @@ class WebSocketsServerCore : protected WebSockets {
void loop(void); // handle client data only void loop(void); // handle client data only
#endif #endif
WSclient_t * newClient(WEBSOCKETS_NETWORK_CLASS * TCPclient);
protected: protected:
String _origin; String _origin;
String _protocol; String _protocol;
@ -116,8 +118,6 @@ class WebSocketsServerCore : protected WebSockets {
uint32_t _pongTimeout; uint32_t _pongTimeout;
uint8_t _disconnectTimeoutCount; uint8_t _disconnectTimeoutCount;
WSclient_t * newClient(WEBSOCKETS_NETWORK_CLASS * TCPclient);
void messageReceived(WSclient_t * client, WSopcode_t opcode, uint8_t * payload, size_t length, bool fin); void messageReceived(WSclient_t * client, WSopcode_t opcode, uint8_t * payload, size_t length, bool fin);
void clientDisconnect(WSclient_t * client); void clientDisconnect(WSclient_t * client);

View File

@ -1,6 +1,6 @@
/** /**
* @file WebSocketsVersion.h * @file WebSocketsVersion.h
* @date 07.01.2021 * @date 09.02.2021
* @author Markus Sattler * @author Markus Sattler
* *
* Copyright (c) 2015 Markus Sattler. All rights reserved. * Copyright (c) 2015 Markus Sattler. All rights reserved.
@ -25,12 +25,12 @@
#ifndef WEBSOCKETSVERSION_H_ #ifndef WEBSOCKETSVERSION_H_
#define WEBSOCKETSVERSION_H_ #define WEBSOCKETSVERSION_H_
#define WEBSOCKETS_VERSION "2.3.2" #define WEBSOCKETS_VERSION "2.3.5"
#define WEBSOCKETS_VERSION_MAJOR 2 #define WEBSOCKETS_VERSION_MAJOR 2
#define WEBSOCKETS_VERSION_MINOR 3 #define WEBSOCKETS_VERSION_MINOR 3
#define WEBSOCKETS_VERSION_PATCH 2 #define WEBSOCKETS_VERSION_PATCH 5
#define WEBSOCKETS_VERSION_INT 2003002 #define WEBSOCKETS_VERSION_INT 2003005
#endif /* WEBSOCKETSVERSION_H_ */ #endif /* WEBSOCKETSVERSION_H_ */