Add support for choosing network service (incl Pretendo+Custom) (#302)

This commit is contained in:
MythicalPlayz 2022-10-11 04:04:47 +02:00 committed by GitHub
parent 52cc7c5996
commit b07e9efba4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 345 additions and 22 deletions

View file

@ -10,6 +10,7 @@
#include <fstream>
#include "config/ActiveSettings.h"
#include "config/NetworkSettings.h"
#include "curl/curl.h"
#include "openssl/bn.h"
#include "openssl/x509.h"
@ -497,9 +498,13 @@ namespace iosu
curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, task_header_callback);
curl_easy_setopt(curl, CURLOPT_HEADERDATA, &(*it));
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 0x3C);
if (GetNetworkConfig().disablesslver.GetValue() && ActiveSettings::GetNetworkService() == NetworkService::Custom || ActiveSettings::GetNetworkService() == NetworkService::Pretendo){ //Remove Pretendo Function once SSL is in the Service
curl_easy_setopt(curl,CURLOPT_SSL_VERIFYPEER,0L);
} else {
curl_easy_setopt(curl, CURLOPT_SSL_CTX_FUNCTION, task_sslctx_function);
curl_easy_setopt(curl, CURLOPT_SSL_CTX_DATA, &it->task_settings);
curl_easy_setopt(curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_0);
}
char url[512];
if(it->task_settings.taskType == kRawDlTaskSetting)
@ -561,8 +566,21 @@ namespace iosu
char boss_code[0x20];
strncpy(boss_code, (char*)&it->task_settings.settings[TaskSetting::kBossCode], TaskSetting::kBossCodeLen);
sprintf(url, "https://npts.app.nintendo.net/p01/tasksheet/%s/%s/%s?c=%s&l=%s", "1", boss_code, it->task_id, countryCode, languageCode);
switch (ActiveSettings::GetNetworkService())
{
case NetworkService::Nintendo:
sprintf(url, NintendoURLs::BOSSURL.append("/%s/%s/%s?c=%s&l=%s").c_str(), "1", boss_code, it->task_id, countryCode, languageCode);
break;
case NetworkService::Pretendo:
sprintf(url, PretendoURLs::BOSSURL.append("/%s/%s/%s?c=%s&l=%s").c_str(), "1", boss_code, it->task_id, countryCode, languageCode);
break;
case NetworkService::Custom:
sprintf(url, GetNetworkConfig().urls.BOSS.GetValue().append("/%s/%s/%s?c=%s&l=%s").c_str(), "1", boss_code, it->task_id, countryCode, languageCode);
break;
default:
sprintf(url, NintendoURLs::BOSSURL.append("/%s/%s/%s?c=%s&l=%s").c_str(), "1", boss_code, it->task_id, countryCode, languageCode);
break;
}
}
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, list_headerParam);