mirror of
https://github.com/Links2004/arduinoWebSockets.git
synced 2025-06-25 15:01:36 +02:00
Compare commits
11 Commits
2.3.2
...
esp32-ssl-
Author | SHA1 | Date | |
---|---|---|---|
f6e730c2b4 | |||
7c3b1b7408 | |||
738e43fda4 | |||
f55bf8d4ed | |||
a484da47ed | |||
4355199120 | |||
0a4fcd44c2 | |||
3a2b757155 | |||
900d81e534 | |||
0ecef8c552 | |||
410489f7c5 |
12
.github/workflows/main.yml
vendored
12
.github/workflows/main.yml
vendored
@ -25,7 +25,7 @@ jobs:
|
||||
|
||||
prepare_example_json:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: generate examples
|
||||
@ -60,7 +60,7 @@ jobs:
|
||||
env:
|
||||
IDE_VERSION: ${{ matrix.IDE_VERSION }}
|
||||
|
||||
steps:
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Get Date
|
||||
@ -121,6 +121,10 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: install libgtk2.0-0
|
||||
run: |
|
||||
sudo apt-get install -y libgtk2.0-0
|
||||
|
||||
- name: Get Date
|
||||
id: get-date
|
||||
run: |
|
||||
@ -134,7 +138,7 @@ jobs:
|
||||
/home/runner/arduino_ide
|
||||
/home/runner/Arduino
|
||||
key: ${{ runner.os }}-${{ steps.get-date.outputs.date }}-${{ matrix.ideversion }}
|
||||
|
||||
|
||||
- name: install python serial
|
||||
if: matrix.cpu == 'esp32'
|
||||
run: |
|
||||
@ -157,7 +161,7 @@ jobs:
|
||||
run: |
|
||||
mkdir -p $HOME/Arduino/libraries/
|
||||
cp -r $GITHUB_WORKSPACE $HOME/Arduino/libraries/arduinoWebSockets
|
||||
|
||||
|
||||
- name: config IDE
|
||||
run: |
|
||||
export DISPLAY=:1.0
|
||||
|
@ -21,5 +21,5 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/Links2004/arduinoWebSockets.git"
|
||||
},
|
||||
"version": "2.3.2"
|
||||
"version": "2.3.5"
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
name=WebSockets
|
||||
version=2.3.2
|
||||
version=2.3.5
|
||||
author=Markus Sattler
|
||||
maintainer=Markus Sattler
|
||||
sentence=WebSockets for Arduino (Server + Client)
|
||||
|
@ -18,31 +18,37 @@ SocketIOclient::~SocketIOclient() {
|
||||
void SocketIOclient::begin(const char * host, uint16_t port, const char * url, const char * protocol) {
|
||||
WebSocketsClient::beginSocketIO(host, port, url, protocol);
|
||||
WebSocketsClient::enableHeartbeat(60 * 1000, 90 * 1000, 5);
|
||||
initClient();
|
||||
}
|
||||
|
||||
void SocketIOclient::begin(String host, uint16_t port, String url, String protocol) {
|
||||
WebSocketsClient::beginSocketIO(host, port, url, protocol);
|
||||
WebSocketsClient::enableHeartbeat(60 * 1000, 90 * 1000, 5);
|
||||
initClient();
|
||||
}
|
||||
#if defined(HAS_SSL)
|
||||
void SocketIOclient::beginSSL(const char * host, uint16_t port, const char * url, const char * protocol) {
|
||||
WebSocketsClient::beginSocketIOSSL(host, port, url, protocol);
|
||||
WebSocketsClient::enableHeartbeat(60 * 1000, 90 * 1000, 5);
|
||||
initClient();
|
||||
}
|
||||
|
||||
void SocketIOclient::beginSSL(String host, uint16_t port, String url, String protocol) {
|
||||
WebSocketsClient::beginSocketIOSSL(host, port, url, protocol);
|
||||
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) {
|
||||
WebSocketsClient::beginSocketIOSSLWithCA(host, port, url, CA_cert, protocol);
|
||||
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) {
|
||||
WebSocketsClient::beginSocketIOSSLWithCA(host, port, url, CA_cert, protocol);
|
||||
WebSocketsClient::enableHeartbeat(60 * 1000, 90 * 1000, 5);
|
||||
initClient();
|
||||
}
|
||||
|
||||
void SocketIOclient::setSSLClientCertKey(const char * clientCert, const char * clientPrivateKey) {
|
||||
@ -55,6 +61,18 @@ void SocketIOclient::setSSLClientCertKey(BearSSL::X509List * clientCert, BearSSL
|
||||
|
||||
#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
|
||||
* @param cbEvent SocketIOclientEvent
|
||||
@ -148,8 +166,8 @@ bool SocketIOclient::sendEVENT(String & payload) {
|
||||
void SocketIOclient::loop(void) {
|
||||
WebSocketsClient::loop();
|
||||
unsigned long t = millis();
|
||||
if((t - _lastConnectionFail) > EIO_HEARTBEAT_INTERVAL) {
|
||||
_lastConnectionFail = t;
|
||||
if(!_disableHeartbeat && (t - _lastHeartbeat) > EIO_HEARTBEAT_INTERVAL) {
|
||||
_lastHeartbeat = t;
|
||||
DEBUG_WEBSOCKETS("[wsIOc] send ping\n");
|
||||
WebSocketsClient::sendTXT(eIOtype_PING);
|
||||
}
|
||||
|
@ -77,7 +77,10 @@ class SocketIOclient : protected WebSocketsClient {
|
||||
|
||||
void loop(void);
|
||||
|
||||
void configureEIOping(bool disableHeartbeat = false);
|
||||
|
||||
protected:
|
||||
bool _disableHeartbeat = false;
|
||||
uint64_t _lastHeartbeat = 0;
|
||||
SocketIOclientEvent _cbEvent;
|
||||
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
|
||||
virtual void runCbEvent(WStype_t type, uint8_t * payload, size_t length) {
|
||||
handleCbEvent(type, payload, length);
|
||||
|
@ -229,8 +229,11 @@ void WebSocketsClient::loop(void) {
|
||||
#else
|
||||
#error setCACert not implemented
|
||||
#endif
|
||||
#if defined(SSL_BARESSL)
|
||||
} else if(_fingerprint) {
|
||||
#if defined(ESP32)
|
||||
} else if(!SSL_FINGERPRINT_IS_SET) {
|
||||
_client.ssl->setInsecure();
|
||||
#elif defined(SSL_BARESSL)
|
||||
} else if(SSL_FINGERPRINT_IS_SET) {
|
||||
_client.ssl->setFingerprint(_fingerprint);
|
||||
} else {
|
||||
_client.ssl->setInsecure();
|
||||
@ -865,14 +868,14 @@ void WebSocketsClient::connectedCb() {
|
||||
|
||||
#if defined(HAS_SSL)
|
||||
#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())) {
|
||||
DEBUG_WEBSOCKETS("[WS-Client] certificate mismatch\n");
|
||||
WebSockets::clientDisconnect(&_client, 1000);
|
||||
return;
|
||||
}
|
||||
#else
|
||||
if(_client.isSSL && _fingerprint) {
|
||||
if(_client.isSSL && SSL_FINGERPRINT_IS_SET) {
|
||||
#endif
|
||||
} else if(_client.isSSL && !_CA_cert) {
|
||||
#if defined(SSL_BARESSL)
|
||||
@ -945,6 +948,9 @@ void WebSocketsClient::handleHBPing() {
|
||||
if(sendPing()) {
|
||||
_client.lastPing = millis();
|
||||
_client.pongReceived = false;
|
||||
} else {
|
||||
DEBUG_WEBSOCKETS("[WS-Client] sending HB ping failed\n");
|
||||
WebSockets::clientDisconnect(&_client, 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -112,12 +112,14 @@ class WebSocketsClient : protected WebSockets {
|
||||
#ifdef SSL_AXTLS
|
||||
String _fingerprint;
|
||||
const char * _CA_cert;
|
||||
#define SSL_FINGERPRINT_IS_SET (_fingerprint.length())
|
||||
#define SSL_FINGERPRINT_NULL ""
|
||||
#else
|
||||
const uint8_t * _fingerprint;
|
||||
BearSSL::X509List * _CA_cert;
|
||||
BearSSL::X509List * _client_cert;
|
||||
BearSSL::PrivateKey * _client_key;
|
||||
#define SSL_FINGERPRINT_IS_SET (_fingerprint != NULL)
|
||||
#define SSL_FINGERPRINT_NULL NULL
|
||||
#endif
|
||||
|
||||
|
@ -914,7 +914,7 @@ void WebSocketsServer::begin(void) {
|
||||
}
|
||||
|
||||
void WebSocketsServer::close(void) {
|
||||
WebSocketsServer::close();
|
||||
WebSocketsServerCore::close();
|
||||
#if(WEBSOCKETS_NETWORK_TYPE == NETWORK_ESP8266)
|
||||
_server->close();
|
||||
#elif(WEBSOCKETS_NETWORK_TYPE == NETWORK_ESP32) || (WEBSOCKETS_NETWORK_TYPE == NETWORK_ESP8266_ASYNC)
|
||||
|
@ -98,6 +98,8 @@ class WebSocketsServerCore : protected WebSockets {
|
||||
void loop(void); // handle client data only
|
||||
#endif
|
||||
|
||||
WSclient_t * newClient(WEBSOCKETS_NETWORK_CLASS * TCPclient);
|
||||
|
||||
protected:
|
||||
String _origin;
|
||||
String _protocol;
|
||||
@ -116,8 +118,6 @@ class WebSocketsServerCore : protected WebSockets {
|
||||
uint32_t _pongTimeout;
|
||||
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 clientDisconnect(WSclient_t * client);
|
||||
|
@ -1,6 +1,6 @@
|
||||
/**
|
||||
* @file WebSocketsVersion.h
|
||||
* @date 07.01.2021
|
||||
* @date 09.02.2021
|
||||
* @author Markus Sattler
|
||||
*
|
||||
* Copyright (c) 2015 Markus Sattler. All rights reserved.
|
||||
@ -25,12 +25,12 @@
|
||||
#ifndef 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_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_ */
|
||||
|
Reference in New Issue
Block a user