Update config to use the new online servers & remove hardcoded certificate (#3703)
* Update config to use the new online servers. Remove hardcoded certificate as we will use Let's encrypt from now on * Fix new server SSL curl certificate by shipping CA bundle from https://curl.haxx.se/docs/caextract.html * Remove debug log for curl host * Move server config to stk_config.xml and Update news.xml redirects
This commit is contained in:
parent
2d219f29cc
commit
edd1280dbc
@ -4,7 +4,7 @@
|
||||
First of all, you can compile STK with `-DSERVER_ONLY=ON` which will produce a GUI-less STK binary optimized for size and memory usage, useful for situation like in VPS.
|
||||
|
||||
### Hosting WAN (public internet) server
|
||||
You are required to have an stk online account first, go [here](https://addons.supertuxkart.net/register.php) for registration.
|
||||
You are required to have an stk online account first, go [here](https://online.supertuxkart.net/register.php) for registration.
|
||||
|
||||
It is recommended you have a saved user in your computer to allow hosting multiple servers simultaneously with the same account, if you have a fresh STK installation, first run:
|
||||
|
||||
@ -178,7 +178,7 @@ There is a network AI tester in STK which can use AI on player controller for se
|
||||
|
||||
x.x.x.x:y is your server ip address with its port, id is the id field of server-info in STK server xml list, omit it if you are testing LAN server, n is the number of AI you want to create.
|
||||
|
||||
You can see STK server xml list [here](https://addons.supertuxkart.net/api/v2/server/get-all).
|
||||
You can see STK server xml list [here](https://online.supertuxkart.net/api/v2/server/get-all).
|
||||
|
||||
You can remove `--auto-connect` if you have another client which can control the starting of games in server, or you can consider enable owner-less mode on server so the games on server can keep going. Remove `--no-graphics` if you want to see the AI racing. You can also run network AI tester in server-only build of STK.
|
||||
|
||||
|
@ -1,21 +0,0 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDezCCAmOgAwIBAgIJAO+A8uXtEMRsMA0GCSqGSIb3DQEBCwUAMFQxCzAJBgNV
|
||||
BAYTAlVTMQwwCgYDVQQIDANTVEsxFTATBgNVBAoMDFN1cGVyVHV4S2FydDEgMB4G
|
||||
A1UEAwwXYWRkb25zLnN1cGVydHV4a2FydC5uZXQwHhcNMTQxMjEwMTEzMTAwWhcN
|
||||
MjQxMjA3MTEzMTAwWjBUMQswCQYDVQQGEwJVUzEMMAoGA1UECAwDU1RLMRUwEwYD
|
||||
VQQKDAxTdXBlclR1eEthcnQxIDAeBgNVBAMMF2FkZG9ucy5zdXBlcnR1eGthcnQu
|
||||
bmV0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2ysZE9rb4y0tHOhk
|
||||
wxYpqsvDv5LCRFTAeyfAfyBVDcOn+4A3sX8MkQdoH/QDi823z4bn9ZsGV8T444FN
|
||||
S4yK/aSRv3eAKkkJm5TUxbs3crATVt3JYusMr5W4wHvRVyDe0DlulSdW4EUEklMP
|
||||
iPat/jwlDZRvZueio3wJoOhZXnl8E8EfnuYtlNONIB1nYGdUHD9xeNyKSPr4zTEp
|
||||
brjvSw0l5G88LmQOROQBDbTDknAcIQwsFT1mf9Bt+N9LK14r95GWRmL3ZtfbrJn4
|
||||
ZEfkOjl0Abv6gET4sQOXv0KioUdEJwzFCwKFLZVcuOrscmcHBOhgD3EruVvprIJ0
|
||||
wZ3z1wIDAQABo1AwTjAdBgNVHQ4EFgQUmQwaPsD+ylVUUsUXMAYpUlnVbNwwHwYD
|
||||
VR0jBBgwFoAUmQwaPsD+ylVUUsUXMAYpUlnVbNwwDAYDVR0TBAUwAwEB/zANBgkq
|
||||
hkiG9w0BAQsFAAOCAQEASyl6BMpnZhJlirDL84/RkVeVjBkr7x68UFAblmKjgfGg
|
||||
pRbYPNSld0IrfZ4pcrDAUkg9WJb0Zxuh0oYiV+RjdW/6s5mF/qiSv8V60xb2myRd
|
||||
z90ZGfhB5SAECI5zfIZSmsMjOEjKjuz8S26aEtJe8Vq7GF2P7/889lfNXrbvIkZX
|
||||
HQpx2P+T07zy++6Ca/K2vmWcf1a+GrN+o0nZTYbz/2r/JJwXdWqT1ZmtEA9GNwvZ
|
||||
J8HhgvspgjgVP/EURUUhOaQ8zfhriU5CJAIuhMhzW7oOBPHxxtxme3auAfxi5zpK
|
||||
wRNluCayrrjhy2I8mABRnBqgMwAQUIrgk9IU6SyQxw==
|
||||
-----END CERTIFICATE-----
|
3218
data/cacert.pem
Normal file
3218
data/cacert.pem
Normal file
File diff suppressed because it is too large
Load Diff
@ -18,6 +18,27 @@
|
||||
positions for those additional karts. -->
|
||||
<karts max-number="20"/>
|
||||
|
||||
<!-- Everything related to hardware configuration.
|
||||
url : The server used for reporting statistics to.
|
||||
// TODO change new-stats to stats before release-->
|
||||
<HardwareReportServer url="https://new-stats.supertuxkart.net" />>
|
||||
|
||||
<!-- Everything related to online play.
|
||||
url: The server used for online multiplayer.
|
||||
server-version : Version of the server API to use. -->
|
||||
<OnlineServer
|
||||
url="https://online.supertuxkart.net/api/"
|
||||
server-version="2"
|
||||
/>
|
||||
|
||||
<!-- Addon and news related settings
|
||||
url : The server used for addon.
|
||||
allow-news-redirects : If true we allow all the server urls to be redirected by the addons news.xml file-->
|
||||
<AddonServer
|
||||
url="https://online.supertuxkart.net/dl/xml"
|
||||
allow-news-redirects="true"
|
||||
/>
|
||||
|
||||
<!-- Scores are the number of points given when the race ends. -->
|
||||
<grand-prix>
|
||||
<!-- Establish the distribution of points in GP.
|
||||
@ -157,7 +178,7 @@
|
||||
<minimap size="180.0" ai-icon="16.0" player-icon="20.0"/>
|
||||
|
||||
<urls donate="https://supertuxkart.net/Donate"
|
||||
password-reset="http://addons.supertuxkart.net/password-reset.php" />
|
||||
password-reset="https://online.supertuxkart.net/password-reset.php" />
|
||||
|
||||
<!-- Skidmark data: maximum number of skid marks, and
|
||||
time for skidmarks to fade out. Maximum number will over
|
||||
|
@ -121,7 +121,7 @@ void AddonsManager::init(const XMLNode *xml,
|
||||
!file_manager->fileExists(filename) )
|
||||
&& UserConfigParams::m_internet_status == RequestManager::IPERM_ALLOWED
|
||||
&& !file_manager->fileExists(filename_part);
|
||||
|
||||
|
||||
if (download)
|
||||
{
|
||||
Log::info("addons", "Downloading updated addons.xml.");
|
||||
@ -611,7 +611,8 @@ void AddonsManager::saveInstalled()
|
||||
xml_installed << "<?xml version=\"1.0\"?>" << std::endl;
|
||||
|
||||
// Get server address from config
|
||||
std::string server = UserConfigParams::m_server_addons;
|
||||
const std::string server = stk_config->m_server_addons;
|
||||
|
||||
// Find the third slash (end of the domain)
|
||||
std::string::size_type index = server.find('/');
|
||||
index = server.find('/', index + 2) + 1; // Omit one slash
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "addons/news_manager.hpp"
|
||||
|
||||
#include "config/user_config.hpp"
|
||||
#include "config/stk_config.hpp"
|
||||
#include "io/file_manager.hpp"
|
||||
#include "online/http_request.hpp"
|
||||
#include "online/request_manager.hpp"
|
||||
@ -167,7 +168,6 @@ void* NewsManager::downloadNews(void *obj)
|
||||
// We need a new object, since the state of the old
|
||||
// download request is now done.
|
||||
download_req = new HTTPRequest("news.xml");
|
||||
UserConfigParams::m_server_addons.revertToDefaults();
|
||||
|
||||
// make sure the new server address is actually used
|
||||
download_req->setAddonsURL("news.xml");
|
||||
@ -225,31 +225,53 @@ void* NewsManager::downloadNews(void *obj)
|
||||
*/
|
||||
void NewsManager::checkRedirect(const XMLNode *xml)
|
||||
{
|
||||
std::string new_server;
|
||||
int result = xml->get("redirect", &new_server);
|
||||
if(result==1 && new_server!="")
|
||||
if (stk_config->m_allow_news_redirects)
|
||||
{
|
||||
if(UserConfigParams::logAddons())
|
||||
// NOTE: Before 0.10 there were just two redirect attributes
|
||||
// "redirect" - addons server (contains /dl/xml/ path)
|
||||
// "hw-report-server" - hardware report server
|
||||
|
||||
// Redirect for the new addons server
|
||||
std::string new_addons_server;
|
||||
if (xml->get("redirect-server-addons", &new_addons_server) == 1 && !new_addons_server.empty())
|
||||
{
|
||||
Log::info("[Addons]", "Current server: '%s'\n [Addons] New server: '%s'",
|
||||
UserConfigParams::m_server_addons.c_str(), new_server.c_str());
|
||||
if (UserConfigParams::logAddons())
|
||||
{
|
||||
Log::info("[Addons]", "Current addons server: '%s'\n [Addons] New addons server: '%s'",
|
||||
stk_config->m_server_addons.c_str(), new_addons_server.c_str());
|
||||
}
|
||||
stk_config->m_server_addons = new_addons_server;
|
||||
}
|
||||
|
||||
// Redirect for the API server
|
||||
std::string new_api_server;
|
||||
if (xml->get("redirect-server-api", &new_api_server) == 1 && !new_api_server.empty())
|
||||
{
|
||||
if (UserConfigParams::logAddons())
|
||||
{
|
||||
Log::info("[Addons]", "Current API server: '%s'\n [Addons] New API server: '%s'",
|
||||
stk_config->m_server_api.c_str(), new_api_server.c_str());
|
||||
}
|
||||
stk_config->m_server_api = new_api_server;
|
||||
}
|
||||
|
||||
// Redirect for the hardware report server
|
||||
std::string new_hardware_report_server;
|
||||
if (xml->get("redirect-server-hardware-report", &new_hardware_report_server) == 1 && !new_hardware_report_server.empty())
|
||||
{
|
||||
Log::info("hw report", "Current hardware report server: '%s'\n [hw report] New hardware report server: '%s'",
|
||||
stk_config->m_server_hardware_report.c_str(), new_hardware_report_server.c_str());
|
||||
stk_config->m_server_hardware_report = new_hardware_report_server;
|
||||
}
|
||||
UserConfigParams::m_server_addons = new_server;
|
||||
}
|
||||
|
||||
std::string hw_report_server;
|
||||
if(xml->get("hw-report-server", &hw_report_server)==1 && hw_report_server.size()>0)
|
||||
{
|
||||
Log::info("hw report", "New server at '%s'.", hw_report_server.c_str());
|
||||
UserConfigParams::m_server_hw_report = hw_report_server;
|
||||
}
|
||||
|
||||
// Update menu/game polling interval
|
||||
float polling;
|
||||
if(xml->get("menu-polling-interval", &polling))
|
||||
if (xml->get("menu-polling-interval", &polling))
|
||||
{
|
||||
RequestManager::get()->setMenuPollingInterval(polling);
|
||||
}
|
||||
if(xml->get("game-polling-interval", &polling))
|
||||
if (xml->get("game-polling-interval", &polling))
|
||||
{
|
||||
RequestManager::get()->setGamePollingInterval(polling);
|
||||
}
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "config/hardware_stats.hpp"
|
||||
|
||||
#include "config/user_config.hpp"
|
||||
#include "config/stk_config.hpp"
|
||||
#include "graphics/central_settings.hpp"
|
||||
#include "graphics/glwrap.hpp"
|
||||
#include "graphics/irr_driver.hpp"
|
||||
@ -398,7 +399,8 @@ void reportHardwareStats()
|
||||
request->addParameter("type", "hwdetect");
|
||||
request->addParameter("version", report_version);
|
||||
request->addParameter("data", json.toString());
|
||||
request->setURL((std::string)UserConfigParams::m_server_hw_report+"/upload/v1/");
|
||||
const std::string request_url = stk_config->m_server_hardware_report + "/upload/v1/";
|
||||
request->setURL(request_url);
|
||||
//request->setURL("http://127.0.0.1:8000/upload/v1/");
|
||||
request->queue();
|
||||
#endif // !SERVER_ONLY
|
||||
|
@ -266,6 +266,23 @@ void STKConfig::getAllData(const XMLNode * root)
|
||||
if(const XMLNode *kart_node = root->getNode("karts"))
|
||||
kart_node->get("max-number", &m_max_karts);
|
||||
|
||||
if (const XMLNode *node = root->getNode("HardwareReportServer"))
|
||||
{
|
||||
node->get("url", &m_server_hardware_report);
|
||||
}
|
||||
|
||||
if (const XMLNode *node = root->getNode("OnlineServer"))
|
||||
{
|
||||
node->get("url", &m_server_api);
|
||||
node->get("server-version", &m_server_api_version);
|
||||
}
|
||||
|
||||
if (const XMLNode *node = root->getNode("AddonServer"))
|
||||
{
|
||||
node->get("url", &m_server_addons);
|
||||
node->get("allow-news-redirects", &m_allow_news_redirects);
|
||||
}
|
||||
|
||||
if(const XMLNode *gp_node = root->getNode("grand-prix"))
|
||||
{
|
||||
for(unsigned int i=0; i<gp_node->getNumNodes(); i++)
|
||||
@ -364,8 +381,8 @@ void STKConfig::getAllData(const XMLNode * root)
|
||||
camera->get("fov-2", &m_camera_fov[1]);
|
||||
camera->get("fov-3", &m_camera_fov[2]);
|
||||
camera->get("fov-4", &m_camera_fov[3]);
|
||||
|
||||
for (unsigned int i = 4; i < MAX_PLAYER_COUNT; i++)
|
||||
|
||||
for (unsigned int i = 4; i < MAX_PLAYER_COUNT; i++)
|
||||
{
|
||||
camera->get("fov-4", &m_camera_fov[i]);
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ public:
|
||||
|
||||
/** If position and velocity constraints are solved separately. */
|
||||
bool m_solver_split_impulse;
|
||||
|
||||
|
||||
/** Threshold when to use the split impulse approach. */
|
||||
float m_solver_split_impulse_thresh;
|
||||
|
||||
@ -214,6 +214,21 @@ public:
|
||||
m_snb_min_adjust_speed, m_snb_max_adjust_time,
|
||||
m_snb_adjust_length_threshold;
|
||||
|
||||
/** URL for the server used for the API multiplayer. */
|
||||
std::string m_server_api;
|
||||
|
||||
/** Version of the server API to use */
|
||||
uint32_t m_server_api_version = 0;
|
||||
|
||||
/** URL for the server used for the addons management. */
|
||||
std::string m_server_addons;
|
||||
|
||||
/** URL for the server used for hardware reporting statistics */
|
||||
std::string m_server_hardware_report;
|
||||
|
||||
/** If true we allow all the server urls to be redirected by the news.xml. */
|
||||
bool m_allow_news_redirects = true;
|
||||
|
||||
private:
|
||||
/** True if stk_config has been loaded. This is necessary if the
|
||||
* --stk-config command line parameter has been specified to avoid
|
||||
|
@ -152,15 +152,15 @@ public:
|
||||
}
|
||||
std::map<T, U>& operator=(const std::map<T,U>& v)
|
||||
{
|
||||
m_elements = std::map<T, U>(v);
|
||||
m_elements = std::map<T, U>(v);
|
||||
return m_elements;
|
||||
}
|
||||
std::map<T, U>& operator=(const MapUserConfigParam& v)
|
||||
{
|
||||
m_elements = std::map<T,U>(v);
|
||||
m_elements = std::map<T,U>(v);
|
||||
return m_elements;
|
||||
}
|
||||
U& operator[] (const T key)
|
||||
U& operator[] (const T key)
|
||||
{
|
||||
return m_elements[key];
|
||||
}
|
||||
@ -443,7 +443,7 @@ namespace UserConfigParams
|
||||
PARAM_PREFIX StringUserConfigParam m_last_used_kart_group
|
||||
PARAM_DEFAULT( StringUserConfigParam("all", "last_kart_group",
|
||||
"Last selected kart group") );
|
||||
|
||||
|
||||
// ---- Wiimote data
|
||||
PARAM_PREFIX GroupUserConfigParam m_wiimote_group
|
||||
PARAM_DEFAULT( GroupUserConfigParam("WiiMote",
|
||||
@ -482,7 +482,7 @@ namespace UserConfigParams
|
||||
PARAM_DEFAULT( IntUserConfigParam(1, "multitouch_active",
|
||||
&m_multitouch_group,
|
||||
"Enable multitouch support: 0 = disabled, 1 = if available, 2 = enabled") );
|
||||
|
||||
|
||||
PARAM_PREFIX BoolUserConfigParam m_multitouch_draw_gui
|
||||
PARAM_DEFAULT( BoolUserConfigParam(false, "multitouch_draw_gui",
|
||||
&m_multitouch_group,
|
||||
@ -508,12 +508,12 @@ namespace UserConfigParams
|
||||
PARAM_DEFAULT( FloatUserConfigParam(0.2f, "multitouch_sensitivity_x",
|
||||
&m_multitouch_group,
|
||||
"A parameter in range [0, 1.0] that determines the sensitivity for x axis."));
|
||||
|
||||
|
||||
PARAM_PREFIX FloatUserConfigParam m_multitouch_sensitivity_y
|
||||
PARAM_DEFAULT( FloatUserConfigParam(0.65f, "multitouch_sensitivity_y",
|
||||
&m_multitouch_group,
|
||||
"A parameter in range [0, 1.0] that determines the sensitivity for y axis."));
|
||||
|
||||
|
||||
PARAM_PREFIX FloatUserConfigParam m_multitouch_tilt_factor
|
||||
PARAM_DEFAULT( FloatUserConfigParam(4.0f, "multitouch_tilt_factor",
|
||||
&m_multitouch_group,
|
||||
@ -530,7 +530,7 @@ namespace UserConfigParams
|
||||
&m_multitouch_group,
|
||||
"Screen keyboard mode: 0 = disabled, 1 = enabled if no hardware "
|
||||
"keyboard, 2 = always enabled, 3 = android keyboard (experimental)") );
|
||||
|
||||
|
||||
PARAM_PREFIX BoolUserConfigParam m_hidpi_enabled
|
||||
PARAM_DEFAULT( BoolUserConfigParam(false, "hidpi_enabled",
|
||||
&m_multitouch_group,
|
||||
@ -728,7 +728,7 @@ namespace UserConfigParams
|
||||
PARAM_PREFIX bool m_race_now PARAM_DEFAULT( false );
|
||||
|
||||
PARAM_PREFIX bool m_enforce_current_player PARAM_DEFAULT( false );
|
||||
|
||||
|
||||
PARAM_PREFIX bool m_enable_sound PARAM_DEFAULT( true );
|
||||
|
||||
/** True to test funky ambient/diffuse/specularity in RGB &
|
||||
@ -953,12 +953,6 @@ namespace UserConfigParams
|
||||
PARAM_DEFAULT( IntUserConfigParam(0, "random-identifier", &m_hw_report_group,
|
||||
"A random number to avoid duplicated reports.") );
|
||||
|
||||
PARAM_PREFIX StringUserConfigParam m_server_hw_report
|
||||
PARAM_DEFAULT( StringUserConfigParam( "http://addons.supertuxkart.net:8080",
|
||||
"hw-report-server",
|
||||
&m_hw_report_group,
|
||||
"The server used for reporting statistics to."));
|
||||
|
||||
PARAM_PREFIX BoolUserConfigParam m_hw_report_enable
|
||||
PARAM_DEFAULT( BoolUserConfigParam( true,
|
||||
"hw-report-enabled",
|
||||
@ -972,35 +966,11 @@ namespace UserConfigParams
|
||||
"Always show the login screen even if last player's session was saved."));
|
||||
|
||||
|
||||
// ---- Online gameplay related
|
||||
PARAM_PREFIX GroupUserConfigParam m_online_group
|
||||
PARAM_DEFAULT( GroupUserConfigParam("OnlineServer",
|
||||
"Everything related to online play.") );
|
||||
|
||||
PARAM_PREFIX StringUserConfigParam m_server_multiplayer
|
||||
PARAM_DEFAULT( StringUserConfigParam( "https://addons.supertuxkart.net/api/",
|
||||
"server_multiplayer",
|
||||
&m_online_group,
|
||||
"The server used for online multiplayer."));
|
||||
|
||||
PARAM_PREFIX IntUserConfigParam m_server_version
|
||||
PARAM_DEFAULT( IntUserConfigParam( 2,
|
||||
"server-version",
|
||||
&m_online_group,
|
||||
"Version of the server API to use."));
|
||||
|
||||
|
||||
// ---- Addon server related entries
|
||||
PARAM_PREFIX GroupUserConfigParam m_addon_group
|
||||
PARAM_DEFAULT( GroupUserConfigParam("AddonServer",
|
||||
"Addon and news related settings") );
|
||||
|
||||
PARAM_PREFIX StringUserConfigParam m_server_addons
|
||||
PARAM_DEFAULT( StringUserConfigParam("http://addons.supertuxkart.net/dl/xml",
|
||||
"server_addons",
|
||||
&m_addon_group,
|
||||
"The server used for addon."));
|
||||
|
||||
PARAM_PREFIX TimeUserConfigParam m_news_last_updated
|
||||
PARAM_DEFAULT( TimeUserConfigParam(0, "news_last_updated",
|
||||
&m_addon_group,
|
||||
@ -1044,7 +1014,7 @@ namespace UserConfigParams
|
||||
PARAM_DEFAULT( IntUserConfigParam(0, "unlock_everything",
|
||||
"Enable all karts and tracks: 0 = disabled, "
|
||||
"1 = everything except final race, 2 = everything") );
|
||||
|
||||
|
||||
PARAM_PREFIX StringUserConfigParam m_commandline
|
||||
PARAM_DEFAULT( StringUserConfigParam("", "commandline",
|
||||
"Allows to set commandline args in config file") );
|
||||
|
@ -115,7 +115,7 @@ FileManager* file_manager = 0;
|
||||
/** The constructor of the file manager creates an irrlicht file system and
|
||||
* detects paths for the user config file and assets base directory (data).
|
||||
* A second initialisation is done later once (see init()), once the user
|
||||
* config file is read. This is necessary since part of discoverPaths
|
||||
* config file is read. This is necessary since part of discoverPaths
|
||||
* depend on artist debug mode.
|
||||
*/
|
||||
FileManager::FileManager()
|
||||
@ -208,17 +208,17 @@ FileManager::FileManager()
|
||||
{
|
||||
Log::error("FileManager", "Could not find file '%s'in any "
|
||||
"standard location (esp. ../data).", version.c_str());
|
||||
Log::error("FileManager",
|
||||
Log::error("FileManager",
|
||||
"Last location checked '%s'.", root_dir.c_str());
|
||||
Log::fatal("FileManager",
|
||||
Log::fatal("FileManager",
|
||||
"Set $SUPERTUXKART_DATADIR to point to the data directory.");
|
||||
// fatal will exit the application
|
||||
}
|
||||
|
||||
|
||||
addRootDirs(root_dir);
|
||||
|
||||
|
||||
std::string assets_dir;
|
||||
|
||||
|
||||
if (getenv("SUPERTUXKART_ASSETS_DIR") != NULL)
|
||||
{
|
||||
assets_dir = std::string(getenv("SUPERTUXKART_ASSETS_DIR"));
|
||||
@ -236,7 +236,7 @@ FileManager::FileManager()
|
||||
//is this needed?
|
||||
assets_dir = std::string(getenv("SUPERTUXKART_ROOT_PATH"));
|
||||
}
|
||||
|
||||
|
||||
if (!assets_dir.empty() && assets_dir != root_dir)
|
||||
{
|
||||
addRootDirs(assets_dir);
|
||||
@ -348,8 +348,9 @@ void FileManager::init()
|
||||
for(int i=0;i<(int)dirs.size(); i++)
|
||||
pushMusicSearchPath(dirs[i]);
|
||||
}
|
||||
m_cert_location = m_file_system->getAbsolutePath(
|
||||
getAsset("addons.supertuxkart.net.pem").c_str()).c_str();
|
||||
|
||||
m_cert_bundle_location = m_file_system->getAbsolutePath(
|
||||
getAsset("cacert.pem").c_str()).c_str();
|
||||
} // init
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -825,7 +826,7 @@ bool FileManager::checkAndCreateDirectoryP(const std::string &path)
|
||||
current_path += split[i] + "/";
|
||||
//Log::verbose("[FileManager]", "Checking for: '%s",
|
||||
// current_path.c_str());
|
||||
|
||||
|
||||
if (!checkAndCreateDirectory(current_path))
|
||||
{
|
||||
Log::error("[FileManager]", "Can't create dir '%s'",
|
||||
@ -937,12 +938,12 @@ void FileManager::checkAndCreateConfigDir()
|
||||
"falling back to '.'.", m_user_config_dir.c_str());
|
||||
m_user_config_dir = "./";
|
||||
}
|
||||
|
||||
|
||||
if (m_stdout_dir.empty())
|
||||
{
|
||||
m_stdout_dir = m_user_config_dir;
|
||||
}
|
||||
|
||||
|
||||
return;
|
||||
} // checkAndCreateConfigDir
|
||||
|
||||
@ -1188,7 +1189,7 @@ void FileManager::setStdoutName(const std::string& filename)
|
||||
void FileManager::setStdoutDir(const std::string& dir)
|
||||
{
|
||||
m_stdout_dir = dir;
|
||||
|
||||
|
||||
if (!m_stdout_dir.empty() && m_stdout_dir[m_stdout_dir.size() - 1] != '/')
|
||||
{
|
||||
m_stdout_dir += "/";
|
||||
@ -1392,8 +1393,8 @@ bool FileManager::removeDirectory(const std::string &name) const
|
||||
|
||||
for (std::string file : files)
|
||||
{
|
||||
if (file == "." || file == ".." || file == name + "/." ||
|
||||
file == name + "/..")
|
||||
if (file == "." || file == ".." || file == name + "/." ||
|
||||
file == name + "/..")
|
||||
continue;
|
||||
|
||||
if (UserConfigParams::logMisc())
|
||||
@ -1417,7 +1418,7 @@ bool FileManager::removeDirectory(const std::string &name) const
|
||||
removeFile(file);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if defined(WIN32)
|
||||
return RemoveDirectory(name.c_str())==TRUE;
|
||||
#else
|
||||
@ -1483,4 +1484,3 @@ bool FileManager::fileIsNewer(const std::string& f1, const std::string& f2) cons
|
||||
stat(f2.c_str(), &stat2);
|
||||
return stat1.st_mtime > stat2.st_mtime;
|
||||
} // fileIsNewer
|
||||
|
||||
|
@ -86,7 +86,7 @@ private:
|
||||
|
||||
/** Name of stdout file. */
|
||||
static std::string m_stdout_filename;
|
||||
|
||||
|
||||
/** Directory of stdout file. */
|
||||
static std::string m_stdout_dir;
|
||||
|
||||
@ -102,7 +102,8 @@ private:
|
||||
/** Directory where user-defined grand prix are stored. */
|
||||
std::string m_gp_dir;
|
||||
|
||||
std::string m_cert_location;
|
||||
/** Location of the certificate bundle. */
|
||||
std::string m_cert_bundle_location;
|
||||
|
||||
std::vector<TextureSearchPath> m_texture_search_path;
|
||||
|
||||
@ -177,7 +178,7 @@ public:
|
||||
std::string getUserConfigFile(const std::string& fname) const;
|
||||
bool fileExists(const std::string& path) const;
|
||||
// ------------------------------------------------------------------------
|
||||
/** Convenience function to save some typing in the
|
||||
/** Convenience function to save some typing in the
|
||||
* file manager constructor. */
|
||||
bool fileExists(const char *prefix, const std::string& path) const
|
||||
{
|
||||
@ -216,7 +217,7 @@ public:
|
||||
m_music_search_path.push_back(path);
|
||||
} // pushMusicSearchPath
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the full path to a shader (this function could be modified
|
||||
/** Returns the full path to a shader (this function could be modified
|
||||
* later to allow track-specific shaders).
|
||||
* \param name Name of the shader.
|
||||
*/
|
||||
@ -225,12 +226,14 @@ public:
|
||||
return getAsset(SHADER, name);
|
||||
|
||||
} // getShader
|
||||
|
||||
|
||||
std::string getShadersDir() const
|
||||
{
|
||||
return m_subdir_name[SHADER];
|
||||
}
|
||||
const std::string& getCertLocation() const { return m_cert_location; }
|
||||
|
||||
const std::string& getCertBundleLocation() const { return m_cert_bundle_location; }
|
||||
|
||||
}; // FileManager
|
||||
|
||||
extern FileManager* file_manager;
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "online/http_request.hpp"
|
||||
|
||||
#include "config/user_config.hpp"
|
||||
#include "config/stk_config.hpp"
|
||||
#include "online/request_manager.hpp"
|
||||
#include "utils/constants.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
@ -95,10 +96,10 @@ namespace Online
|
||||
m_parameters = "";
|
||||
m_curl_code = CURLE_OK;
|
||||
m_progress.setAtomic(0);
|
||||
if (m_http_header == NULL)
|
||||
if (m_http_header == nullptr)
|
||||
{
|
||||
m_http_header = curl_slist_append(m_http_header,
|
||||
"Host: addons.supertuxkart.net");
|
||||
std::string Host = "Host: " + StringUtils::getHostNameFromURL(stk_config->m_server_api);
|
||||
m_http_header = curl_slist_append(m_http_header, Host.c_str());
|
||||
}
|
||||
m_disable_sending_log = false;
|
||||
} // init
|
||||
@ -114,25 +115,25 @@ namespace Online
|
||||
const std::string &action)
|
||||
{
|
||||
// Old (0.8.1) API: send to client-user.php, and add action as a parameter
|
||||
if(UserConfigParams::m_server_version==1)
|
||||
if (stk_config->m_server_api_version == 1)
|
||||
{
|
||||
setURL( (std::string)UserConfigParams::m_server_multiplayer +
|
||||
"client-user.php" );
|
||||
if(action=="change-password")
|
||||
const std::string final_url = stk_config->m_server_api + "client-user.php";
|
||||
setURL(final_url);
|
||||
if (action == "change-password")
|
||||
addParameter("action", "change_password");
|
||||
else if(action=="recover")
|
||||
else if (action == "recover")
|
||||
addParameter("action", "recovery");
|
||||
else
|
||||
addParameter("action", action);
|
||||
}
|
||||
else
|
||||
{
|
||||
setURL(
|
||||
(std::string)UserConfigParams::m_server_multiplayer +
|
||||
+"v"+StringUtils::toString(UserConfigParams::m_server_version)
|
||||
+ "/" + path + // eg: /user/, /server/
|
||||
action + "/" // eg: connect/, pool/, get-server-list/
|
||||
);
|
||||
const std::string final_url = stk_config->m_server_api +
|
||||
+ "v" + StringUtils::toString(stk_config->m_server_api_version)
|
||||
+ "/" + path // eg: /user/, /server/
|
||||
+ action + "/"; // eg: connect/, pool/, get-server-list/
|
||||
|
||||
setURL(final_url);
|
||||
}
|
||||
} // setServerURL
|
||||
|
||||
@ -143,7 +144,7 @@ namespace Online
|
||||
*/
|
||||
void HTTPRequest::setAddonsURL(const std::string& path)
|
||||
{
|
||||
setURL((std::string)UserConfigParams::m_server_addons + "/" + path);
|
||||
setURL(stk_config->m_server_addons + "/" + path);
|
||||
} // set AddonsURL
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@ -169,7 +170,7 @@ namespace Online
|
||||
}
|
||||
|
||||
curl_easy_setopt(m_curl_session, CURLOPT_URL, m_url.c_str());
|
||||
curl_easy_setopt(m_curl_session, CURLOPT_FOLLOWLOCATION, 1);
|
||||
curl_easy_setopt(m_curl_session, CURLOPT_FOLLOWLOCATION, 1L);
|
||||
curl_easy_setopt(m_curl_session, CURLOPT_NOPROGRESS, 0);
|
||||
curl_easy_setopt(m_curl_session, CURLOPT_PROGRESSDATA, this);
|
||||
curl_easy_setopt(m_curl_session, CURLOPT_PROGRESSFUNCTION,
|
||||
@ -179,29 +180,22 @@ namespace Online
|
||||
curl_easy_setopt(m_curl_session, CURLOPT_LOW_SPEED_TIME, 20);
|
||||
curl_easy_setopt(m_curl_session, CURLOPT_NOSIGNAL, 1);
|
||||
//curl_easy_setopt(m_curl_session, CURLOPT_VERBOSE, 1L);
|
||||
if (m_url.substr(0, 8) == "https://")
|
||||
|
||||
// https, load certificate info
|
||||
const std::string& ci = file_manager->getCertBundleLocation();
|
||||
CURLcode error = curl_easy_setopt(m_curl_session, CURLOPT_CAINFO, ci.c_str());
|
||||
if (error != CURLE_OK)
|
||||
{
|
||||
// https, load certificate info
|
||||
assert(m_http_header != NULL);
|
||||
curl_easy_setopt(m_curl_session, CURLOPT_HTTPHEADER,
|
||||
m_http_header);
|
||||
const std::string& ci = file_manager->getCertLocation();
|
||||
CURLcode error = curl_easy_setopt(m_curl_session, CURLOPT_CAINFO,
|
||||
Log::error("HTTPRequest", "Error setting CAINFO to '%s'",
|
||||
ci.c_str());
|
||||
if (error != CURLE_OK)
|
||||
{
|
||||
Log::error("HTTPRequest", "Error setting CAINFO to '%s'",
|
||||
ci.c_str());
|
||||
Log::error("HTTPRequest", "Error: '%s'.", error,
|
||||
curl_easy_strerror(error));
|
||||
}
|
||||
curl_easy_setopt(m_curl_session, CURLOPT_SSL_VERIFYPEER, 1L);
|
||||
#ifdef __APPLE__
|
||||
curl_easy_setopt(m_curl_session, CURLOPT_SSL_VERIFYHOST, 0L);
|
||||
#else
|
||||
curl_easy_setopt(m_curl_session, CURLOPT_SSL_VERIFYHOST, 1L);
|
||||
#endif
|
||||
Log::error("HTTPRequest", "Error: '%s'.", error,
|
||||
curl_easy_strerror(error));
|
||||
}
|
||||
|
||||
assert(m_http_header != nullptr);
|
||||
curl_easy_setopt(m_curl_session, CURLOPT_HTTPHEADER, m_http_header);
|
||||
curl_easy_setopt(m_curl_session, CURLOPT_SSL_VERIFYPEER, 1L);
|
||||
curl_easy_setopt(m_curl_session, CURLOPT_SSL_VERIFYHOST, 2L);
|
||||
} // prepareOperation
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
@ -946,18 +946,46 @@ namespace StringUtils
|
||||
std::string removeWhitespaces(const std::string& input)
|
||||
{
|
||||
std::string out;
|
||||
|
||||
|
||||
for (char ch : input)
|
||||
{
|
||||
if (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r')
|
||||
continue;
|
||||
|
||||
|
||||
out += ch;
|
||||
}
|
||||
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
std::string getHostNameFromURL(const std::string& url)
|
||||
{
|
||||
// Not even a valid URL
|
||||
if (url.length() < 8)
|
||||
return "";
|
||||
|
||||
// protocol is substr(0, first_color_position)
|
||||
const size_t first_colon_position = url.find_first_of(":");
|
||||
if (first_colon_position == std::string::npos)
|
||||
return "";
|
||||
|
||||
// skip ://
|
||||
const std::string url_without_protocol = url.substr(first_colon_position + 3);
|
||||
|
||||
// Find end with port
|
||||
const size_t port_colon_position = url_without_protocol.find_first_of(":");
|
||||
if (port_colon_position != std::string::npos)
|
||||
return url_without_protocol.substr(0, port_colon_position);
|
||||
|
||||
// Find end with path
|
||||
const size_t slash_position = url_without_protocol.find_first_of("/");
|
||||
if (slash_position != std::string::npos)
|
||||
return url_without_protocol.substr(0, slash_position);
|
||||
|
||||
return url_without_protocol;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Breaks the text so that each line is smaller than max_width with the current settings.
|
||||
* The result is put into output, a vector of strings, with each line having its own string */
|
||||
|
@ -241,7 +241,7 @@ namespace StringUtils
|
||||
} // parseString
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
|
||||
irr::core::stringw utf8ToWide(const char* input);
|
||||
irr::core::stringw utf8ToWide(const std::string &input);
|
||||
std::string wideToUtf8(const wchar_t* input);
|
||||
@ -271,6 +271,15 @@ namespace StringUtils
|
||||
#endif
|
||||
return uagent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the hostname part of an url (if any)
|
||||
*
|
||||
* Example https://online.supertuxkart.net/
|
||||
*
|
||||
*/
|
||||
std::string getHostNameFromURL(const std::string& url);
|
||||
|
||||
} // namespace StringUtils
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user