tDocument switch to libcurl - vaccinewars - be a doctor and try to vaccinate the world
git clone git://src.adamsgaard.dk/vaccinewars
Log
Files
Refs
README
LICENSE
---
commit 911e3d0b81eaa0cfb2ec75a3d8394906cff257c5
parent 826c6ac4c313c45fad652728ea9002483507ef9a
Author: Ben Webb 
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(-)
---
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).
 
diff --git a/doc/configfile.html b/doc/configfile.html
t@@ -202,31 +202,13 @@ is replaced by FALSE the server will not report to the metaserver.
 This setting, if set to TRUE, can be overridden by the -S
 command line option.
 
-
MetaServer.Name="dopewars.sourceforge.net"
-
Tells dopewars that the metaserver is located at -dopewars.sourceforge.net. See the -metaserver page, and below, for information -about connecting to the dopewars metaserver via a proxy web server.
- -
MetaServer.Port=80
-
Instructs dopewars that the metaserver can be found on TCP port -80. This is the standard HTTP port for Web access. (You shouldn't need -to change this, even if you connect via a proxy.)
- -
MetaServer.ProxyName="proxy.com"
-
Sends all requests to the metaserver via the web proxy at proxy.com. -If this is set to a blank string (the default) then the connection to the -metaserver is made directly.
- -
MetaServer.ProxyPort=8080
-
Connects to the web proxy on port 8080. (It then connects to the -metaserver on the port specified by MetaServer.Port.) This variable is ignored -if MetaServer.ProxyName is blank.
- -
MetaServer.Path="/metaserver.php"
-
Tells dopewars that the PHP script on the metaserver, for server -registration (server mode) or listing the available servers (client mode) is -/metaserver.php.
+
MetaServer.URL="https://dopewars.sourceforge.io/metaserver.php"
+
Tells dopewars that the metaserver PHP script is located at +https://dopewars.sourceforge.io/metaserver.php. This is used for server +registration (server mode) or listing the available servers (client mode); +see the metaserver page. If a proxy is needed to +connect to the web server, set the +https_proxy environment variable.
MetaServer.Comment="dopewars server"
t@@ -248,28 +230,6 @@ See the metaserver page for more details.
Uses the password auth to authenticate your dopewars server's hostname (see MetaServer.LocalName above) with the metaserver.
-
MetaServer.UseSocks=FALSE
-
Even if "Socks.Active" is TRUE, do not use SOCKS for metaserver -communication - connect directly to the metaserver or proxy.
- -
MetaServer.Auth.User=""
-
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.)
- -
MetaServer.Auth.Password=""
-
The corresponding password for MetaServer.Auth.User, above.
- -
MetaServer.Proxy.User=""
-
In a similar way to MetaServer.Auth.User, above, this enables a dopewars -server or AI player to authenticate itself with a web proxy.
- -
MetaServer.Proxy.Password=""
-
The corresponding password for MetaServer.Proxy.User, above.
-

Basic configuration: places in the game

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

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 proxy.com on port 8080 then you should -add the following lines to your dopewars -configuration file:-
-MetaServer.ProxyName="proxy.com"
-MetaServer.ProxyPort=8080

+most machines which have web access. If you require a proxy to connect to +the Web, set the https_proxy environment variable.

Using the metaserver from the server

People running servers who do not want their details listed by the

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