tSOCKS support for HTTP connections (controlled by MetaServer.UseSocks); documentation updates for SOCKS configuration variables - 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 f8dc591b26deac71c0a9bb30898186158bf1864f
 (DIR) parent da4d9b8e32c32e7aab338e77448f8084da14414a
 (HTM) Author: Ben Webb <ben@salilab.org>
       Date:   Sun,  7 Oct 2001 23:55:16 +0000
       
       SOCKS support for HTTP connections (controlled by MetaServer.UseSocks);
       documentation updates for SOCKS configuration variables
       
       
       Diffstat:
         M doc/configfile.html                 |      24 ++++++++++++++++++++++++
         M src/dopewars.c                      |       9 +++++++--
         M src/dopewars.h                      |       1 +
         M src/message.c                       |       1 +
         M src/network.c                       |       3 ++-
         M src/network.h                       |       1 +
         M src/serverside.c                    |       1 +
       
       7 files changed, 37 insertions(+), 3 deletions(-)
       ---
 (DIR) diff --git a/doc/configfile.html b/doc/configfile.html
       t@@ -87,6 +87,25 @@ This option can be overridden with the -o <a href="commandline.html#server">
        command line option</a> (but be sure to protect the brackets from the shell
        if you use one of the "special" names).
        
       +<dt><b>Socks.Active=<i>FALSE</i></b></a>
       +<dd>Instructs the dopewars client to connect directly to the given server,
       +without using an intermediate SOCKS server. If this is set to TRUE, all
       +connections go via. the SOCKS server. By default, SOCKS is not used for
       +metaserver communications - see the MetaServer.UseSocks variable. N.B. You
       +cannot run a dopewars server behind a SOCKS server, due to limitations in
       +the SOCKS protocol.
       +
       +<dt><b>Socks.Name=<i>socks</i></b></a>
       +<dd>If using SOCKS, sets the hostname of the SOCKS server to connect to to
       +be <i>"socks"</i>.
       +
       +<dt><b>Socks.Port=<i>1080</i></b></a>
       +<dd>Connects to the SOCKS server on TCP port <i>1080</i>.
       +
       +<dt><b>Socks.Version=<i>4</i></b></a>
       +<dd>Uses SOCKS version <i>4</i>. Version 5 is also supported; SOCKS5 servers
       +support username/password authentication, unlike SOCKS4.
       +
        <dt><a name="HiScoreFile"><b>HiScoreFile=<i>"/var/lib/dopewars.sco"</i></b></a>
        <dd>Tells the dopewars server (or the client, if running in single-player
        mode, not connected to a server) to use the file <i>/var/lib/dopewars.sco</i>
       t@@ -157,6 +176,11 @@ See the <a href="metaserver.html">metaserver page</a> for more details.
        <dt><b>MetaServer.Password=<i>"auth"</i></b>
        <dd>Uses the password <i>auth</i> to authenticate your dopewars server's
        hostname (see MetaServer.LocalName above) with the metaserver.
       +
       +<dt><b>MetaServer.UseSocks=<i>FALSE</i></b>
       +<dd>Even if "Socks.Active" is TRUE, do not use SOCKS for metaserver
       +communication - connect directly to the metaserver or proxy.
       +
        </dl>
        
        <h2><a name="places">Basic configuration: places in the game</a></h2>
 (DIR) diff --git a/src/dopewars.c b/src/dopewars.c
       t@@ -158,11 +158,12 @@ struct BITCH Bitch = {
           50000,150000
        };
        
       -struct METASERVER MetaServer = { FALSE,NULL,0,NULL,0,NULL,NULL,NULL,NULL };
       +struct METASERVER MetaServer = { FALSE,NULL,0,NULL,0,NULL,NULL,NULL,
       +                                 NULL,FALSE };
        
        struct METASERVER DefaultMetaServer = {
           TRUE,"dopewars.sourceforge.net",80,"",8080,"/metaserver.php",
       -   "","","dopewars server"
       +   "","","dopewars server", FALSE
        };
        
        SocksServer Socks = { NULL,0,0 };
       t@@ -223,6 +224,9 @@ struct GLOBALS Globals[] = {
           { NULL,NULL,NULL,&MetaServer.Comment,NULL,"MetaServer.Comment",
             N_("Server description, reported to the metaserver"),NULL,NULL,0,"",NULL,
             NULL },
       +   { NULL,&MetaServer.UseSocks,NULL,NULL,NULL,"MetaServer.UseSocks",
       +     N_("TRUE if SOCKS should be used for metaserver communication"),
       +     NULL,NULL,0,"",NULL,NULL },
           { NULL,NULL,NULL,&Pager,NULL,"Pager",
             N_("Program used to display multi-page output"),NULL,NULL,0,"",NULL,NULL },
           { &NumTurns,NULL,NULL,NULL,NULL,"NumTurns",
       t@@ -1240,6 +1244,7 @@ void CopyMetaServer(struct METASERVER *dest,struct METASERVER *src) {
           dest->Active=src->Active;
           dest->Port=src->Port;
           dest->ProxyPort=src->ProxyPort;
       +   dest->UseSocks=src->UseSocks;
           AssignName(&dest->Name,src->Name);
           AssignName(&dest->ProxyName,src->ProxyName);
           AssignName(&dest->Path,src->Path);
 (DIR) diff --git a/src/dopewars.h b/src/dopewars.h
       t@@ -83,6 +83,7 @@ struct METASERVER {
           gchar *ProxyName;
           unsigned ProxyPort;
           gchar *Path,*LocalName,*Password,*Comment;
       +   gboolean UseSocks;
        };
        
        struct PRICES {
 (DIR) diff --git a/src/message.c b/src/message.c
       t@@ -311,6 +311,7 @@ gboolean OpenMetaHttpConnection(HttpConnection **conn) {
                                   MetaServer.Path,METAVERSION);
           retval = OpenHttpConnection(conn,MetaServer.Name,MetaServer.Port,
                                       MetaServer.ProxyName,MetaServer.ProxyPort,
       +                               UseSocks && MetaServer.UseSocks ? &Socks : NULL,
                                       "GET",query,NULL,NULL);
           g_free(query);
           return retval;
 (DIR) diff --git a/src/network.c b/src/network.c
       t@@ -937,13 +937,14 @@ static gboolean StartHttpConnect(HttpConnection *conn) {
        
        gboolean OpenHttpConnection(HttpConnection **connpt,gchar *HostName,
                                    unsigned Port,gchar *Proxy,unsigned ProxyPort,
       +                            SocksServer *socks,
                                    gchar *Method,gchar *Query,
                                    gchar *Headers,gchar *Body) {
           HttpConnection *conn;
           g_assert(HostName && Method && Query && connpt);
        
           conn=g_new0(HttpConnection,1);
       -   InitNetworkBuffer(&conn->NetBuf,'\n','\r',NULL);
       +   InitNetworkBuffer(&conn->NetBuf,'\n','\r',socks);
           conn->HostName=g_strdup(HostName);
           if (Proxy && Proxy[0]) conn->Proxy=g_strdup(Proxy);
           conn->Method=g_strdup(Method);
 (DIR) diff --git a/src/network.h b/src/network.h
       t@@ -172,6 +172,7 @@ gchar *GetWaitingMessage(NetworkBuffer *NetBuf);
        
        gboolean OpenHttpConnection(HttpConnection **conn,gchar *HostName,
                                    unsigned Port,gchar *Proxy,unsigned ProxyPort,
       +                            SocksServer *socks,
                                    gchar *Method,gchar *Query,
                                    gchar *Headers,gchar *Body);
        void CloseHttpConnection(HttpConnection *conn);
 (DIR) diff --git a/src/serverside.c b/src/serverside.c
       t@@ -219,6 +219,7 @@ void RegisterWithMetaServer(gboolean Up,gboolean SendData,
           
           retval=OpenHttpConnection(&MetaConn,MetaServer.Name,MetaServer.Port,
                                     MetaServer.ProxyName,MetaServer.ProxyPort,
       +                             UseSocks && MetaServer.UseSocks ? &Socks : NULL,
                                     "POST",MetaServer.Path,headers->str,body->str);
           g_string_free(headers,TRUE);
           g_string_free(body,TRUE);