Skip to content

Commit

Permalink
Added protocol check in the MqttClient (#1410)
Browse files Browse the repository at this point in the history
  • Loading branch information
frankdownunder authored and slaff committed Jul 9, 2018
1 parent 49d9f2a commit ade49d3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Sming/SmingCore/Network/MqttClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ bool MqttClient::setWill(const String& topic, const String& message, int QoS, bo
bool MqttClient::connect(const URL& url, const String& clientName, uint32_t sslOptions)
{
this->url = url;
if (not (url.Protocol == "mqtt" || url.Protocol == "mqtts")) {
debug_e("Only mqtt and mqtts protocols are allowed");
return false;
}
waitingSize = 0;
posHeader = 0;
current = NULL;
Expand Down
2 changes: 1 addition & 1 deletion Sming/SmingCore/Network/MqttClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class MqttClient: protected TcpClient
bool setWill(const String& topic, const String& message, int QoS, bool retained = false);

/** @brief Connect to a MQTT server
* @param url, in the form "mttqs://user:password@server:port"
* @param url, in the form "mqtt://user:password@server:port" or "mqtts://user:password@server:port"
* @param client name
*/
bool connect(const URL& url, const String& uniqueClientName, uint32_t sslOptions = 0);
Expand Down

0 comments on commit ade49d3

Please sign in to comment.