* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA.
- * $Id: clients.c,v 1.6 2001/06/02 04:21:02 a1kmm Exp $
+ * $Id: clients.c,v 1.7 2001/06/02 05:42:13 a1kmm Exp $
*/
#include <stdlib.h>
#include <string.h>
if ((svr = find_server(parv[1])) != NULL)
{
svr->introduced = timenow;
+ svr->last_kill_dec = timenow;
+ svr->skill_count = 0;
+ svr->okill_count = 0;
return;
}
svr = malloc(sizeof(*svr));
{
/* :doer KILL client :Reason */
struct User *usr;
+ struct Server *svr;
if (parc < 2)
return;
if (!strcasecmp(parv[1], sn))
- {
send_msg("NICK %s 1 1 +o services %s %s :* Services *", sn,
server_name, server_name);
- return;
+ else
+ if ((usr = find_user(parv[1])) != NULL)
+ destroy_user(usr);
+#ifdef USE_AUTOJUPE
+ if (((usr = find_user(sender))!=NULL && (svr=usr->server)!=NULL)
+ || (svr = find_server(sender)) != NULL)
+ {
+ if (timenow-svr->last_kill_dec > 60)
+ {
+ svr->skill_count = 0;
+ svr->okill_count = 0;
+ svr->last_kill_dec = timenow;
+ }
+ if (usr != NULL)
+ {
+ if (++svr->okill_count > OKILL_MAX)
+ place_autojupe(svr, "[Auto] Operator killing too fast; Probably "
+ "compromised operarator passwords.");
+ } else
+ {
+ if (++svr->skill_count > SKILL_MAX)
+ place_autojupe(svr, "[Auto] Server killing too fast; Probably "
+ "compromised server.");
+ }
}
- if ((usr = find_user(parv[1])) == NULL)
- return;
- destroy_user(usr);
+#endif
}
void
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA.
- * $Id: efserv.c,v 1.7 2001/05/31 08:52:04 a1kmm Exp $
+ * $Id: efserv.c,v 1.8 2001/06/02 05:42:13 a1kmm Exp $
*/
#include <stdarg.h>
{
va_list *val;
int i, l;
- char buffer[512], *p;
+ char buffer[BUFLEN], *p;
va_start(val, msg);
- vsnprintf(buffer, 510, msg, val);
+ vsnprintf(buffer, BUFLEN-1, msg, val);
va_end(val);
printf("Out: %s\n", buffer);
i = strlen(buffer);
{
struct Command *cmd;
int parc = 1;
- char *parv[256], *p, *sender;
+ char *parv[MAX_ARGS], *p, *sender;
if (len == 0)
return;
printf("In: %s\n", msg);
parv[0] = strtok(NULL, " ");
} else
sender = first_server ? first_server->name : NULL;
- for (p = strtok(NULL, " "); parc<256 && p; p = strtok(NULL, " "))
+ for (p = strtok(NULL, " "); parc<MAX_ARGS && p; p = strtok(NULL, " "))
{
if (*p != ':')
parv[parc++] = p;
{
static time_t
last_cleanup_jupes=0, last_cleanup_chans=0, last_cleanup_clones=0;
- if (timenow - last_cleanup_jupes > 10)
+ if (timenow - last_cleanup_jupes > JUPE_CLEANUP_TIME)
{
last_cleanup_jupes = timenow;
cleanup_jupes();
}
- if (timenow - last_cleanup_chans > 5)
+ if (timenow - last_cleanup_chans > CHANNEL_CLEANUP_TIME)
{
last_cleanup_chans = timenow;
cleanup_channels();
}
- if (timenow - last_cleanup_clones > 10)
+ if (timenow - last_cleanup_clones > CLONE_CLEANUP_TIME)
{
last_cleanup_clones = timenow;
cleanup_hosts();
void
do_main_loop(void)
{
- char read_buffer[2048], *p = read_buffer, *pe = read_buffer, *m;
+ char read_buffer[READLEN], *p = read_buffer, *pe = read_buffer, *m;
int rv, skip = 0;
do_setup_commands();
if (connected == 0)
while (reload_module == 0 && die == 0)
{
check_events();
- if ((rv = read(server_fd, p, 2048-(pe-read_buffer))) <= 0)
+ if ((rv = read(server_fd, p, READLEN-(pe-read_buffer))) <= 0)
{
if (rv < 0 && (errno == EAGAIN || errno == EINTR))
continue;
close(server_fd);
connected = 0;
log("[Hub] Connection to hub lost: send error.\n");
- sleep(3);
+ sleep(ERROR_SLEEP_TIME);
return;
}
skip = 0;
break;
m = p;
}
- if (m == read_buffer+2048)
+ if (m == read_buffer+READLEN)
skip = 1;
if (m != read_buffer && m != pe)
{
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA.
- * $Id: define.h,v 1.4 2001/06/02 04:21:03 a1kmm Exp $
+ * $Id: define.h,v 1.5 2001/06/02 05:42:14 a1kmm Exp $
*/
#define CHANNEL_DB PREFIX "efchans.db"
#define VERSION "pre0.1-test"
+#define OKILL_MAX 10
+#define SKILL_MAX 200
+
#define ETCPATH PREFIX "etc/"
+#define MAX_ARGS 256
+
+#define JUPE_CLEANUP_TIME 10
+#define CHANNEL_CLEANUP_TIME 5
+#define CLONE_CLEANUP_TIME 10
+#define BUFLEN 512
+#define READLEN 2048
+#define ERROR_SLEEP_TIME 3
+
/* Below this should not be changed on setup... */
#define UFLAG_ADMIN 0x00000001
#define UFLAG_OPER 0x00000002
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA.
- * $Id: struct.h,v 1.2 2001/06/02 04:21:04 a1kmm Exp $
+ * $Id: struct.h,v 1.3 2001/06/02 05:42:15 a1kmm Exp $
*/
struct Command
struct List *node;
struct Server *uplink;
struct Jupe *jupe;
- time_t introduced;
+ time_t introduced, last_kill_dec;
+ unsigned long okill_count, skill_count;
};
struct Channel