Skip to content

Commit

Permalink
Update config to use the new online servers & remove hardcoded certif…
Browse files Browse the repository at this point in the history
…icate (#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
  • Loading branch information
vampy authored and auriamg committed Jan 19, 2019
1 parent 2d219f2 commit edd1280
Show file tree
Hide file tree
Showing 15 changed files with 3,428 additions and 149 deletions.
4 changes: 2 additions & 2 deletions NETWORKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down Expand Up @@ -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.

Expand Down
21 changes: 0 additions & 21 deletions data/addons.supertuxkart.net.pem

This file was deleted.

3,218 changes: 3,218 additions & 0 deletions data/cacert.pem

Large diffs are not rendered by default.

23 changes: 22 additions & 1 deletion data/stk_config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions src/addons/addons_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down Expand Up @@ -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
Expand Down
54 changes: 38 additions & 16 deletions src/addons/news_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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;
}
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;
// 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;
}
}

// 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);
}
Expand Down
4 changes: 3 additions & 1 deletion src/config/hardware_stats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
21 changes: 19 additions & 2 deletions src/config/stk_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
Expand Down Expand Up @@ -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]);
}
Expand Down
17 changes: 16 additions & 1 deletion src/config/stk_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class STKConfig : public NoCopy

/** 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;

Expand Down Expand Up @@ -214,6 +214,21 @@ class STKConfig : public NoCopy
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
Expand Down
50 changes: 10 additions & 40 deletions src/config/user_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,15 @@ class MapUserConfigParam : public UserConfigParam
}
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];
}
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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 &
Expand Down Expand Up @@ -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",
Expand All @@ -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,
Expand Down Expand Up @@ -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") );
Expand Down
Loading

0 comments on commit edd1280

Please sign in to comment.