Adapt WSS to new boards and use MQTT domain for eSIM connectivity
Preserve main GNSS and volume behavior while porting verified TLS, receive fixes and full-handshake optimizations. Add MQTT connection diagnostics and route MQTT through banban.api.talkingq.com:1883. Include migration documentation and regression tools. Firmware builds and package checks passed; user confirmed new-board connectivity after switching the MQTT host to the domain.
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
#include "talkingq_wss.h"
|
||||
#include <string.h>
|
||||
|
||||
int talkingq_is_legacy_ws_url(const char *url)
|
||||
{
|
||||
return url && (!strcmp(url, "ws://101.35.224.118:8080") ||
|
||||
!strcmp(url, "ws://101.35.224.118:8080/ws") ||
|
||||
!strcmp(url, "ws://api.talkingq.com:8080") ||
|
||||
!strcmp(url, "ws://175.24.73.253:80"));
|
||||
}
|
||||
|
||||
int talkingq_parse_wss_url(const char *url, char *host, size_t host_size,
|
||||
int *port, char *path, size_t path_size)
|
||||
{
|
||||
const char *begin, *end, *colon, *cursor, *resource;
|
||||
size_t length;
|
||||
unsigned int value = 0;
|
||||
if (!url || !host || !port || !path || strncmp(url, "wss://", 6))
|
||||
return -1;
|
||||
begin = url + 6;
|
||||
end = strchr(begin, '/');
|
||||
if (!end) end = begin + strlen(begin);
|
||||
colon = memchr(begin, ':', (size_t)(end - begin));
|
||||
length = (size_t)((colon ? colon : end) - begin);
|
||||
if (!length || length >= host_size) return -1;
|
||||
for (cursor = begin; cursor < begin + length; ++cursor) {
|
||||
char c = *cursor;
|
||||
if (!((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') ||
|
||||
(c >= '0' && c <= '9') || c == '.' || c == '-')) return -1;
|
||||
}
|
||||
if (colon) {
|
||||
if (colon + 1 == end) return -1;
|
||||
for (cursor = colon + 1; cursor < end; ++cursor) {
|
||||
if (*cursor < '0' || *cursor > '9') return -1;
|
||||
value = value * 10 + (unsigned int)(*cursor - '0');
|
||||
if (value > 65535) return -1;
|
||||
}
|
||||
if (!value) return -1;
|
||||
} else {
|
||||
value = 443;
|
||||
}
|
||||
resource = *end ? end : "/ws";
|
||||
if (strlen(resource) >= path_size) return -1;
|
||||
for (cursor = resource; *cursor; ++cursor) {
|
||||
if ((unsigned char)*cursor <= 32 || *cursor == '#' ||
|
||||
(unsigned char)*cursor >= 127) return -1;
|
||||
}
|
||||
memcpy(host, begin, length);
|
||||
host[length] = '\0';
|
||||
strcpy(path, resource);
|
||||
*port = (int)value;
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user