#ifndef PROJECT_H_INCLUDED
#define PROJECT_H_INCLUDED
-#define PROJECT_H_VERSION "$Id: project.h,v 1.33 2001/09/20 13:30:08 steudten Exp $"
+#define PROJECT_H_VERSION "$Id: project.h,v 1.37 2001/10/14 22:14:01 jongfoster Exp $"
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/project.h,v $
*
* Revisions :
* $Log: project.h,v $
+ * Revision 1.37 2001/10/14 22:14:01 jongfoster
+ * Removing name_length field from struct cgi_dispatcher, as this is
+ * now calculated at runtime from the "name" field.
+ *
+ * Revision 1.36 2001/10/10 16:45:15 oes
+ * Added LIMIT_CONNECT action and string
+ * Fixed HTTP message line termination
+ * Added CFORBIDDEN HTTP message
+ *
+ * Revision 1.35 2001/10/07 18:06:43 oes
+ * Added status member to struct http_request
+ *
+ * Revision 1.34 2001/10/07 15:45:25 oes
+ * Added url member to struct http_request and commented all
+ * members
+ *
+ * Added CT_TABOO
+ *
+ * Added ACTION_DOWNGRADE and ACTION_NO_COMPRESSION
+ *
+ * Replaced struct client_state members rejected,
+ * force, active and toggled_on with "flags" bitmap.
+ *
+ * Added CSP_FLAG_MODIFIED and CSP_FLAG_CHUNKED
+ *
+ * Added buffer_limit to struct configuration_spec
+ *
* Revision 1.33 2001/09/20 13:30:08 steudten
*
* Make freez() more secure in case of: if (exp) { free(z) ; a=*z }
extern "C" {
#endif
+
+/*
+ * Error codes. Functions returning these should return a jb_err
+ */
+#define JB_ERR_OK 0 /* Success, no error */
+#define JB_ERR_MEMORY 1 /* Out of memory */
+#define JB_ERR_CGI_PARAMS 2 /* Missing or corrupt CGI parameters */
+#define JB_ERR_FILE 3 /* Error opening, reading or writing a file */
+#define JB_ERR_PARSE 4 /* Error parsing file */
+#define JB_ERR_MODIFIED 5 /* File has been modified outside of the */
+ /* CGI actions editor. */
+typedef int jb_err;
+
+
+/*
+ * This macro is used to free a pointer that may be NULL
+ */
#define freez(X) { if(X) { free(X); X = NULL ; } }
+/*
+ * Use for statically allocated buffers if you have no other choice.
+ * Remember to check the length of what you write into the buffer
+ * - we don't want any buffer overflows!
+ */
#define BUFFER_SIZE 5000
+/*
+ * So you can say "while (FOREVER) { ...do something... }"
+ */
#define FOREVER 1
/* Default IP and port to listen on */
char *gpc; /* HTTP method: GET, POST, .. */
char *url; /* The URL */
char *ver; /* Protocol version */
+ int status; /* HTTP Status */
char *host; /* Host part of URL */
int port; /* Port of URL or 80 (default) */
#define ACTION_NO_COOKIE_SET 0x2000U
#define ACTION_NO_POPUPS 0x4000U
#define ACTION_VANILLA_WAFER 0x8000U
-
+#define ACTION_LIMIT_CONNECT 0x010000U
#define ACTION_STRING_DEANIMATE 0
#define ACTION_STRING_FROM 1
#define ACTION_STRING_IMAGE_BLOCKER 2
#define ACTION_STRING_REFERER 3
#define ACTION_STRING_USER_AGENT 4
-#define ACTION_STRING_COUNT 5
-
+#define ACTION_STRING_LIMIT_CONNECT 5
+#define ACTION_STRING_COUNT 6
#define ACTION_MULTI_ADD_HEADER 0
#define ACTION_MULTI_WAFER 1
#define CSP_FLAG_REJECTED 0x10 /* Set if request was blocked. */
#define CSP_FLAG_TOGGLED_ON 0x20 /* Set if we are toggled on (FEATURE_TOGGLE) */
+/*
+ * The state of a JunkBuster processing thread.
+ */
struct client_state
{
/* The proxy's configuration */
};
+/*
+ * List of functions to run on a list of headers
+ */
struct parsers
{
char *str;
char *(*parser)(const struct parsers *, const char *, struct client_state *);
};
+
+/*
+ * List of available CGI functions.
+ */
struct cgi_dispatcher
{
- const char *name;
- int name_length;
- int (*handler)(struct client_state *csp, struct http_response *rsp, struct map *parameters);
- const char *description;
+ const char * const name;
+ jb_err (* const handler)(struct client_state *csp, struct http_response *rsp, const struct map *parameters);
+ const char * const description;
};
+
+/*
+ * A data file used by JunkBuster. Kept in a linked list.
+ */
struct file_list
{
/*
/* Maximum number of loaders (actions, re_filter, ...) */
#define NLOADERS 8
+
+#define RUNTIME_FEATURE_CGI_EDIT_ACTIONS 1
+#define RUNTIME_FEATURE_CGI_TOGGLE 2
+
+
/*
* Data loaded from the configuration file.
*
int debug;
int multi_threaded;
+ /* Features that can be enabled/disabled throuigh the config file */
+ unsigned feature_flags;
+
const char *logfile;
const char *confdir;
/* HTTP snipplets */
static const char CSUCCEED[] =
"HTTP/1.0 200 Connection established\n"
- "Proxy-Agent: IJ/" VERSION "\n\n";
+ "Proxy-Agent: IJ/" VERSION "\r\n\r\n";
static const char CHEADER[] =
- "HTTP/1.0 400 Invalid header received from browser\n\n";
+ "HTTP/1.0 400 Invalid header received from browser\r\n\r\n";
+
+static const char CFORBIDDEN[] =
+ "HTTP/1.0 403 Connection not allowable\r\nX-Hint: If you read this message interactively, then you know why this happens ,-)\r\n\r\n";
#ifdef __cplusplus
} /* extern "C" */