* Added the "-c" command line option to generate optional cookies indicating
authorArt Cancro <ajc@citadel.org>
Wed, 22 Aug 2001 16:38:06 +0000 (16:38 +0000)
committerArt Cancro <ajc@citadel.org>
Wed, 22 Aug 2001 16:38:06 +0000 (16:38 +0000)
  the host name of the server.  This makes it easy to put a cluster of WebCit
  servers behind (for example) an Arrowpoint load balancer.

webcit/ChangeLog
webcit/README.txt
webcit/webcit.c
webcit/webcit.h
webcit/webserver.c

index 3a2c25b3d26d8e6955327cefeddcc53b2b2c9abc..cc171b84f559d9e8763ff6d130e2b17277a572dc 100644 (file)
@@ -1,4 +1,9 @@
 $Log$
+Revision 301.6  2001/08/22 16:38:06  ajc
+* Added the "-c" command line option to generate optional cookies indicating
+  the host name of the server.  This makes it easy to put a cluster of WebCit
+  servers behind (for example) an Arrowpoint load balancer.
+
 Revision 301.5  2001/08/21 04:02:56  ajc
 * Added some more meta-tags to (hopefully) prevent the "lame goto" caused by
   unwanted page caching
@@ -619,3 +624,4 @@ Sun Dec  6 19:50:55 EST 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
 
 1998-12-03 Nathan Bryant <bryant@cs.usm.maine.edu>
        * webserver.c: warning fix
+
index 658e019c2480cd41f549e6cde93096b13857b788..4dd93b1964043bfdf9a34e292a1b0b96cf7383d5 100644 (file)
@@ -61,11 +61,11 @@ any reason.  Open /etc/inittab and add an entry something like this:
  Several command-line options are also available.  Here's the usage for
 the "webserver" program:
   
- webserver [-p localport] [-t tracefile] [remotehost [remoteport]]
+ webserver [-p localport] [-t tracefile] [-c] [remotehost [remoteport]]
  
    *or*
  
- webserver [-p localport] [-t tracefile] uds /your/citadel/directory
+ webserver [-p localport] [-t tracefile] [-c] uds /your/citadel/directory
  
  Explained: 
   
@@ -77,6 +77,13 @@ the "webserver" program:
   -> tracefile: where you want WebCit to log to.  This can be a file, a
      virtual console, or /dev/null to suppress logging altogether.
  
+  -> The "-c" option causes WebCit to output an extra cookie containing the
+     identity of the WebCit server.  The cookie will look like this:
+       Set-cookie: wcserver=your.host.name
+     This is useful if you have a cluster of WebCit servers sitting behind a
+     load balancer, and the load balancer has the ability to use cookies to
+     keep track of which server to send HTTP requests to.
   -> remotehost: the name or IP address of the host on which your Citadel/UX
      server is running.  The default is "localhost".  (NOTE: if you run
      WebCit and the Citadel/UX server on different hosts, the real-time chat
index e936f2b5f37a8ef5eea011175a5cb71c6b58cab9..243edf6c8b332775ffb375523a98c79bd98e8d1f 100644 (file)
@@ -315,6 +315,9 @@ void output_headers(int controlcode)
                wprintf("Set-cookie: webcit=%s\n", unset);
        } else {
                wprintf("Set-cookie: webcit=%s\n", cookie);
+               if (server_cookie != NULL) {
+                       wprintf("%s\n", server_cookie);
+               }
        }
 
        if (print_standard_html_head > 0) {
@@ -324,7 +327,7 @@ void output_headers(int controlcode)
                wprintf("</TITLE>\n"
                        "<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">\n"
                        "<META HTTP-EQUIV=\"expired\" CONTENT=\"28-May-1971 18:10:00 GMT\">\n"
-                       "<meta name=\"MSSmartTagsPreventParsing\" content=\"TRUE\">\n");
+                       "<META NAME=\"MSSmartTagsPreventParsing\" CONTENT=\"TRUE\">\n");
                if (refresh30) wprintf(
                        "<META HTTP-EQUIV=\"refresh\" CONTENT=\"30\">\n");
                else wprintf(
index faca0d6ad605cb9878a096078337cf9d00b0fa53..5bdbd4158f4a2d8c45bed6f45393e669b51ccb8e 100644 (file)
@@ -156,6 +156,7 @@ struct serv_info serv_info;
 extern char floorlist[128][256];
 extern char *axdefs[];
 extern char *defaulthost, *defaultport;
+extern char *server_cookie;
 
 extern struct wcsubst *global_subst;
 
index d86bfcb86b7dc1578c59c548798540dbc967bc03..2f05519fab730aa8fdb63ddfe2ad612fee1e551d 100644 (file)
@@ -48,7 +48,7 @@ extern pthread_mutex_t SessionListMutex;
 extern pthread_key_t MyConKey;
 
 
-
+char *server_cookie = NULL;
 
 
 char *defaulthost = DEFAULT_HOST;
@@ -228,7 +228,7 @@ int main(int argc, char **argv)
        char tracefile[PATH_MAX];
 
        /* Parse command line */
-       while ((a = getopt(argc, argv, "hp:t:")) != EOF)
+       while ((a = getopt(argc, argv, "hp:t:c")) != EOF)
                switch (a) {
                case 'p':
                        port = atoi(optarg);
@@ -239,9 +239,22 @@ int main(int argc, char **argv)
                        freopen(tracefile, "w", stderr);
                        freopen(tracefile, "r", stdin);
                        break;
+               case 'c':
+                       server_cookie = malloc(256);
+                       if (server_cookie != NULL) {
+                               strcpy(server_cookie, "Set-cookie: wcserver=");
+                               if (gethostname(
+                                  &server_cookie[strlen(server_cookie)],
+                                  200) != 0) {
+                                       fprintf(stderr, "gethostname: %s\n",
+                                               strerror(errno));
+                                       free(server_cookie);
+                               }
+                       }
+                       break;
                default:
                        fprintf(stderr, "usage: webserver [-p localport] "
-                               "[-t tracefile] "
+                               "[-t tracefile] [-c] "
                                "[remotehost [remoteport]]\n");
                        return 1;
                }