Skip to content

Commit

Permalink
Update Readme and SSLClient.
Browse files Browse the repository at this point in the history
  • Loading branch information
mobizt committed Aug 25, 2023
1 parent 54964aa commit edbc9c1
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 19 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -946,11 +946,13 @@ param **`pageSize`** (integer) The maximum number of files to return per page.

param **`orderBy`** (string) A comma-separated list of sort keys.

Note: Valid keys are 'createdTime', 'folder', 'modifiedByMeTime', 'modifiedTime', 'name', 'name_natural', 'quotaBytesUsed', 'recency', 'sharedWithMeTime', 'starred', and 'viewedByMeTime'.
Note: Valid keys are `createdTime`, `folder`, `modifiedByMeTime`, `modifiedTime`, `name`, `name_natural`, `quotaBytesUsed`, `recency`, `sharedWithMeTime`, `starred`, and `viewedByMeTime`.

Each key sorts ascending by default, but may be reversed with the 'desc' modifier.
Each key sorts ascending by default, but may be reversed with the `desc` modifier.

Example usage: ?orderBy=folder,modifiedTime desc,name.
Example usage: `folder,modifiedTime%20desc,name` which the white space need to be replaceed with `%20` as this parameter is used as the URI parameter of Google Drive API request endpoint.

Please consult [Google Drive API doc](https://developers.google.com/drive/api/reference/rest/v3/files/list) for the more detail.

param **`pageToken`** (string) The token for continuing a previous list request on the next page.

Expand Down
37 changes: 33 additions & 4 deletions src/client/SSLClient/ESP_SSLClient.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
*
* The ESP SSL Client Class, ESP_SSLClient.h v2.1.3
* The ESP SSL Client Class, ESP_SSLClient.h v2.1.5
*
* Created August 13, 2023
* Created August 22, 2023
*
* The MIT License (MIT)
* Copyright (c) 2023 K. Suwatchai (Mobizt)
Expand Down Expand Up @@ -38,13 +38,42 @@
#if defined(USE_EMBED_SSL_ENGINE) || defined(USE_LIB_SSL_ENGINE)
#include "client/BSSL_TCP_Client.h"
class ESP_SSLClient : public BSSL_TCP_Client
{
public:
ESP_SSLClient(){};
~ESP_SSLClient(){};
};

class ESP_SSLClient2 : public BSSL_TCP_Client
{
public:
ESP_SSLClient2(Client &client, bool enableSSL = true) : _base_client(client)
{
setClient(&_base_client, enableSSL);
};
~ESP_SSLClient2(){};

private:
Client &_base_client;
};

#else
class ESP_SSLClient
#endif
{
public:
ESP_SSLClient(){};
~ESP_SSLClient(){};
};

#endif
class ESP_SSLClient2
{
public:
ESP_SSLClient2(Client &client, bool enableSSL = true) : _base_client(client){};
~ESP_SSLClient2(){};

private:
Client &_base_client;
};
#endif

#endif
43 changes: 40 additions & 3 deletions src/client/SSLClient/client/BSSL_SSL_Client.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* BSSL_SSL_Client library v1.0.9 for Arduino devices.
* BSSL_SSL_Client library v1.0.10 for Arduino devices.
*
* Created August 13, 2003
* Created August 22, 2003
*
* This work contains codes based on WiFiClientSecure from Earle F. Philhower and SSLClient from OSU OPEnS Lab.
*
Expand Down Expand Up @@ -194,6 +194,16 @@ uint8_t BSSL_SSL_Client::connected()
return c_con && br_con;
}

void BSSL_SSL_Client::validate(const char *host, uint16_t port)
{
mConnectionValidate(host, IPAddress(), port);
}

void BSSL_SSL_Client::validate(IPAddress ip, uint16_t port)
{
mConnectionValidate(nullptr, ip, port);
}

int BSSL_SSL_Client::available()
{
if (!mIsClientInitialized(false))
Expand Down Expand Up @@ -425,9 +435,14 @@ int BSSL_SSL_Client::connectSSL(IPAddress ip, uint16_t port)
if (!mIsClientInitialized(true))
return 0;

validate(ip, port);

if (!_basic_client->connected() && !mConnectBasicClient(nullptr, ip, port))
return 0;

_ip = ip;
_port = port;

return mConnectSSL(nullptr);
}

Expand All @@ -437,9 +452,14 @@ int BSSL_SSL_Client::connectSSL(const char *host, uint16_t port)
if (!mIsClientInitialized(true))
return 0;

validate(host, port);

if (!_basic_client->connected() && !mConnectBasicClient(host, IPAddress(), port))
return 0;

_host = host;
_port = port;

return mConnectSSL(host);
}

Expand Down Expand Up @@ -1374,7 +1394,8 @@ int BSSL_SSL_Client::mIsClientInitialized(bool notify)

int BSSL_SSL_Client::mConnectBasicClient(const char *host, IPAddress ip, uint16_t port)
{
if (!mIsClientInitialized(true))

if (!mConnectionValidate(host, ip, port))
return 0;

if (!(host ? _basic_client->connect(host, port) : _basic_client->connect(ip, port)))
Expand Down Expand Up @@ -1570,6 +1591,22 @@ int BSSL_SSL_Client::mConnectSSL(const char *host)
return 1;
}

