tDocument switch to libcurl - vaccinewars - be a doctor and try to vaccinate the world (HTM) git clone git://src.adamsgaard.dk/vaccinewars (DIR) Log (DIR) Files (DIR) Refs (DIR) README (DIR) LICENSE --- (DIR) commit 911e3d0b81eaa0cfb2ec75a3d8394906cff257c5 (DIR) parent 826c6ac4c313c45fad652728ea9002483507ef9a (HTM) Author: Ben Webb <ben@salilab.org> Date: Mon, 2 Nov 2020 23:52:15 -0800 Document switch to libcurl Diffstat: M ChangeLog | 7 +++++++ M doc/configfile.html | 54 ++++--------------------------- M doc/example-igneous | 2 -- M doc/metaserver.html | 11 ++--------- M src/dopewars.c | 37 +++---------------------------- M src/dopewars.h | 4 ---- M src/gui_client/optdialog.c | 12 ------------ M src/serverside.c | 43 ------------------------------ 8 files changed, 19 insertions(+), 151 deletions(-) --- (DIR) diff --git a/ChangeLog b/ChangeLog t@@ -7,6 +7,13 @@ SVN of these libraries to build dopewars. - Update metaserver to work with new SourceForge; older versions can no longer successfully register with the metaserver. + - Switch to using libcurl to talk to the metaserver (this supports https, + unlike the old internal code). The metaserver configuration has changed + accordingly; MetaServer.Name, MetaServer.Port and MetaServer.Path are + replaced with MetaServer.URL, and MetaServer.Auth, MetaServer.Proxy*, + and MetaServer.UseSocks are removed (set the https_proxy environment + variable instead, as per + https://curl.haxx.se/libcurl/c/libcurl-tutorial.html#Environment) - Fix for a DOS against the server using the REQUESTJET message type (thanks to Doug Prostko for reporting the problem). (DIR) diff --git a/doc/configfile.html b/doc/configfile.html t@@ -202,31 +202,13 @@ is replaced by <i>FALSE</i> the server will not report to the metaserver. This setting, if set to TRUE, can be overridden by the -S <a href="commandline.html#privateserver">command line option</a>.</dd> -<dt><b>MetaServer.Name=<i>"dopewars.sourceforge.net"</i></b></dt> -<dd>Tells dopewars that the metaserver is located at -<i>dopewars.sourceforge.net</i>. See the -<a href="metaserver.html">metaserver</a> page, and below, for information -about connecting to the dopewars metaserver via a proxy web server.</dd> - -<dt><b>MetaServer.Port=<i>80</i></b></dt> -<dd>Instructs dopewars that the metaserver can be found on TCP port -<i>80</i>. This is the standard HTTP port for Web access. (You shouldn't need -to change this, even if you connect via a proxy.)</dd> - -<dt><b>MetaServer.ProxyName=<i>"proxy.com"</i></b></dt> -<dd>Sends all requests to the metaserver via the web proxy at <i>proxy.com</i>. -If this is set to a blank string (the default) then the connection to the -metaserver is made directly.</dd> - -<dt><b>MetaServer.ProxyPort=<i>8080</i></b></dt> -<dd>Connects to the web proxy on port <i>8080</i>. (It then connects to the -metaserver on the port specified by MetaServer.Port.) This variable is ignored -if MetaServer.ProxyName is blank.</dd> - -<dt><b>MetaServer.Path=<i>"/metaserver.php"</i></b></dt> -<dd>Tells dopewars that the PHP script on the metaserver, for server -registration (server mode) or listing the available servers (client mode) is -<i>/metaserver.php</i>.</dd> +<dt><b>MetaServer.URL=<i>"https://dopewars.sourceforge.io/metaserver.php"</i></b></dt> +<dd>Tells dopewars that the metaserver PHP script is located at +<i>https://dopewars.sourceforge.io/metaserver.php</i>. This is used for server +registration (server mode) or listing the available servers (client mode); +see the <a href="metaserver.html">metaserver</a> page. If a proxy is needed to +connect to the web server, set the +<a href="https://curl.haxx.se/libcurl/c/libcurl-tutorial.html#Environment">https_proxy environment variable</a>.</dd> <dt><a id="MetaServerComment"><b>MetaServer.Comment=<i>"dopewars server"</i></b></a></dt> t@@ -248,28 +230,6 @@ See the <a href="metaserver.html">metaserver page</a> for more details.</dd> <dd>Uses the password <i>auth</i> to authenticate your dopewars server's hostname (see MetaServer.LocalName above) with the metaserver.</dd> -<dt><b>MetaServer.UseSocks=<i>FALSE</i></b></dt> -<dd>Even if "Socks.Active" is TRUE, do not use SOCKS for metaserver -communication - connect directly to the metaserver or proxy.</dd> - -<dt><b>MetaServer.Auth.User=<i>""</i></b></dt> -<dd>If the metaserver webpage is on a restricted access server (i.e. it -requires HTTP Basic authentication), and you wish to connect with the server -or AI player (which can both run unattended) then setting this variable to -something other than "" will enable them to authenticate themselves, -provided MetaServer.Auth.Password is also set. (The game clients prompt -the user for a username and password on each connect instead.)</dd> - -<dt><b>MetaServer.Auth.Password=<i>""</i></b></dt> -<dd>The corresponding password for MetaServer.Auth.User, above.</dd> - -<dt><b>MetaServer.Proxy.User=<i>""</i></b></dt> -<dd>In a similar way to MetaServer.Auth.User, above, this enables a dopewars -server or AI player to authenticate itself with a web proxy.</dd> - -<dt><b>MetaServer.Proxy.Password=<i>""</i></b></dt> -<dd>The corresponding password for MetaServer.Proxy.User, above.</dd> - </dl> <h2><a id="places">Basic configuration: places in the game</a></h2> (DIR) diff --git a/doc/example-igneous b/doc/example-igneous t@@ -1,7 +1,5 @@ ServerMOTD = "Welcome All, Play for as long as you like. !- MAKE SURE TO PAY OFF YOUR DEBT NOW -!" Port = 7902 -MetaServer.Port = 80 -MetaServer.ProxyPort = 0 MetaServer.Comment = "Igneous\'s MOD" NumTurns = 0 NumLocation = 87 (DIR) diff --git a/doc/metaserver.html b/doc/metaserver.html t@@ -55,15 +55,8 @@ and so there is at least a good chance that the servers listed there will be working.</p> <p>The metaserver, being an ordinary web page, should work happily on -most machines which have web access. A problem occurs, however, if your -connection to the Web is via an enforced proxy server (i.e. traffic on -port 80 from your machine is blocked by firewall). dopewars can be -configured to connect via a proxy server without too much difficulty; if -your proxy server is at <i>proxy.com</i> on port <i>8080</i> then you should -add the following lines to your dopewars <a href="configfile.html"> -configuration file</a>:-<br /> -<b>MetaServer.ProxyName="proxy.com"<br /> -MetaServer.ProxyPort=8080</b></p> +most machines which have web access. If you require a proxy to connect to +the Web, set the <a href="https://curl.haxx.se/libcurl/c/libcurl-tutorial.html#Environment">https_proxy environment variable</a>.</p> <h2><a id="server">Using the metaserver from the server</a></h2> <p>People running servers who <b>do not</b> want their details listed by the (DIR) diff --git a/src/dopewars.c b/src/dopewars.c t@@ -210,13 +210,12 @@ struct BITCH Bitch = { #ifdef NETWORKING struct METASERVER MetaServer = { - FALSE, NULL, NULL, 0, NULL, NULL, - NULL, FALSE, NULL, NULL, NULL, NULL + FALSE, NULL, NULL, NULL, NULL }; struct METASERVER DefaultMetaServer = { - TRUE, "https://dopewars.sourceforge.io/metaserver.php", "", 8080, - "", "", "dopewars server", FALSE, "", "", "", "" + TRUE, "https://dopewars.sourceforge.io/metaserver.php", "", + "", "dopewars server" }; SocksServer Socks = { NULL, 0, 0, FALSE, NULL, NULL, NULL }; t@@ -280,12 +279,6 @@ struct GLOBALS Globals[] = { {NULL, NULL, NULL, &MetaServer.URL, NULL, "MetaServer.URL", N_("Metaserver URL to report/get server details to/from"), NULL, NULL, 0, "", NULL, NULL, FALSE, 0, 0}, - {NULL, NULL, NULL, &MetaServer.ProxyName, NULL, "MetaServer.ProxyName", - N_("Name of a proxy for metaserver communication"), - NULL, NULL, 0, "", NULL, NULL, FALSE, 0, 0}, - {&MetaServer.ProxyPort, NULL, NULL, NULL, NULL, "MetaServer.ProxyPort", - N_("Port for communicating with the proxy server"), - NULL, NULL, 0, "", NULL, NULL, FALSE, 0, 65535}, {NULL, NULL, NULL, &MetaServer.LocalName, NULL, "MetaServer.LocalName", N_("Preferred hostname of your server machine"), NULL, NULL, 0, "", NULL, NULL, FALSE, 0, 0}, t@@ -295,23 +288,6 @@ struct GLOBALS Globals[] = { {NULL, NULL, NULL, &MetaServer.Comment, NULL, "MetaServer.Comment", N_("Server description, reported to the metaserver"), NULL, NULL, 0, "", NULL, NULL, FALSE, 0, 0}, - {NULL, &MetaServer.UseSocks, NULL, NULL, NULL, "MetaServer.UseSocks", - N_("If TRUE, use SOCKS for metaserver communication"), - NULL, NULL, 0, "", NULL, NULL, FALSE, 0, 0}, - {NULL, NULL, NULL, &MetaServer.authuser, NULL, "MetaServer.Auth.User", - N_("Username for HTTP Basic authentication"), - NULL, NULL, 0, "", NULL, NULL, FALSE, 0, 0}, - {NULL, NULL, NULL, &MetaServer.authpassword, NULL, - "MetaServer.Auth.Password", - N_("Password for HTTP Basic authentication"), - NULL, NULL, 0, "", NULL, NULL, FALSE, 0, 0}, - {NULL, NULL, NULL, &MetaServer.proxyuser, NULL, "MetaServer.Proxy.User", - N_("Username for HTTP Basic proxy authentication"), - NULL, NULL, 0, "", NULL, NULL, FALSE, 0, 0}, - {NULL, NULL, NULL, &MetaServer.proxypassword, NULL, - "MetaServer.Proxy.Password", - N_("Password for HTTP Basic proxy authentication"), - NULL, NULL, 0, "", NULL, NULL, FALSE, 0, 0}, #endif /* NETWORKING */ #ifdef CYGWIN {NULL, &MinToSysTray, NULL, NULL, NULL, "MinToSysTray", t@@ -1676,17 +1652,10 @@ void CopyNames(struct NAMES *dest, struct NAMES *src) void CopyMetaServer(struct METASERVER *dest, struct METASERVER *src) { dest->Active = src->Active; - dest->ProxyPort = src->ProxyPort; - dest->UseSocks = src->UseSocks; AssignName(&dest->URL, src->URL); - AssignName(&dest->ProxyName, src->ProxyName); AssignName(&dest->LocalName, src->LocalName); AssignName(&dest->Password, src->Password); AssignName(&dest->Comment, src->Comment); - AssignName(&dest->authuser, src->authuser); - AssignName(&dest->authpassword, src->authpassword); - AssignName(&dest->proxyuser, src->proxyuser); - AssignName(&dest->proxypassword, src->proxypassword); } #endif (DIR) diff --git a/src/dopewars.h b/src/dopewars.h t@@ -101,11 +101,7 @@ struct SOUNDS { struct METASERVER { gboolean Active; gchar *URL; - gchar *ProxyName; - unsigned ProxyPort; gchar *LocalName, *Password, *Comment; - gboolean UseSocks; - gchar *authuser, *authpassword, *proxyuser, *proxypassword; }; #endif (DIR) diff --git a/src/gui_client/optdialog.c b/src/gui_client/optdialog.c t@@ -920,18 +920,6 @@ void OptDialog(GtkWidget *widget, gpointer data) entry = NewConfigEntry("MetaServer.URL"); gtk_table_attach_defaults(GTK_TABLE(table), entry, 1, 4, 1, 2); - label = gtk_label_new(_("Web proxy hostname")); - gtk_table_attach(GTK_TABLE(table), label, 0, 1, 2, 3, - GTK_SHRINK, GTK_SHRINK, 0, 0); - entry = NewConfigEntry("MetaServer.ProxyName"); - gtk_table_attach_defaults(GTK_TABLE(table), entry, 1, 2, 2, 3); - - label = gtk_label_new(_("Port")); - gtk_table_attach(GTK_TABLE(table), label, 2, 3, 2, 3, - GTK_SHRINK, GTK_SHRINK, 0, 0); - entry = NewConfigEntry("MetaServer.ProxyPort"); - gtk_table_attach_defaults(GTK_TABLE(table), entry, 3, 4, 2, 3); - label = gtk_label_new(_("Comment")); gtk_table_attach(GTK_TABLE(table), label, 0, 1, 4, 5, GTK_SHRINK, GTK_SHRINK, 0, 0); (DIR) diff --git a/src/serverside.c b/src/serverside.c t@@ -168,49 +168,6 @@ void log_meta_headers(gpointer data, gpointer user_data) if (*header) dopelog(4, LF_SERVER, _("MetaServer: %s"), header); } - -static void ServerHttpAuth(HttpConnection *conn, gboolean proxyauth, - gchar *realm, gpointer data) -{ - gchar *user = NULL, *password = NULL; - - if (proxyauth) { - if (MetaServer.proxyuser[0] && MetaServer.proxypassword[0]) { - user = MetaServer.proxyuser; - password = MetaServer.proxypassword; - dopelog(3, LF_SERVER, - _("Using MetaServer.Proxy.User and " - "MetaServer.Proxy.Password for HTTP proxy authentication")); - } else { - dopelog(0, LF_SERVER, - _("Unable to authenticate with HTTP proxy; please " - "set MetaServer.Proxy.User and " - "MetaServer.Proxy.Password variables")); - } - } else { - if (MetaServer.authuser[0] && MetaServer.authpassword[0]) { - user = MetaServer.authuser; - password = MetaServer.authpassword; - dopelog(3, LF_SERVER, - _("Using MetaServer.Auth.User and MetaServer.Auth.Password " - "for HTTP authentication")); - } else { - dopelog(0, LF_SERVER, - _("Unable to authenticate with HTTP server; please set " - "MetaServer.Auth.User and " - "MetaServer.Auth.Password variables")); - } - } - SetHttpAuthentication(conn, proxyauth, user, password); -} - -static void ServerNetBufAuth(NetworkBuffer *netbuf, gpointer data) -{ - dopelog(3, LF_SERVER, - _("Using Socks.Auth.User and Socks.Auth.Password " - "for SOCKS5 authentication")); - SendSocks5UserPasswd(netbuf, Socks.authuser, Socks.authpassword); -} #endif /*