mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-24 09:26:52 +00:00
This reverts commit 398d29064e
.
This commit is contained in:
parent
f39a9c5083
commit
d9b287880f
@ -231,16 +231,6 @@ bool isPrivateIpAddress(const IPAddress &ip)
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<std::string, uint16_t> parseHostAndPort(std::string address, uint16_t port = 0)
|
|
||||||
{
|
|
||||||
const size_t delimIndex = address.find_first_of(':');
|
|
||||||
if (delimIndex > 0) {
|
|
||||||
port = std::stoul(address.substr(delimIndex + 1, address.length()));
|
|
||||||
address.resize(delimIndex);
|
|
||||||
}
|
|
||||||
return std::make_pair(std::move(address), port);
|
|
||||||
}
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void MQTT::mqttCallback(char *topic, byte *payload, unsigned int length)
|
void MQTT::mqttCallback(char *topic, byte *payload, unsigned int length)
|
||||||
@ -318,8 +308,7 @@ MQTT::MQTT() : concurrency::OSThread("mqtt"), mqttQueue(MAX_MQTT_QUEUE)
|
|||||||
}
|
}
|
||||||
|
|
||||||
IPAddress ip;
|
IPAddress ip;
|
||||||
isMqttServerAddressPrivate =
|
isMqttServerAddressPrivate = ip.fromString(moduleConfig.mqtt.address) && isPrivateIpAddress(ip);
|
||||||
ip.fromString(parseHostAndPort(moduleConfig.mqtt.address).first.c_str()) && isPrivateIpAddress(ip);
|
|
||||||
|
|
||||||
#if HAS_NETWORKING
|
#if HAS_NETWORKING
|
||||||
if (!moduleConfig.mqtt.proxy_to_client_enabled)
|
if (!moduleConfig.mqtt.proxy_to_client_enabled)
|
||||||
@ -435,9 +424,14 @@ void MQTT::reconnect()
|
|||||||
pubSub.setClient(mqttClient);
|
pubSub.setClient(mqttClient);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::pair<std::string, uint16_t> hostAndPort = parseHostAndPort(serverAddr, serverPort);
|
String server = String(serverAddr);
|
||||||
serverAddr = hostAndPort.first.c_str();
|
int delimIndex = server.indexOf(':');
|
||||||
serverPort = hostAndPort.second;
|
if (delimIndex > 0) {
|
||||||
|
String port = server.substring(delimIndex + 1, server.length());
|
||||||
|
server[delimIndex] = 0;
|
||||||
|
serverPort = port.toInt();
|
||||||
|
serverAddr = server.c_str();
|
||||||
|
}
|
||||||
pubSub.setServer(serverAddr, serverPort);
|
pubSub.setServer(serverAddr, serverPort);
|
||||||
pubSub.setBufferSize(512);
|
pubSub.setBufferSize(512);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user