bool BSSL_SSL_Client::mConnectionValidate(const char *host, IPAddress ip, uint16_t port)
{
if (!mIsClientInitialized(true))
return false;

if (_basic_client && _basic_client->connected() &&
host
? (strcasecmp(host, _host.c_str()) != 0 || port != _port)
: (ip != _ip || port != _port))
{
_basic_client->stop();
}

return true;
}

int BSSL_SSL_Client::mRunUntil(const unsigned target, unsigned long timeout)
{
unsigned lastState = 0;
Expand Down
15 changes: 13 additions & 2 deletions src/client/SSLClient/client/BSSL_SSL_Client.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* BSSL_SSL_Client library v1.0.9 for Arduino devices.
* BSSL_SSL_Client library v1.0.10 for Arduino devices.
*
* Created August 13, 2003
* Created August 22, 2003
*
* This work contains codes based on WiFiClientSecure from Earle F. Philhower and SSLClient from OSU OPEnS Lab.
*
Expand Down Expand Up @@ -98,6 +98,10 @@ class BSSL_SSL_Client : public Client

uint8_t connected() override;

void validate(const char* host, uint16_t port);

void validate(IPAddress ip, uint16_t port);

int available() override;

int read() override;
Expand All @@ -124,6 +128,8 @@ class BSSL_SSL_Client : public Client

int connectSSL(const char *host, uint16_t port);



void stop() override;

void setTimeout(unsigned int timeoutMs);
Expand Down Expand Up @@ -234,6 +240,8 @@ class BSSL_SSL_Client : public Client

int mConnectSSL(const char *host = nullptr);

bool mConnectionValidate(const char *host, IPAddress ip, uint16_t port);

int mRunUntil(const unsigned target, unsigned long timeout = 0);

unsigned mUpdateEngine();
Expand Down Expand Up @@ -333,6 +341,9 @@ class BSSL_SSL_Client : public Client
unsigned long _timeout = 15000;
unsigned long _handshake_timeout = 60000;
bool _isSSLEnabled = false;
String _host;
uint16_t _port;
IPAddress _ip;
};

#endif
Expand Down
14 changes: 12 additions & 2 deletions src/client/SSLClient/client/BSSL_TCP_Client.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* BSSL_TCP_Client v2.0.10 for Arduino devices.
* BSSL_TCP_Client v2.0.11 for Arduino devices.
*
* Created August 13, 2023
* Created August 22, 2023
*
* The MIT License (MIT)
* Copyright (c) 2023 K. Suwatchai (Mobizt)
Expand Down Expand Up @@ -134,6 +134,16 @@ uint8_t BSSL_TCP_Client::connected()
return _ssl_client.connected();
}

void BSSL_TCP_Client::validate(const char *host, uint16_t port)
{
_ssl_client.validate(host, port);
}

void BSSL_TCP_Client::validate(IPAddress ip, uint16_t port)
{
_ssl_client.validate(ip, port);
}

int BSSL_TCP_Client::available()
{
return _ssl_client.available();
Expand Down
26 changes: 21 additions & 5 deletions src/client/SSLClient/client/BSSL_TCP_Client.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* BSSL_TCP_Client v2.0.10 for Arduino devices.
* BSSL_TCP_Client v2.0.11 for Arduino devices.
*
* Created August 13, 2023
* Created August 22, 2023
*
* The MIT License (MIT)
* Copyright (c) 2023 K. Suwatchai (Mobizt)
Expand Down Expand Up @@ -103,7 +103,7 @@ class BSSL_TCP_Client : public Client
/**
* Connect to server.
* @param ip The server IP to connect.
* @param port The server port to connecte.
* @param port The server port to connect.
* @param timeout The connection time out in miiliseconds.
* @return 1 for success or 0 for error.
*/
Expand All @@ -112,15 +112,15 @@ class BSSL_TCP_Client : public Client
/**
* Connect to server.
* @param host The server host name.
* @param port The server port to connecte.
* @param port The server port to connect.
* @return 1 for success or 0 for error.
*/
int connect(const char *host, uint16_t port) override;

/**
* Connect to server.
* @param host The server host name.
* @param port The server port to connecte.
* @param port The server port to connect.
* @param timeout The connection time out in miiliseconds.
* @return 1 for success or 0 for error.
*/
Expand All @@ -132,6 +132,22 @@ class BSSL_TCP_Client : public Client
*/
uint8_t connected() override;

/**
* Validate the last Client connection with these host and port.
* @param host The server host name.
* @param port The server port to connect.
* The Client connection will be closed when the provided host or port is not match with that of last connection.
*/
void validate(const char *host, uint16_t port);

/**
* Validate the last Client connection with these IP and port.
* @param ip The server IP to connect.
* @param port The server port to connect.
* The Client connection will be closed when the provided IP or port is not match with that of last connection.
*/
void validate(IPAddress ip, uint16_t port);

/**
* Get available data size to read.
* @return The avaiable data size.
Expand Down

0 comments on commit edbc9c1

Please sign in to comment.