If the new keep-alive code is enabled, Keep-Alive headers are passed.
[privoxy.git] / project.h
index 19f7523..8b6c429 100644 (file)
--- a/project.h
+++ b/project.h
@@ -1,7 +1,7 @@
 #ifndef PROJECT_H_INCLUDED
 #define PROJECT_H_INCLUDED
 /** Version string. */
-#define PROJECT_H_VERSION "$Id: project.h,v 1.129 2009/03/08 14:12:51 fabiankeil Exp $"
+#define PROJECT_H_VERSION "$Id: project.h,v 1.136 2009/05/13 18:20:54 fabiankeil Exp $"
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/project.h,v $
  *
  * Revisions   :
  *    $Log: project.h,v $
+ *    Revision 1.136  2009/05/13 18:20:54  fabiankeil
+ *    There's no reason for keep_alive_timeout to be signed.
+ *
+ *    Revision 1.135  2009/05/10 10:19:23  fabiankeil
+ *    Reenable server-side-only keep-alive support, but only share
+ *    outgoing connections if the connection-sharing option is set.
+ *
+ *    Revision 1.134  2009/05/10 10:12:30  fabiankeil
+ *    Initial keep-alive support for the client socket.
+ *    Temporarily disable the server-side-only keep-alive code.
+ *
+ *    Revision 1.133  2009/04/24 15:29:43  fabiankeil
+ *    Allow to limit the number of of client connections.
+ *
+ *    Revision 1.132  2009/04/17 11:45:19  fabiankeil
+ *    Replace HAVE_GETADDRINFO and HAVE_GETNAMEINFO macros
+ *    with HAVE_RFC2553 macro. Original patch by Petr Pisar.
+ *
+ *    Revision 1.131  2009/04/17 11:34:35  fabiankeil
+ *    Style cosmetics for the IPv6 code.
+ *
+ *    Revision 1.130  2009/04/17 11:27:49  fabiankeil
+ *    Petr Pisar's privoxy-3.0.12-ipv6-3.diff.
+ *
  *    Revision 1.129  2009/03/08 14:12:51  fabiankeil
  *    All the CSP_FLAG_FOO bit masks should be unsigned ints.
  *
 /* Needed for pcre choice */
 #include "config.h"
 
-#ifdef HAVE_GETADDRINFO
+#ifdef HAVE_RFC2553
 /* Need for struct sockaddr_storage */
 #include <sys/socket.h>
 #endif
@@ -1291,6 +1315,31 @@ struct url_actions
 };
 
 
+/*
+ * Structure to make sure we only reuse the server socket
+ * if the host and forwarding settings are the same.
+ */
+struct reusable_connection
+{
+   jb_socket sfd;
+   int       in_use;
+   time_t    timestamp;
+   /*
+    * Number of seconds after which this
+    * connection will no longer be reused.
+    */
+   unsigned int keep_alive_timeout;
+
+   char *host;
+   int  port;
+   int  forwarder_type;
+   char *gateway_host;
+   int  gateway_port;
+   char *forward_host;
+   int  forward_port;
+};
+
+
 /*
  * Flags for use in csp->flags
  */
@@ -1330,15 +1379,15 @@ struct url_actions
 
 /**
  * Flag for csp->flags: Set if an acceptable Connection header
- * is already set.
+ * has already been set by the client.
  */
 #define CSP_FLAG_CLIENT_CONNECTION_HEADER_SET  0x00000040U
 
 /**
- * Flag for csp->flags: Set if adding the 'Connection: close' header
- * for the server isn't necessary.
+ * Flag for csp->flags: Set if an acceptable Connection header
+ * has already been set by the server.
  */
-#define CSP_FLAG_SERVER_CONNECTION_CLOSE_SET   0x00000080U
+#define CSP_FLAG_SERVER_CONNECTION_HEADER_SET  0x00000080U
 
 /**
  * Flag for csp->flags: Signals header parsers whether they
@@ -1377,6 +1426,12 @@ struct url_actions
  * content length.
  */
 #define CSP_FLAG_CONTENT_LENGTH_SET            0x00002000U
