Update config to use the new online servers. Remove hardcoded certificate as we will use Let's encrypt from now on (#3690)

This commit is contained in:
Daniel Butum 2019-01-08 02:42:30 +02:00 committed by auria.mg
parent 75076106b9
commit ed225a21f2
8 changed files with 79 additions and 79 deletions

View File

@ -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-----

View File

@ -157,7 +157,7 @@
<minimap size="180.0" ai-icon="16.0" player-icon="20.0"/> <minimap size="180.0" ai-icon="16.0" player-icon="20.0"/>
<urls donate="https://supertuxkart.net/Donate" <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 <!-- Skidmark data: maximum number of skid marks, and
time for skidmarks to fade out. Maximum number will over time for skidmarks to fade out. Maximum number will over

View File

@ -152,15 +152,15 @@ public:
} }
std::map<T, U>& operator=(const std::map<T,U>& v) 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; return m_elements;
} }
std::map<T, U>& operator=(const MapUserConfigParam& v) 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; return m_elements;
} }
U& operator[] (const T key) U& operator[] (const T key)
{ {
return m_elements[key]; return m_elements[key];
} }
@ -443,7 +443,7 @@ namespace UserConfigParams
PARAM_PREFIX StringUserConfigParam m_last_used_kart_group PARAM_PREFIX StringUserConfigParam m_last_used_kart_group
PARAM_DEFAULT( StringUserConfigParam("all", "last_kart_group", PARAM_DEFAULT( StringUserConfigParam("all", "last_kart_group",
"Last selected kart group") ); "Last selected kart group") );
// ---- Wiimote data // ---- Wiimote data
PARAM_PREFIX GroupUserConfigParam m_wiimote_group PARAM_PREFIX GroupUserConfigParam m_wiimote_group
PARAM_DEFAULT( GroupUserConfigParam("WiiMote", PARAM_DEFAULT( GroupUserConfigParam("WiiMote",
@ -482,7 +482,7 @@ namespace UserConfigParams
PARAM_DEFAULT( BoolUserConfigParam(false, "multitouch_enabled", PARAM_DEFAULT( BoolUserConfigParam(false, "multitouch_enabled",
&m_multitouch_group, &m_multitouch_group,
"Enable multitouch support.") ); "Enable multitouch support.") );
PARAM_PREFIX IntUserConfigParam m_multitouch_mode PARAM_PREFIX IntUserConfigParam m_multitouch_mode
PARAM_DEFAULT( IntUserConfigParam(1, "multitouch_mode", PARAM_DEFAULT( IntUserConfigParam(1, "multitouch_mode",
&m_multitouch_group, &m_multitouch_group,
@ -508,12 +508,12 @@ namespace UserConfigParams
PARAM_DEFAULT( FloatUserConfigParam(0.2f, "multitouch_sensitivity_x", PARAM_DEFAULT( FloatUserConfigParam(0.2f, "multitouch_sensitivity_x",
&m_multitouch_group, &m_multitouch_group,
"A parameter in range [0, 1.0] that determines the sensitivity for x axis.")); "A parameter in range [0, 1.0] that determines the sensitivity for x axis."));
PARAM_PREFIX FloatUserConfigParam m_multitouch_sensitivity_y PARAM_PREFIX FloatUserConfigParam m_multitouch_sensitivity_y
PARAM_DEFAULT( FloatUserConfigParam(0.65f, "multitouch_sensitivity_y", PARAM_DEFAULT( FloatUserConfigParam(0.65f, "multitouch_sensitivity_y",
&m_multitouch_group, &m_multitouch_group,
"A parameter in range [0, 1.0] that determines the sensitivity for y axis.")); "A parameter in range [0, 1.0] that determines the sensitivity for y axis."));
PARAM_PREFIX FloatUserConfigParam m_multitouch_tilt_factor PARAM_PREFIX FloatUserConfigParam m_multitouch_tilt_factor
PARAM_DEFAULT( FloatUserConfigParam(4.0f, "multitouch_tilt_factor", PARAM_DEFAULT( FloatUserConfigParam(4.0f, "multitouch_tilt_factor",
&m_multitouch_group, &m_multitouch_group,
@ -530,7 +530,7 @@ namespace UserConfigParams
&m_multitouch_group, &m_multitouch_group,
"Screen keyboard mode: 0 = disabled, 1 = enabled if no hardware " "Screen keyboard mode: 0 = disabled, 1 = enabled if no hardware "
"keyboard, 2 = always enabled, 3 = android keyboard (experimental)") ); "keyboard, 2 = always enabled, 3 = android keyboard (experimental)") );
PARAM_PREFIX BoolUserConfigParam m_hidpi_enabled PARAM_PREFIX BoolUserConfigParam m_hidpi_enabled
PARAM_DEFAULT( BoolUserConfigParam(false, "hidpi_enabled", PARAM_DEFAULT( BoolUserConfigParam(false, "hidpi_enabled",
&m_multitouch_group, &m_multitouch_group,
@ -728,7 +728,7 @@ namespace UserConfigParams
PARAM_PREFIX bool m_race_now PARAM_DEFAULT( false ); PARAM_PREFIX bool m_race_now PARAM_DEFAULT( false );
PARAM_PREFIX bool m_enforce_current_player PARAM_DEFAULT( false ); PARAM_PREFIX bool m_enforce_current_player PARAM_DEFAULT( false );
PARAM_PREFIX bool m_enable_sound PARAM_DEFAULT( true ); PARAM_PREFIX bool m_enable_sound PARAM_DEFAULT( true );
/** True to test funky ambient/diffuse/specularity in RGB & /** True to test funky ambient/diffuse/specularity in RGB &
@ -953,8 +953,9 @@ namespace UserConfigParams
PARAM_DEFAULT( IntUserConfigParam(0, "random-identifier", &m_hw_report_group, PARAM_DEFAULT( IntUserConfigParam(0, "random-identifier", &m_hw_report_group,
"A random number to avoid duplicated reports.") ); "A random number to avoid duplicated reports.") );
// TODO change new-stats to stats before release
PARAM_PREFIX StringUserConfigParam m_server_hw_report PARAM_PREFIX StringUserConfigParam m_server_hw_report
PARAM_DEFAULT( StringUserConfigParam( "http://addons.supertuxkart.net:8080", PARAM_DEFAULT( StringUserConfigParam( "https://new-stats.supertuxkart.net",
"hw-report-server", "hw-report-server",
&m_hw_report_group, &m_hw_report_group,
"The server used for reporting statistics to.")); "The server used for reporting statistics to."));
@ -978,7 +979,7 @@ namespace UserConfigParams
"Everything related to online play.") ); "Everything related to online play.") );
PARAM_PREFIX StringUserConfigParam m_server_multiplayer PARAM_PREFIX StringUserConfigParam m_server_multiplayer
PARAM_DEFAULT( StringUserConfigParam( "https://addons.supertuxkart.net/api/", PARAM_DEFAULT( StringUserConfigParam( "https://online.supertuxkart.net/api/",
"server_multiplayer", "server_multiplayer",
&m_online_group, &m_online_group,
"The server used for online multiplayer.")); "The server used for online multiplayer."));
@ -996,7 +997,7 @@ namespace UserConfigParams
"Addon and news related settings") ); "Addon and news related settings") );
PARAM_PREFIX StringUserConfigParam m_server_addons PARAM_PREFIX StringUserConfigParam m_server_addons
PARAM_DEFAULT( StringUserConfigParam("http://addons.supertuxkart.net/dl/xml", PARAM_DEFAULT( StringUserConfigParam("https://online.supertuxkart.net/dl/xml",
"server_addons", "server_addons",
&m_addon_group, &m_addon_group,
"The server used for addon.")); "The server used for addon."));
@ -1044,7 +1045,7 @@ namespace UserConfigParams
PARAM_DEFAULT( IntUserConfigParam(0, "unlock_everything", PARAM_DEFAULT( IntUserConfigParam(0, "unlock_everything",
"Enable all karts and tracks: 0 = disabled, " "Enable all karts and tracks: 0 = disabled, "
"1 = everything except final race, 2 = everything") ); "1 = everything except final race, 2 = everything") );
PARAM_PREFIX StringUserConfigParam m_commandline PARAM_PREFIX StringUserConfigParam m_commandline
PARAM_DEFAULT( StringUserConfigParam("", "commandline", PARAM_DEFAULT( StringUserConfigParam("", "commandline",
"Allows to set commandline args in config file") ); "Allows to set commandline args in config file") );

View File

@ -115,7 +115,7 @@ FileManager* file_manager = 0;
/** The constructor of the file manager creates an irrlicht file system and /** The constructor of the file manager creates an irrlicht file system and
* detects paths for the user config file and assets base directory (data). * detects paths for the user config file and assets base directory (data).
* A second initialisation is done later once (see init()), once the user * 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. * depend on artist debug mode.
*/ */
FileManager::FileManager() FileManager::FileManager()
@ -208,17 +208,17 @@ FileManager::FileManager()
{ {
Log::error("FileManager", "Could not file '%s'in any " Log::error("FileManager", "Could not file '%s'in any "
"standard location (esp. ../data).", version.c_str()); "standard location (esp. ../data).", version.c_str());
Log::error("FileManager", Log::error("FileManager",
"Last location checked '%s'.", root_dir.c_str()); "Last location checked '%s'.", root_dir.c_str());
Log::fatal("FileManager", Log::fatal("FileManager",
"Set $SUPERTUXKART_DATADIR to point to the data directory."); "Set $SUPERTUXKART_DATADIR to point to the data directory.");
// fatal will exit the application // fatal will exit the application
} }
addRootDirs(root_dir); addRootDirs(root_dir);
std::string assets_dir; std::string assets_dir;
if (getenv("SUPERTUXKART_ASSETS_DIR") != NULL) if (getenv("SUPERTUXKART_ASSETS_DIR") != NULL)
{ {
assets_dir = std::string(getenv("SUPERTUXKART_ASSETS_DIR")); assets_dir = std::string(getenv("SUPERTUXKART_ASSETS_DIR"));
@ -236,7 +236,7 @@ FileManager::FileManager()
//is this needed? //is this needed?
assets_dir = std::string(getenv("SUPERTUXKART_ROOT_PATH")); assets_dir = std::string(getenv("SUPERTUXKART_ROOT_PATH"));
} }
if (!assets_dir.empty() && assets_dir != root_dir) if (!assets_dir.empty() && assets_dir != root_dir)
{ {
addRootDirs(assets_dir); addRootDirs(assets_dir);
@ -348,8 +348,6 @@ void FileManager::init()
for(int i=0;i<(int)dirs.size(); i++) for(int i=0;i<(int)dirs.size(); i++)
pushMusicSearchPath(dirs[i]); pushMusicSearchPath(dirs[i]);
} }
m_cert_location = m_file_system->getAbsolutePath(
getAsset("addons.supertuxkart.net.pem").c_str()).c_str();
} // init } // init
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -825,7 +823,7 @@ bool FileManager::checkAndCreateDirectoryP(const std::string &path)
current_path += split[i] + "/"; current_path += split[i] + "/";
//Log::verbose("[FileManager]", "Checking for: '%s", //Log::verbose("[FileManager]", "Checking for: '%s",
// current_path.c_str()); // current_path.c_str());
if (!checkAndCreateDirectory(current_path)) if (!checkAndCreateDirectory(current_path))
{ {
Log::error("[FileManager]", "Can't create dir '%s'", Log::error("[FileManager]", "Can't create dir '%s'",
@ -937,12 +935,12 @@ void FileManager::checkAndCreateConfigDir()
"falling back to '.'.", m_user_config_dir.c_str()); "falling back to '.'.", m_user_config_dir.c_str());
m_user_config_dir = "./"; m_user_config_dir = "./";
} }
if (m_stdout_dir.empty()) if (m_stdout_dir.empty())
{ {
m_stdout_dir = m_user_config_dir; m_stdout_dir = m_user_config_dir;
} }
return; return;
} // checkAndCreateConfigDir } // checkAndCreateConfigDir
@ -1188,7 +1186,7 @@ void FileManager::setStdoutName(const std::string& filename)
void FileManager::setStdoutDir(const std::string& dir) void FileManager::setStdoutDir(const std::string& dir)
{ {
m_stdout_dir = dir; m_stdout_dir = dir;
if (!m_stdout_dir.empty() && m_stdout_dir[m_stdout_dir.size() - 1] != '/') if (!m_stdout_dir.empty() && m_stdout_dir[m_stdout_dir.size() - 1] != '/')
{ {
m_stdout_dir += "/"; m_stdout_dir += "/";
@ -1392,8 +1390,8 @@ bool FileManager::removeDirectory(const std::string &name) const
for (std::string file : files) for (std::string file : files)
{ {
if (file == "." || file == ".." || file == name + "/." || if (file == "." || file == ".." || file == name + "/." ||
file == name + "/..") file == name + "/..")
continue; continue;
if (UserConfigParams::logMisc()) if (UserConfigParams::logMisc())
@ -1417,7 +1415,7 @@ bool FileManager::removeDirectory(const std::string &name) const
removeFile(file); removeFile(file);
} }
} }
#if defined(WIN32) #if defined(WIN32)
return RemoveDirectory(name.c_str())==TRUE; return RemoveDirectory(name.c_str())==TRUE;
#else #else
@ -1483,4 +1481,3 @@ bool FileManager::fileIsNewer(const std::string& f1, const std::string& f2) cons
stat(f2.c_str(), &stat2); stat(f2.c_str(), &stat2);
return stat1.st_mtime > stat2.st_mtime; return stat1.st_mtime > stat2.st_mtime;
} // fileIsNewer } // fileIsNewer

View File

@ -86,7 +86,7 @@ private:
/** Name of stdout file. */ /** Name of stdout file. */
static std::string m_stdout_filename; static std::string m_stdout_filename;
/** Directory of stdout file. */ /** Directory of stdout file. */
static std::string m_stdout_dir; static std::string m_stdout_dir;
@ -102,8 +102,6 @@ private:
/** Directory where user-defined grand prix are stored. */ /** Directory where user-defined grand prix are stored. */
std::string m_gp_dir; std::string m_gp_dir;
std::string m_cert_location;
std::vector<TextureSearchPath> m_texture_search_path; std::vector<TextureSearchPath> m_texture_search_path;
std::vector<std::string> std::vector<std::string>
@ -177,7 +175,7 @@ public:
std::string getUserConfigFile(const std::string& fname) const; std::string getUserConfigFile(const std::string& fname) const;
bool fileExists(const std::string& path) 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. */ * file manager constructor. */
bool fileExists(const char *prefix, const std::string& path) const bool fileExists(const char *prefix, const std::string& path) const
{ {
@ -216,7 +214,7 @@ public:
m_music_search_path.push_back(path); m_music_search_path.push_back(path);
} // pushMusicSearchPath } // 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). * later to allow track-specific shaders).
* \param name Name of the shader. * \param name Name of the shader.
*/ */
@ -225,12 +223,11 @@ public:
return getAsset(SHADER, name); return getAsset(SHADER, name);
} // getShader } // getShader
std::string getShadersDir() const std::string getShadersDir() const
{ {
return m_subdir_name[SHADER]; return m_subdir_name[SHADER];
} }
const std::string& getCertLocation() const { return m_cert_location; }
}; // FileManager }; // FileManager
extern FileManager* file_manager; extern FileManager* file_manager;

View File

@ -95,10 +95,10 @@ namespace Online
m_parameters = ""; m_parameters = "";
m_curl_code = CURLE_OK; m_curl_code = CURLE_OK;
m_progress.setAtomic(0); m_progress.setAtomic(0);
if (m_http_header == NULL) if (m_http_header == nullptr)
{ {
m_http_header = curl_slist_append(m_http_header, std::string Host = "Host: " + StringUtils::getHostNameFromURL(UserConfigParams::m_server_multiplayer);
"Host: addons.supertuxkart.net"); m_http_header = curl_slist_append(m_http_header, Host.c_str());
} }
m_disable_sending_log = false; m_disable_sending_log = false;
} // init } // init
@ -182,19 +182,8 @@ namespace Online
if (m_url.substr(0, 8) == "https://") if (m_url.substr(0, 8) == "https://")
{ {
// https, load certificate info // https, load certificate info
assert(m_http_header != NULL); assert(m_http_header != nullptr);
curl_easy_setopt(m_curl_session, CURLOPT_HTTPHEADER, curl_easy_setopt(m_curl_session, CURLOPT_HTTPHEADER, m_http_header);
m_http_header);
const std::string& ci = file_manager->getCertLocation();
CURLcode error = curl_easy_setopt(m_curl_session, CURLOPT_CAINFO,
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); curl_easy_setopt(m_curl_session, CURLOPT_SSL_VERIFYPEER, 1L);
#ifdef __APPLE__ #ifdef __APPLE__
curl_easy_setopt(m_curl_session, CURLOPT_SSL_VERIFYHOST, 0L); curl_easy_setopt(m_curl_session, CURLOPT_SSL_VERIFYHOST, 0L);

View File

@ -896,18 +896,46 @@ namespace StringUtils
std::string removeWhitespaces(const std::string& input) std::string removeWhitespaces(const std::string& input)
{ {
std::string out; std::string out;
for (char ch : input) for (char ch : input)
{ {
if (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r') if (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r')
continue; continue;
out += ch; out += ch;
} }
return out; 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. /** 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 */ * The result is put into output, a vector of strings, with each line having its own string */

View File

@ -240,7 +240,7 @@ namespace StringUtils
} // parseString } // parseString
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
irr::core::stringw utf8ToWide(const char* input); irr::core::stringw utf8ToWide(const char* input);
irr::core::stringw utf8ToWide(const std::string &input); irr::core::stringw utf8ToWide(const std::string &input);
std::string wideToUtf8(const wchar_t* input); std::string wideToUtf8(const wchar_t* input);
@ -270,6 +270,15 @@ namespace StringUtils
#endif #endif
return uagent; 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 } // namespace StringUtils
#endif #endif