Skip to content

Commit b2c11c1

Browse files
vampyauriamg
authored andcommitted
Update config to use the new online servers. Remove hardcoded certificate as we will use Let's encrypt from now on (supertuxkart#3690)
1 parent f40ac02 commit b2c11c1

File tree

8 files changed

+79
-79
lines changed

8 files changed

+79
-79
lines changed

data/addons.supertuxkart.net.pem

Lines changed: 0 additions & 21 deletions
This file was deleted.

data/stk_config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@
157157
<minimap size="180.0" ai-icon="16.0" player-icon="20.0"/>
158158

159159
<urls donate="https://supertuxkart.net/Donate"
160-
password-reset="http://addons.supertuxkart.net/password-reset.php" />
160+
password-reset="https://online.supertuxkart.net/password-reset.php" />
161161

162162
<!-- Skidmark data: maximum number of skid marks, and
163163
time for skidmarks to fade out. Maximum number will over

src/config/user_config.hpp

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -152,15 +152,15 @@ class MapUserConfigParam : public UserConfigParam
152152
}
153153
std::map<T, U>& operator=(const std::map<T,U>& v)
154154
{
155-
m_elements = std::map<T, U>(v);
155+
m_elements = std::map<T, U>(v);
156156
return m_elements;
157157
}
158158
std::map<T, U>& operator=(const MapUserConfigParam& v)
159159
{
160-
m_elements = std::map<T,U>(v);
160+
m_elements = std::map<T,U>(v);
161161
return m_elements;
162162
}
163-
U& operator[] (const T key)
163+
U& operator[] (const T key)
164164
{
165165
return m_elements[key];
166166
}
@@ -443,7 +443,7 @@ namespace UserConfigParams
443443
PARAM_PREFIX StringUserConfigParam m_last_used_kart_group
444444
PARAM_DEFAULT( StringUserConfigParam("all", "last_kart_group",
445445
"Last selected kart group") );
446-
446+
447447
// ---- Wiimote data
448448
PARAM_PREFIX GroupUserConfigParam m_wiimote_group
449449
PARAM_DEFAULT( GroupUserConfigParam("WiiMote",
@@ -482,7 +482,7 @@ namespace UserConfigParams
482482
PARAM_DEFAULT( BoolUserConfigParam(false, "multitouch_enabled",
483483
&m_multitouch_group,
484484
"Enable multitouch support.") );
485-
485+
486486
PARAM_PREFIX IntUserConfigParam m_multitouch_mode
487487
PARAM_DEFAULT( IntUserConfigParam(1, "multitouch_mode",
488488
&m_multitouch_group,
@@ -508,12 +508,12 @@ namespace UserConfigParams
508508
PARAM_DEFAULT( FloatUserConfigParam(0.2f, "multitouch_sensitivity_x",
509509
&m_multitouch_group,
510510
"A parameter in range [0, 1.0] that determines the sensitivity for x axis."));
511-
511+
512512
PARAM_PREFIX FloatUserConfigParam m_multitouch_sensitivity_y
513513
PARAM_DEFAULT( FloatUserConfigParam(0.65f, "multitouch_sensitivity_y",
514514
&m_multitouch_group,
515515
"A parameter in range [0, 1.0] that determines the sensitivity for y axis."));
516-
516+
517517
PARAM_PREFIX FloatUserConfigParam m_multitouch_tilt_factor
518518
PARAM_DEFAULT( FloatUserConfigParam(4.0f, "multitouch_tilt_factor",
519519
&m_multitouch_group,
@@ -530,7 +530,7 @@ namespace UserConfigParams
530530
&m_multitouch_group,
531531
"Screen keyboard mode: 0 = disabled, 1 = enabled if no hardware "
532532
"keyboard, 2 = always enabled, 3 = android keyboard (experimental)") );
533-
533+
534534
PARAM_PREFIX BoolUserConfigParam m_hidpi_enabled
535535
PARAM_DEFAULT( BoolUserConfigParam(false, "hidpi_enabled",
536536
&m_multitouch_group,
@@ -728,7 +728,7 @@ namespace UserConfigParams
728728
PARAM_PREFIX bool m_race_now PARAM_DEFAULT( false );
729729

730730
PARAM_PREFIX bool m_enforce_current_player PARAM_DEFAULT( false );
731-
731+
732732
PARAM_PREFIX bool m_enable_sound PARAM_DEFAULT( true );
733733

734734
/** True to test funky ambient/diffuse/specularity in RGB &
@@ -953,8 +953,9 @@ namespace UserConfigParams
953953
PARAM_DEFAULT( IntUserConfigParam(0, "random-identifier", &m_hw_report_group,
954954
"A random number to avoid duplicated reports.") );
955955

956+
// TODO change new-stats to stats before release
956957
PARAM_PREFIX StringUserConfigParam m_server_hw_report
957-
PARAM_DEFAULT( StringUserConfigParam( "http://addons.supertuxkart.net:8080",
958+
PARAM_DEFAULT( StringUserConfigParam( "https://new-stats.supertuxkart.net",
958959
"hw-report-server",
959960
&m_hw_report_group,
960961
"The server used for reporting statistics to."));
@@ -978,7 +979,7 @@ namespace UserConfigParams
978979
"Everything related to online play.") );
979980

980981
PARAM_PREFIX StringUserConfigParam m_server_multiplayer
981-
PARAM_DEFAULT( StringUserConfigParam( "https://addons.supertuxkart.net/api/",
982+
PARAM_DEFAULT( StringUserConfigParam( "https://online.supertuxkart.net/api/",
982983
"server_multiplayer",
983984
&m_online_group,
984985
"The server used for online multiplayer."));
@@ -996,7 +997,7 @@ namespace UserConfigParams
996997
"Addon and news related settings") );
997998

998999
PARAM_PREFIX StringUserConfigParam m_server_addons
999-
PARAM_DEFAULT( StringUserConfigParam("http://addons.supertuxkart.net/dl/xml",
1000+
PARAM_DEFAULT( StringUserConfigParam("https://online.supertuxkart.net/dl/xml",
10001001
"server_addons",
10011002
&m_addon_group,
10021003
"The server used for addon."));
@@ -1044,7 +1045,7 @@ namespace UserConfigParams
10441045
PARAM_DEFAULT( IntUserConfigParam(0, "unlock_everything",
10451046
"Enable all karts and tracks: 0 = disabled, "
10461047
"1 = everything except final race, 2 = everything") );
1047-
1048+
10481049
PARAM_PREFIX StringUserConfigParam m_commandline
10491050
PARAM_DEFAULT( StringUserConfigParam("", "commandline",
10501051
"Allows to set commandline args in config file") );

src/io/file_manager.cpp

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ FileManager* file_manager = 0;
115115
/** The constructor of the file manager creates an irrlicht file system and
116116
* detects paths for the user config file and assets base directory (data).
117117
* A second initialisation is done later once (see init()), once the user
118-
* config file is read. This is necessary since part of discoverPaths
118+
* config file is read. This is necessary since part of discoverPaths
119119
* depend on artist debug mode.
120120
*/
121121
FileManager::FileManager()
@@ -208,17 +208,17 @@ FileManager::FileManager()
208208
{
209209
Log::error("FileManager", "Could not file '%s'in any "
210210
"standard location (esp. ../data).", version.c_str());
211-
Log::error("FileManager",
211+
Log::error("FileManager",
212212
"Last location checked '%s'.", root_dir.c_str());
213-
Log::fatal("FileManager",
213+
Log::fatal("FileManager",
214214
"Set $SUPERTUXKART_DATADIR to point to the data directory.");
215215
// fatal will exit the application
216216
}
217-
217+
218218
addRootDirs(root_dir);
219-
219+
220220
std::string assets_dir;
221-
221+
222222
if (getenv("SUPERTUXKART_ASSETS_DIR") != NULL)
223223
{
224224
assets_dir = std::string(getenv("SUPERTUXKART_ASSETS_DIR"));
@@ -236,7 +236,7 @@ FileManager::FileManager()
236236
//is this needed?
237237
assets_dir = std::string(getenv("SUPERTUXKART_ROOT_PATH"));
238238
}
239-
239+
240240
if (!assets_dir.empty() && assets_dir != root_dir)
241241
{
242242
addRootDirs(assets_dir);
@@ -348,8 +348,6 @@ void FileManager::init()
348348
for(int i=0;i<(int)dirs.size(); i++)
349349
pushMusicSearchPath(dirs[i]);
350350
}
351-
m_cert_location = m_file_system->getAbsolutePath(
352-
getAsset("addons.supertuxkart.net.pem").c_str()).c_str();
353351
} // init
354352

355353
//-----------------------------------------------------------------------------
@@ -825,7 +823,7 @@ bool FileManager::checkAndCreateDirectoryP(const std::string &path)
825823
current_path += split[i] + "/";
826824
//Log::verbose("[FileManager]", "Checking for: '%s",
827825
// current_path.c_str());
828-
826+
829827
if (!checkAndCreateDirectory(current_path))
830828
{
831829
Log::error("[FileManager]", "Can't create dir '%s'",
@@ -937,12 +935,12 @@ void FileManager::checkAndCreateConfigDir()
937935
"falling back to '.'.", m_user_config_dir.c_str());
938936
m_user_config_dir = "./";
939937
}
940-
938+
941939
if (m_stdout_dir.empty())
942940
{
943941
m_stdout_dir = m_user_config_dir;
944942
}
945-
943+
946944
return;
947945
} // checkAndCreateConfigDir
948946

@@ -1188,7 +1186,7 @@ void FileManager::setStdoutName(const std::string& filename)
11881186
void FileManager::setStdoutDir(const std::string& dir)
11891187
{
11901188
m_stdout_dir = dir;
1191-
1189+
11921190
if (!m_stdout_dir.empty() && m_stdout_dir[m_stdout_dir.size() - 1] != '/')
11931191
{
11941192
m_stdout_dir += "/";
@@ -1392,8 +1390,8 @@ bool FileManager::removeDirectory(const std::string &name) const
13921390

13931391
for (std::string file : files)
13941392
{
1395-
if (file == "." || file == ".." || file == name + "/." ||
1396-
file == name + "/..")
1393+
if (file == "." || file == ".." || file == name + "/." ||
1394+
file == name + "/..")
13971395
continue;
13981396

13991397
if (UserConfigParams::logMisc())
@@ -1417,7 +1415,7 @@ bool FileManager::removeDirectory(const std::string &name) const
14171415
removeFile(file);
14181416
}
14191417
}
1420-
1418+
14211419
#if defined(WIN32)
14221420
return RemoveDirectory(name.c_str())==TRUE;
14231421
#else
@@ -1483,4 +1481,3 @@ bool FileManager::fileIsNewer(const std::string& f1, const std::string& f2) cons
14831481
stat(f2.c_str(), &stat2);
14841482
return stat1.st_mtime > stat2.st_mtime;
14851483
} // fileIsNewer
1486-

src/io/file_manager.hpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class FileManager : public NoCopy
8686

8787
/** Name of stdout file. */
8888
static std::string m_stdout_filename;
89-
89+
9090
/** Directory of stdout file. */
9191
static std::string m_stdout_dir;
9292

@@ -102,8 +102,6 @@ class FileManager : public NoCopy
102102
/** Directory where user-defined grand prix are stored. */
103103
std::string m_gp_dir;
104104

105-
std::string m_cert_location;
106-
107105
std::vector<TextureSearchPath> m_texture_search_path;
108106

109107
std::vector<std::string>
@@ -177,7 +175,7 @@ class FileManager : public NoCopy
177175
std::string getUserConfigFile(const std::string& fname) const;
178176
bool fileExists(const std::string& path) const;
179177
// ------------------------------------------------------------------------
180-
/** Convenience function to save some typing in the
178+
/** Convenience function to save some typing in the
181179
* file manager constructor. */
182180
bool fileExists(const char *prefix, const std::string& path) const
183181
{
@@ -216,7 +214,7 @@ class FileManager : public NoCopy
216214
m_music_search_path.push_back(path);
217215
} // pushMusicSearchPath
218216
// ------------------------------------------------------------------------
219-
/** Returns the full path to a shader (this function could be modified
217+
/** Returns the full path to a shader (this function could be modified
220218
* later to allow track-specific shaders).
221219
* \param name Name of the shader.
222220
*/
@@ -225,12 +223,11 @@ class FileManager : public NoCopy
225223
return getAsset(SHADER, name);
226224

227225
} // getShader
228-
226+
229227
std::string getShadersDir() const
230228
{
231229
return m_subdir_name[SHADER];
232230
}
233-
const std::string& getCertLocation() const { return m_cert_location; }
234231
}; // FileManager
235232

236233
extern FileManager* file_manager;

src/online/http_request.cpp

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,10 @@ namespace Online
9595
m_parameters = "";
9696
m_curl_code = CURLE_OK;
9797
m_progress.setAtomic(0);
98-
if (m_http_header == NULL)
98+
if (m_http_header == nullptr)
9999
{
100-
m_http_header = curl_slist_append(m_http_header,
101-
"Host: addons.supertuxkart.net");
100+
std::string Host = "Host: " + StringUtils::getHostNameFromURL(UserConfigParams::m_server_multiplayer);
101+
m_http_header = curl_slist_append(m_http_header, Host.c_str());
102102
}
103103
m_disable_sending_log = false;
104104
} // init
@@ -182,19 +182,8 @@ namespace Online
182182
if (m_url.substr(0, 8) == "https://")
183183
{
184184
// https, load certificate info
185-
assert(m_http_header != NULL);
186-
curl_easy_setopt(m_curl_session, CURLOPT_HTTPHEADER,
187-
m_http_header);
188-
const std::string& ci = file_manager->getCertLocation();
189-
CURLcode error = curl_easy_setopt(m_curl_session, CURLOPT_CAINFO,
190-
ci.c_str());
191-
if (error != CURLE_OK)
192-
{
193-
Log::error("HTTPRequest", "Error setting CAINFO to '%s'",
194-
ci.c_str());
195-
Log::error("HTTPRequest", "Error: '%s'.", error,
196-
curl_easy_strerror(error));
197-
}
185+
assert(m_http_header != nullptr);
186+
curl_easy_setopt(m_curl_session, CURLOPT_HTTPHEADER, m_http_header);
198187
curl_easy_setopt(m_curl_session, CURLOPT_SSL_VERIFYPEER, 1L);
199188
#ifdef __APPLE__
200189
curl_easy_setopt(m_curl_session, CURLOPT_SSL_VERIFYHOST, 0L);

src/utils/string_utils.cpp

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -896,18 +896,46 @@ namespace StringUtils
896896
std::string removeWhitespaces(const std::string& input)
897897
{
898898
std::string out;
899-
899+
900900
for (char ch : input)
901901
{
902902
if (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r')
903903
continue;
904-
904+
905905
out += ch;
906906
}
907-
907+
908908
return out;
909909
}
910910

911+
// ------------------------------------------------------------------------
912+
std::string getHostNameFromURL(const std::string& url)
913+
{
914+
// Not even a valid URL
915+
if (url.length() < 8)
916+
return "";
917+
918+
// protocol is substr(0, first_color_position)
919+
const size_t first_colon_position = url.find_first_of(":");
920+
if (first_colon_position == std::string::npos)
921+
return "";
922+
923+
// skip ://
924+
const std::string url_without_protocol = url.substr(first_colon_position + 3);
925+
926+
// Find end with port
927+
const size_t port_colon_position = url_without_protocol.find_first_of(":");
928+
if (port_colon_position != std::string::npos)
929+
return url_without_protocol.substr(0, port_colon_position);
930+
931+
// Find end with path
932+
const size_t slash_position = url_without_protocol.find_first_of("/");
933+
if (slash_position != std::string::npos)
934+
return url_without_protocol.substr(0, slash_position);
935+
936+
return url_without_protocol;
937+
}
938+
911939
// ------------------------------------------------------------------------
912940
/** Breaks the text so that each line is smaller than max_width with the current settings.
913941
* The result is put into output, a vector of strings, with each line having its own string */

0 commit comments

Comments
 (0)