Added support for SSL verification on non-iOS and added Discord RPC setting to configuration

This commit is contained in:
2025-09-26 03:28:44 +10:00
parent 6bd1fc943e
commit e95b3e0789
3 changed files with 37 additions and 3 deletions

View File

@@ -37,6 +37,8 @@ int configHandler_Read(configHandler_config_t** configObj) {
(*configObj)->lastfm_api_key = NULL; (*configObj)->lastfm_api_key = NULL;
(*configObj)->lastfm_api_secret = NULL; (*configObj)->lastfm_api_secret = NULL;
(*configObj)->lastfm_api_session_key = NULL; (*configObj)->lastfm_api_session_key = NULL;
(*configObj)->discordrpc_enable = false;
(*configObj)->discordrpc_method = 0;
(*configObj)->audio_equalizer_enable = false; (*configObj)->audio_equalizer_enable = false;
(*configObj)->audio_equalizer_followPitch = false; (*configObj)->audio_equalizer_followPitch = false;
(*configObj)->audio_equalizer_graphCount = 0; (*configObj)->audio_equalizer_graphCount = 0;
@@ -53,7 +55,7 @@ int configHandler_Read(configHandler_config_t** configObj) {
// Form the path to the config JSON // Form the path to the config JSON
char* config_path = NULL; char* config_path = NULL;
#if defined(__APPLE__) && defined(__MACH__) #if defined(__APPLE__) && defined(__MACH__) && defined(XCODE)
// NOTE: This is a relatively hacky way of fetching the iOS container path without diving into the hell that is ObjC // NOTE: This is a relatively hacky way of fetching the iOS container path without diving into the hell that is ObjC
char* root_path = getenv("HOME"); char* root_path = getenv("HOME");
rc = asprintf(&config_path, "%s/Documents/config.json", root_path); rc = asprintf(&config_path, "%s/Documents/config.json", root_path);
@@ -62,7 +64,7 @@ int configHandler_Read(configHandler_config_t** configObj) {
#endif // DEBUG #endif // DEBUG
#else #else
rc = asprintf(&config_path, "config.json"); rc = asprintf(&config_path, "config.json");
#endif // defined(__APPLE__) && defined(__MACH__) #endif // defined(__APPLE__) && defined(__MACH__) && defined(XCODE)
if (rc == -1) { if (rc == -1) {
logger_log_error(__func__, "asprintf() failed (Could not generate config path)."); logger_log_error(__func__, "asprintf() failed (Could not generate config path).");
free(config_path); free(config_path);
@@ -201,6 +203,26 @@ int configHandler_Read(configHandler_config_t** configObj) {
(*configObj)->lastfm_api_session_key = strdup(scrobbler_lastfm_api_session_key->valuestring); (*configObj)->lastfm_api_session_key = strdup(scrobbler_lastfm_api_session_key->valuestring);
} }
// Make an object from discord-rpc
cJSON* discordrpc_root = cJSON_GetObjectItemCaseSensitive(root, "discord_rpc");
if (discordrpc_root == NULL) {
logger_log_error(__func__, "Error parsing JSON - discord-rpc does not exist.");
cJSON_Delete(root);
return 1;
}
cJSON* discordrpc_enable = cJSON_GetObjectItemCaseSensitive(discordrpc_root, "enable");
if (cJSON_IsBool(discordrpc_enable)) {
if (cJSON_IsTrue(discordrpc_enable)) {
(*configObj)->discordrpc_enable = true;
}
}
cJSON* discordrpc_method = cJSON_GetObjectItemCaseSensitive(discordrpc_root, "method");
if (cJSON_IsNumber(discordrpc_method)) {
(*configObj)->discordrpc_method = discordrpc_method->valueint;
}
// Make an object from audio // Make an object from audio
cJSON* audio_root = cJSON_GetObjectItemCaseSensitive(root, "audio"); cJSON* audio_root = cJSON_GetObjectItemCaseSensitive(root, "audio");
if (audio_root == NULL) { if (audio_root == NULL) {

View File

@@ -30,6 +30,10 @@ typedef struct {
char* lastfm_api_secret; // LastFM API Secret char* lastfm_api_secret; // LastFM API Secret
char* lastfm_api_session_key; // LastFM API Session Key (Generated from authorization endpoint) char* lastfm_api_session_key; // LastFM API Session Key (Generated from authorization endpoint)
// Discord RPC Settings
bool discordrpc_enable; // Enable Discord RPC
int discordrpc_method; // Discord RPC Method (0 = Regular, 1 = DscrdRPC)
// Audio Settings // Audio Settings
bool audio_equalizer_enable; bool audio_equalizer_enable;
bool audio_equalizer_followPitch; // Have equalizer align to pitch adjustment bool audio_equalizer_followPitch; // Have equalizer align to pitch adjustment

View File

@@ -412,8 +412,16 @@ void UNIX_HttpRequest(opensubsonic_httpClientRequest_t** httpReq) {
curl_easy_setopt(curl_handle, CURLOPT_URL, (*httpReq)->requestUrl); curl_easy_setopt(curl_handle, CURLOPT_URL, (*httpReq)->requestUrl);
curl_easy_setopt(curl_handle, CURLOPT_MAXREDIRS, 50L); curl_easy_setopt(curl_handle, CURLOPT_MAXREDIRS, 50L);
curl_easy_setopt(curl_handle, CURLOPT_TCP_KEEPALIVE,0L); curl_easy_setopt(curl_handle, CURLOPT_TCP_KEEPALIVE,0L);
// Do not use SSL verification on iOS due to an SSL issue with using libcurl on iOS
#if defined(__APPLE__) && defined(__MACH__) && defined(XCODE)
curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0L); curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0L);
curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 0L); curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 0L);
#else
curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 1L);
curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 1L);
#endif // defined(__APPLE__) && defined(__MACH__) && defined(XCODE)
curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, write_to_memory); curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, write_to_memory);
curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)&chunk); curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)&chunk);
CURLcode res = curl_easy_perform(curl_handle); CURLcode res = curl_easy_perform(curl_handle);