#include "class.h"
#include "client.h"
#include "crule.h"
+#include "destruct_event.h"
#include "hash.h"
#include "ircd_alloc.h"
#include "ircd_events.h"
* External stuff
*--------------------------------------------------------------------------*/
extern void init_counters(void);
+extern void mem_dbg_initialise(void);
/*----------------------------------------------------------------------------
* Constants / Enums
static struct Timer connect_timer; /* timer structure for try_connections() */
static struct Timer ping_timer; /* timer structure for check_pings() */
+static struct Timer destruct_event_timer; /* timer structure for exec_expired_destruct_events() */
static struct Daemon thisServer = { 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0 };
struct ConnectionClass* cltmp;
struct ConfItem* con_conf = 0;
struct Jupe* ajupe;
- unsigned int con_class = 0;
+ const char* con_class = NULL;
assert(ET_EXPIRE == ev_type(ev));
assert(0 != ev_timer(ev));
Debug((DEBUG_NOTICE, "Connection check at : %s", myctime(CurrentTime)));
for (aconf = GlobalConfList; aconf; aconf = aconf->next) {
/* Also when already connecting! (update holdtimes) --SRB */
- if (!(aconf->status & CONF_SERVER) || aconf->port == 0)
+ if (!(aconf->status & CONF_SERVER) || aconf->port == 0 || aconf->hold == 0)
continue;
/* Also skip juped servers */
cltmp = aconf->conn_class;
confrq = get_con_freq(cltmp);
- aconf->hold = CurrentTime + confrq;
+ if(confrq == 0)
+ aconf->hold = next = 0;
+ else
+ aconf->hold = CurrentTime + confrq;
/* Found a CONNECT config with port specified, scan clients and see if
* this server is already connected?
cptr = FindServer(aconf->name);
if (!cptr && (Links(cltmp) < MaxLinks(cltmp)) &&
- (!connecting || (ConClass(cltmp) > con_class))) {
+ (!connecting /*|| (ConClass(cltmp) > con_class)*/)) {
/*
* Check connect rules to see if we're allowed to try
*/
continue;
}
- /* Quit the client after max_ping*2 - they should have answered by now */
- if (CurrentTime-cli_lasttime(cptr) >= (max_ping*2) ) {
- /* If it was a server, then tell ops about it. */
- if (IsServer(cptr) || IsConnecting(cptr) || IsHandshake(cptr))
- sendto_opmask_butone(0, SNO_OLDSNO,
- "No response from %s, closing link",
- cli_name(cptr));
- exit_client_msg(cptr, cptr, &me, "Ping timeout");
- continue;
- }
-
/* Unregistered clients pingout after max_ping seconds, they don't
* get given a second chance - if they were then people could not quite
* finish registration and hold resources without being subject to k/g
":Your client may not be compatible with this server.");
send_reply(cptr, SND_EXPLICIT | ERR_BADPING,
":Compatible clients are available at "
- "ftp://ftp.undernet.org/pub/irc/clients");
+ URL_CLIENTS);
}
exit_client_msg(cptr,cptr,&me, "Ping Timeout");
continue;
sendcmdto_one(&me, CMD_PING, cptr, ":%s", cli_name(&me));
}
+ /* Quit the client after max_ping*2 - they should have answered by now */
+ if (CurrentTime-cli_lasttime(cptr) >= (max_ping*2) ) {
+ /* If it was a server, then tell ops about it. */
+ if (IsServer(cptr) || IsConnecting(cptr) || IsHandshake(cptr))
+ sendto_opmask_butone(0, SNO_OLDSNO,
+ "No response from %s, closing link",
+ cli_name(cptr));
+ exit_client_msg(cptr, cptr, &me, "Ping timeout");
+ continue;
+ }
+
expire = cli_lasttime(cptr) + max_ping * 2;
if (expire < next_check)
next_check=expire;
case 'd': dpath = optarg; break;
case 'f': configfile = optarg; break;
case 'h': ircd_strncpy(cli_name(&me), optarg, HOSTLEN); break;
- case 'v': printf("ircd %s\n", version); exit(0);
+ case 'v':
+ printf("ircd %s\n", version);
+ printf("Event engines: ");
+#ifdef USE_KQUEUE
+ printf("kqueue() ");
+#endif
+#ifdef USE_DEVPOLL
+ printf("/dev/poll ");
+#endif
+#ifdef USE_POLL
+ printf("poll()");
+#else
+ printf("select()");
+#endif
+ printf("\nCompiled for a maximum of %d connections.\n", MAXCONNECTIONS);
+
+
+ exit(0);
+ break;
case 'x':
debuglevel = atoi(optarg);
fprintf(stderr,
"Check on %cPATH (%s) failed: %s\n"
- "Please create file and/or rerun `make config' and "
- "recompile to correct this.\n",
- which, path, strerror(errno));
-
-#ifdef CHROOTDIR
- fprintf(stderr, "Keep in mind that paths are relative to CHROOTDIR.\n");
-#endif
+ "Please create this file and/or rerun `configure' "
+ "using --with-%cpath and recompile to correct this.\n",
+ which, path, strerror(errno), which);
return 0;
}
-/*----------------------------------------------------------------------------
- * set_chroot_environment
- *--------------------------------------------------------------------------*/
-#ifdef CHROOTDIR
-static char set_chroot_environment(void) {
- /* Must be root to chroot! Silly if you ask me... */
- if (geteuid())
- seteuid(0);
-
- if (chdir(dpath)) {
- fprintf(stderr, "Fail: Cannot chdir(%s): %s\n", dpath, strerror(errno));
- return 0;
- }
- if (chroot(dpath)) {
- fprintf(stderr, "Fail: Cannot chroot(%s): %s\n", dpath, strerror(errno));
- return 0;
- }
- dpath = "/";
- return 1;
-}
-#endif
-
-
/*----------------------------------------------------------------------------
* set_userid_if_needed()
*--------------------------------------------------------------------------*/
static int set_userid_if_needed(void) {
- /* TODO: Drop privs correctly! */
-#if defined(IRC_GID) && defined(IRC_UID)
- setgid (IRC_GID);
- setegid(IRC_GID);
- setuid (IRC_UID);
- seteuid(IRC_UID);
-#endif
-
if (getuid() == 0 || geteuid() == 0 ||
getgid() == 0 || getegid() == 0) {
fprintf(stderr, "ERROR: This server will not run as superuser.\n");
thisServer.uid = getuid();
thisServer.euid = geteuid();
-#ifdef CHROOTDIR
- if (!set_chroot_environment())
- return 1;
+#ifdef MDEBUG
+ mem_dbg_initialise();
#endif
#if defined(HAVE_SETRLIMIT) && defined(RLIMIT_CORE)
if (!check_file_access(SPATH, 'S', X_OK) ||
!check_file_access(configfile, 'C', R_OK))
return 4;
-
-#ifdef DEBUG
- if (!check_file_access(LPATH, 'L', W_OK))
- return 5;
-#endif
debug_init(thisServer.bootopt & BOOT_TTY);
daemon_init(thisServer.bootopt & BOOT_TTY);
uping_init();
IPcheck_init();
- timer_add(&connect_timer, try_connections, 0, TT_RELATIVE, 1);
- timer_add(&ping_timer, check_pings, 0, TT_RELATIVE, 1);
+ timer_add(timer_init(&connect_timer), try_connections, 0, TT_RELATIVE, 1);
+ timer_add(timer_init(&ping_timer), check_pings, 0, TT_RELATIVE, 1);
+ timer_add(timer_init(&destruct_event_timer), exec_expired_destruct_events, 0, TT_PERIODIC, 60);
CurrentTime = time(NULL);