diff options
author | turret <turret@duck.com> | 2024-01-12 19:43:15 +0000 |
---|---|---|
committer | turret <turret@duck.com> | 2024-01-12 19:43:15 +0000 |
commit | 7da85e6f9b6e9a694eb2faef5c1779c83b9efe3c (patch) | |
tree | 7a0758c84051c2809a72f8a3ed5acafb36a05bea /net | |
parent | dfb0d84c8113629f1af0fa39519a38c4c48f7140 (diff) | |
download | discord-bot-skeleton-7da85e6f9b6e9a694eb2faef5c1779c83b9efe3c.tar.gz discord-bot-skeleton-7da85e6f9b6e9a694eb2faef5c1779c83b9efe3c.tar.bz2 discord-bot-skeleton-7da85e6f9b6e9a694eb2faef5c1779c83b9efe3c.zip |
net: format WSS url properly
libcurl requires first 3 characters of a wss url
(i.e. wss://example.com) to be capital, so instead WSS://example.com.
so we modify the assume url to use WSS and ensure the returned URL from
discord uses the WSS capital scheme
Diffstat (limited to 'net')
-rw-r--r-- | net/net.c | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -56,20 +56,23 @@ void net_get_gateway_url() goto assume; } - char *gateway_url = calloc(strlen(gateway_url_json->valuestring) + 1, + gateway_url = calloc(strlen(gateway_url_json->valuestring) + 1, sizeof(char)); strcpy(gateway_url, gateway_url_json->valuestring); + gateway_url[0] = 'W'; + gateway_url[1] = 'S'; + gateway_url[2] = 'S'; + print(LOG_DEBUG "net: using gateway url %s", gateway_url); - free(gateway_url); cJSON_Delete(gateway_info); return; assume: - print(LOG_DEBUG "net: assuming gateway url wss://gateway.discord.gg"); - gateway_url = calloc(strlen("wss://gateway.discord.gg") + 1, + print(LOG_DEBUG "net: assuming gateway url WSS://gateway.discord.gg"); + gateway_url = calloc(strlen("WSS://gateway.discord.gg") + 1, sizeof(char)); - strcpy(gateway_url, "wss://gateway.discord.gg"); + strcpy(gateway_url, "WSS://gateway.discord.gg"); return; } l1_initcall(net_get_gateway_url); |