aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorturret <turret@duck.com>2023-12-18 15:38:55 -0600
committerturret <turret@duck.com>2023-12-18 15:38:55 -0600
commitbbf9af905b0a93367a6ba49bd60d83e2cf20cb56 (patch)
tree4acaa6f079701d9312eee14a497f7d3b7e5170fa
parentc2dc21b3e454f7e27d9456fddb4d26e0bfed39fa (diff)
downloaddiscord-bot-skeleton-bbf9af905b0a93367a6ba49bd60d83e2cf20cb56.tar.gz
discord-bot-skeleton-bbf9af905b0a93367a6ba49bd60d83e2cf20cb56.tar.bz2
discord-bot-skeleton-bbf9af905b0a93367a6ba49bd60d83e2cf20cb56.zip
net: panic if wss not supported by libcurl
-rw-r--r--net/net.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/net/net.c b/net/net.c
index 9ed4653..fada07c 100644
--- a/net/net.c
+++ b/net/net.c
@@ -16,12 +16,22 @@ int net_subsystem(void)
{
print(LOG_INFO "net: starting net subsystem");
-
return 0;
}
void net_get_gateway_url()
{
+ curl_version_info_data *curl_version = curl_version_info(CURLVERSION_NOW);
+ const char * const* curl_protocols = curl_version->protocols;
+ int wss_supported = 0;
+ for(int i = 0; curl_protocols[i]; ++i) {
+ if(strcmp(curl_protocols[i], "wss") == 0)
+ wss_supported = 1;
+ }
+
+ if(!wss_supported)
+ panic("net: wss not supported by libcurl");
+
int fd = http_get("https://discord.com/api/gateway/bot");
if(fd < 0) {
print(LOG_ERR "net: failed to get gateway url (error %d)", -fd);