-const char jcc_rcs[] = "$Id: jcc.c,v 1.5 2001/05/22 18:46:04 oes Exp $";
+const char jcc_rcs[] = "$Id: jcc.c,v 1.9 2001/05/26 00:28:36 jongfoster Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/jcc.c,v $
*
* Revisions :
* $Log: jcc.c,v $
+ * Revision 1.9 2001/05/26 00:28:36 jongfoster
+ * Automatic reloading of config file.
+ * Removed obsolete SIGHUP support (Unix) and Reload menu option (Win32).
+ * Most of the global variables have been moved to a new
+ * struct configuration_spec, accessed through csp->config->globalname
+ * Most of the globals remaining are used by the Win32 GUI.
+ *
+ * Revision 1.8 2001/05/25 22:43:18 jongfoster
+ * Fixing minor memory leak and buffer overflow.
+ *
+ * Revision 1.7 2001/05/25 22:34:30 jongfoster
+ * Hard tabs->Spaces
+ *
+ * Revision 1.6 2001/05/23 00:13:58 joergs
+ * AmigaOS support fixed.
+ *
* Revision 1.5 2001/05/22 18:46:04 oes
*
* - Enabled filtering banners by size rather than URL
#ifdef FORCE_LOAD
/* If this request contains the FORCE_PREFIX,
- * better get rid of it now and set the force flag --oes
+ * better get rid of it now and set the force flag --oes
*/
- if(strstr(req, FORCE_PREFIX))
+ if (strstr(req, FORCE_PREFIX))
{
- strclean(req, FORCE_PREFIX);
- log_error(LOG_LEVEL_FORCE, "Enforcing request \"%s\".\n", req);
- csp->force = 1;
- }
+ strclean(req, FORCE_PREFIX);
+ log_error(LOG_LEVEL_FORCE, "Enforcing request \"%s\".\n", req);
+ csp->force = 1;
+ }
else
{
- csp->force = 0;
- }
+ csp->force = 0;
+ }
#endif /* def FORCE_LOAD */
parse_http_request(req, http, csp);
destroy_list(csp->headers);
- /* Check the request against all rules, unless
- * we're toggled off or in force mode.
+ /* Check the request against all rules, unless
+ * we're toggled off or in force mode.
*/
if (IS_TOGGLED_ON
IS_TRUSTED_URL
(p = block_url(http, csp))
#ifdef FAST_REDIRECTS
- || (fast_redirects && (p = redirect_url(http, csp)))
+ || (csp->config->fast_redirects && (p = redirect_url(http, csp)))
#endif /* def FAST_REDIRECTS */
))
{
#if defined(DETECT_MSIE_IMAGES) || defined(USE_IMAGE_LIST)
/* Block as image? */
- if ( (tinygif > 0) && block_imageurl(http, csp) )
+ if ( (csp->config->tinygif > 0) && block_imageurl(http, csp) )
{
/* Send "blocked" image */
log_error(LOG_LEVEL_GPC, "%s%s image crunch!",
http->hostport, http->path);
- if ((tinygif == 2) || strstr(http->path, "ijb-send-banner"))
+ if ((csp->config->tinygif == 2) || strstr(http->path, "ijb-send-banner"))
{
write_socket(csp->cfd, JBGIF, sizeof(JBGIF)-1);
}
- if (tinygif == 1)
+ else if (csp->config->tinygif == 1)
{
write_socket(csp->cfd, BLANKGIF, sizeof(BLANKGIF)-1);
}
- else if ((tinygif == 3) && (tinygifurl))
+ else if ((csp->config->tinygif == 3) && (csp->config->tinygifurl))
{
- p = (char *)malloc(strlen(HTTP_REDIRECT_TEMPLATE) + strlen(tinygifurl));
- sprintf(p, HTTP_REDIRECT_TEMPLATE, tinygifurl);
+ freez(p);
+ p = (char *)malloc(sizeof(HTTP_REDIRECT_TEMPLATE)
+ + strlen(csp->config->tinygifurl));
+ sprintf(p, HTTP_REDIRECT_TEMPLATE, csp->config->tinygifurl);
write_socket(csp->cfd, p, strlen(p));
}
else
configfile = argv[1];
}
- remove_all_loaders();
- memset( proxy_args, 0, sizeof( proxy_args ) );
files->next = NULL;
- load_config( 0 );
-
- /*
- * Since load_config acts as a signal handler too, it returns
- * its status in configret. Check it for an error in loading.
- */
- if ( 0 != configret )
- {
- /* load config failed! Exit with error. */
- return( 1 );
- }
-
#ifdef _WIN32
InitWin32();
#endif
#ifndef _WIN32
signal(SIGPIPE, SIG_IGN);
signal(SIGCHLD, SIG_IGN);
- signal(SIGHUP, load_config);
#else /* ifdef _WIN32 */
# ifdef _WIN_CONSOLE
{
struct client_state *csp = NULL;
int bfd;
+ struct configuration_spec * config;
+
+ config = load_config();
log_error(LOG_LEVEL_CONNECT, "bind (%s, %d)",
- haddr ? haddr : "INADDR_ANY", hport);
+ config->haddr ? config->haddr : "INADDR_ANY", config->hport);
- bfd = bind_port(haddr, hport);
- config_changed = 0;
+ bfd = bind_port(config->haddr, config->hport);
if (bfd < 0)
{
log_error(LOG_LEVEL_FATAL, "can't bind %s:%d: %E "
"- There may be another junkbuster or some other "
"proxy running on port %d",
- (NULL != haddr) ? haddr : "INADDR_ANY", hport, hport
+ (NULL != config->haddr) ? config->haddr : "INADDR_ANY",
+ config->hport, config->hport
);
/* shouldn't get here */
return;
}
+ config->need_bind = 0;
+
while (FOREVER)
{
csp->active = 1;
csp->sfd = -1;
- if ( config_changed )
+ csp->config = config = load_config();
+
+ if ( config->need_bind )
{
/*
* Since we were listening to the "old port", we will not see
* request. This should not be a so common of an operation
* that this will hurt people's feelings.
*/
+
close_socket(bfd);
log_error(LOG_LEVEL_CONNECT, "bind (%s, %d)",
- haddr ? haddr : "INADDR_ANY", hport);
- bfd = bind_port(haddr, hport);
+ config->haddr ? config->haddr : "INADDR_ANY", config->hport);
+ bfd = bind_port(config->haddr, config->hport);
- config_changed = 0;
+ if (bfd < 0)
+ {
+ log_error(LOG_LEVEL_FATAL, "can't bind %s:%d: %E "
+ "- There may be another junkbuster or some other "
+ "proxy running on port %d",
+ (NULL != config->haddr) ? config->haddr : "INADDR_ANY",
+ config->hport, config->hport
+ );
+ /* shouldn't get here */
+ return;
+ }
+
+ config->need_bind = 0;
}
log_error(LOG_LEVEL_CONNECT, "accept connection ... ");
{
exit(1);
}
-#endif
+#endif\r
+ freez(csp);
continue;
}
else
{
log_error(LOG_LEVEL_CONNECT, "OK");
- }
+ }\r
#if defined(TOGGLE)
/* by haroon - most of credit to srt19170 */
csp->toggled_on = g_bToggleIJB;
#endif
- /* add it to the list of clients */
- csp->next = clients->next;
- clients->next = csp;
-
if (run_loader(csp))
{
log_error(LOG_LEVEL_FATAL, "a loader failed - must exit");
/* Never get here - LOG_LEVEL_FATAL causes program exit */
}
-
- if (multi_threaded)
+\r
+ if (block_acl(NULL,csp))\r
+ {\r
+ log_error(LOG_LEVEL_CONNECT, "Connection dropped due to ACL");\r
+ close_socket(csp->cfd);\r
+ freez(csp);\r
+ continue;\r
+ }\r
+
+ /* add it to the list of clients */\r
+ csp->next = clients->next;\r
+ clients->next = csp;\r
+\r
+ if (config->multi_threaded)
{
int child_id;