+
+/**
+ * Flag for csp->flags: Set if the client wants to keep
+ * the connection alive.
+ */
+#define CSP_FLAG_CLIENT_CONNECTION_KEEP_ALIVE  0x00004000U
 #endif /* def FEATURE_CONNECTION_KEEP_ALIVE */
 
 /*
@@ -1418,13 +1473,16 @@ struct client_state
    /** socket to talk to server (web server or proxy) */
    jb_socket sfd;
 
+   /** current connection to the server (may go through a proxy) */
+   struct reusable_connection server_connection;
+
    /** Multi-purpose flag container, see CSP_FLAG_* above */
    unsigned int flags;
 
    /** Client PC's IP address, as reported by the accept() function.
        As a string. */
    char *ip_addr_str;
-#ifdef HAVE_GETADDRINFO
+#ifdef HAVE_RFC2553
    /** Client PC's TCP address, as reported by the accept() function.
        As a sockaddr. */
    struct sockaddr_storage tcp_addr;
@@ -1432,7 +1490,7 @@ struct client_state
    /** Client PC's IP address, as reported by the accept() function.
        As a number. */
    unsigned long ip_addr_long;
-#endif /* def HAVE_GETADDRINFO */
+#endif /* def HAVE_RFC2553 */
 
    /** The URL that was requested */
    struct http_request http[1];
@@ -1666,14 +1724,14 @@ struct re_filterfile_spec
  */
 struct access_control_addr
 {
-#ifdef HAVE_GETADDRINFO
+#ifdef HAVE_RFC2553
    struct sockaddr_storage addr; /* <The TCP address in network order. */
    struct sockaddr_storage mask; /* <The TCP mask in network order. */
 #else
    unsigned long addr;  /**< The IP address as an integer. */
    unsigned long mask;  /**< The network mask as an integer. */
    unsigned long port;  /**< The port number. */
-#endif /* HAVE_GETADDRINFO */
+#endif /* HAVE_RFC2553 */
 };
 
 /**
@@ -1685,7 +1743,7 @@ struct access_control_list
 {
    struct access_control_addr src[1];  /**< Client IP address */
    struct access_control_addr dst[1];  /**< Website or parent proxy IP address */
-#ifdef HAVE_GETADDRINFO
+#ifdef HAVE_RFC2553
    int wildcard_dst;                   /** < dst address is wildcard */
 #endif
 
@@ -1724,6 +1782,9 @@ struct access_control_list
 /** configuration_spec::feature_flags: Try to keep the connection to the server alive. */
 #define RUNTIME_FEATURE_CONNECTION_KEEP_ALIVE      128U
 
+/** configuration_spec::feature_flags: Share outgoing connections between different client connections. */
+#define RUNTIME_FEATURE_CONNECTION_SHARING         256U
+
 /**
  * Data loaded from the configuration file.
  *
@@ -1817,11 +1878,19 @@ struct configuration_spec
    struct forward_spec *forward;
 
    /** Number of retries in case a forwarded connection attempt fails */
-   int         forwarded_connect_retries;
+   int forwarded_connect_retries;
+
+   /** Maximum number of client connections. */
+   int max_client_connections;
 
    /* Timeout when waiting on sockets for data to become available. */
    int socket_timeout;
 
+#ifdef FEATURE_CONNECTION_KEEP_ALIVE
+   /* Maximum number of seconds after which an open connection will no longer be reused. */
+   unsigned int keep_alive_timeout;
+#endif
+
    /** All options from the config file, HTML-formatted. */
    char *proxy_args;
 
@@ -1896,6 +1965,4 @@ struct configuration_spec
   Local Variables:
   tab-width: 3
   end:
-
-  vim:softtabstop=3 shiftwidth=3
 */