Skip to content

Commit

Permalink
Fix validate issue when no basic client assigned.
Browse files Browse the repository at this point in the history
  • Loading branch information
mobizt committed Aug 23, 2023
1 parent ecf4cc9 commit ce575f0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 9 additions & 5 deletions src/client/BSSL_SSL_Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1394,10 +1394,9 @@ int BSSL_SSL_Client::mIsClientInitialized(bool notify)

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

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

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

void BSSL_SSL_Client::mConnectionValidate(const char *host, IPAddress ip, uint16_t port)
bool BSSL_SSL_Client::mConnectionValidate(const char *host, IPAddress ip, uint16_t port)
{
if (_basic_client->connected() &&
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)
Expand Down
2 changes: 1 addition & 1 deletion src/client/BSSL_SSL_Client.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ class BSSL_SSL_Client : public Client

int mConnectSSL(const char *host = nullptr);

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

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

Expand Down

0 comments on commit ce575f0

Please sign in to comment.