Add MQTT exception for private IP address server (#5072)

Determines if the given IP address is a private address, i.e. not routable on the public internet.
These are the ranges: 127.0.0.1, 10.0.0.0-10.255.255.255, 172.16.0.0-172.31.255.255, 192.168.0.0-192.168.255.255.

If so, allow MQTT publication the same as existing localhost support.
This commit is contained in:
Johnathon Mohr
2024-10-15 17:08:49 -07:00
committed by GitHub
parent 25b557cf46
commit ad214ea42a
2 changed files with 38 additions and 2 deletions

View File

@@ -120,6 +120,10 @@ class MQTT : private concurrency::OSThread
// returns true if this is a valid JSON envelope which we accept on downlink
bool isValidJsonEnvelope(JSONObject &json);
/// Determines if the given IP address is a private address, i.e. not routable on the public internet.
/// These are the ranges: 127.0.0.1, 10.0.0.0-10.255.255.255, 172.16.0.0-172.31.255.255, 192.168.0.0-192.168.255.255.
bool isPrivateIpAddress(const char ip[]);
/// Return 0 if sleep is okay, veto sleep if we are connected to pubsub server
// int preflightSleepCb(void *unused = NULL) { return pubSub.connected() ? 1 : 0; }
};