From b263907bd84f1e45b7e4757627efdaccfa92abc3 Mon Sep 17 00:00:00 2001 From: stskeeps Date: Sat, 3 Feb 2001 19:07:21 +0000 Subject: [PATCH] +- Classes keep reference counts now, and moving classes (oper) works good + too. +- Added /trace class search results (class->clients) --- Changes | 3 +++ include/struct.h | 2 ++ src/list.c | 1 + src/parse.c | 3 --- src/s_conf2.c | 12 ++++++++++-- src/s_misc.c | 2 ++ src/s_serv.c | 9 ++++----- src/s_user.c | 33 ++++++++++++--------------------- 8 files changed, 34 insertions(+), 31 deletions(-) diff --git a/Changes b/Changes index add5ddba5..c00e7fbd0 100644 --- a/Changes +++ b/Changes @@ -176,3 +176,6 @@ - Fixed a little problem with SERVER servername :info crashing the ircd Long live the Floridan way of counting - ban server {} works the original way it was intended to now +- Classes keep reference counts now, and moving classes (oper) works good + too. +- Added /trace class search results (class->clients) diff --git a/include/struct.h b/include/struct.h index b0bc263da..7ebde0324 100644 --- a/include/struct.h +++ b/include/struct.h @@ -979,6 +979,8 @@ struct _configitem_class { int pingfreq; int maxclients; int sendq; + + int clients; }; struct _configitem_allow { diff --git a/src/list.c b/src/list.c index 9b12600b8..58af64ed6 100644 --- a/src/list.c +++ b/src/list.c @@ -289,6 +289,7 @@ void remove_client_from_list(cptr) add_history(cptr, 0); off_history(cptr); /* Remove all pointers to cptr */ } + if (cptr->user) (void)free_user(cptr->user, cptr); if (cptr->serv) diff --git a/src/parse.c b/src/parse.c index cf8bb1e87..cc8f58bc8 100644 --- a/src/parse.c +++ b/src/parse.c @@ -172,7 +172,6 @@ void ban_flooder(aClient *cptr) }; strcpy(hostip, (char *)inetntoa((char *)&cptr->ip)); -// exit_client(cptr, cptr, &me, "Flooding"); tkllayer[4] = hostip; tkllayer[5] = me.name; @@ -210,8 +209,6 @@ int parse(cptr, buffer, bufend, mptr) if (IsDead(cptr)) return 0; -// sendto_realops("Debug: parse(): %s", buffer); - if ((cptr->receiveK >= 4) && IsUnknown(cptr)) { sendto_realops("Flood from unknown connection %s detected", diff --git a/src/s_conf2.c b/src/s_conf2.c index 6ec8c0b7f..25090c64f 100644 --- a/src/s_conf2.c +++ b/src/s_conf2.c @@ -2194,8 +2194,16 @@ int AllowClient(aClient *cptr, struct hostent *hp, char *sockhost) { MyFree(cptr->passwd); cptr->passwd = NULL; - } - cptr->class = aconf->class; + } + if (!((aconf->class->clients + 1) > aconf->class->maxclients)) + { + cptr->class = aconf->class; + cptr->class->clients++; + } + else + { + return -3; + } return 0; } return -1; diff --git a/src/s_misc.c b/src/s_misc.c index 00ba4071c..cf04cb39f 100644 --- a/src/s_misc.c +++ b/src/s_misc.c @@ -440,6 +440,8 @@ int exit_client(cptr, sptr, from, comment) if (IsServer(sptr)) delfrom_fdlist(sptr->fd, &serv_fdlist); #endif + if (sptr->class) + sptr->class->clients--; if (IsClient(sptr)) IRCstats.me_clients--; if (IsServer(sptr)) diff --git a/src/s_serv.c b/src/s_serv.c index de8dbb593..303705cf8 100644 --- a/src/s_serv.c +++ b/src/s_serv.c @@ -4160,7 +4160,7 @@ int m_trace(cptr, sptr, parc, parv) { int i; aClient *acptr; - aClass *cltmp; + ConfigItem_class *cltmp; char *tname; int doall, link_s[MAXCONNECTIONS], link_u[MAXCONNECTIONS]; int cnt = 0, wilds, dow; @@ -4338,11 +4338,10 @@ int m_trace(cptr, sptr, parc, parv) link_u[me.fd], me.name, "*", "*", me.name); return 0; } -/* for (cltmp = FirstClass(); doall && cltmp; cltmp = NextClass(cltmp)) - if (Links(cltmp) > 0) + for (cltmp = conf_class; doall && cltmp; cltmp = (ConfigItem_class *) cltmp->next) + if (cltmp->clients > 0) sendto_one(sptr, rpl_str(RPL_TRACECLASS), me.name, - parv[0], Class(cltmp), Links(cltmp)); -*/ + parv[0], cltmp->name ? cltmp->name : "[noname]", cltmp->clients); return 0; } diff --git a/src/s_user.c b/src/s_user.c index ecf675026..d36b50011 100644 --- a/src/s_user.c +++ b/src/s_user.c @@ -742,16 +742,13 @@ static int register_user(cptr, sptr, nick, username, umode, virthost) i == -3 ? "Too many connections" : "Unauthorized connection", get_client_host(sptr)); ircstp->is_ref++; - tmpx = MyMalloc(1024); - ircsprintf(tmpx, "This server is full. Please try %s", + ircsprintf(mo, "This server is full. Please try %s", defserv); - xx = + return exit_client(cptr, sptr, &me, i == - -3 ? tmpx : + -3 ? mo : "You are not authorized to connect to this server"); - MyFree(tmpx); - return xx; } if (sptr->hostp) { @@ -3226,7 +3223,7 @@ int m_kill(cptr, sptr, parc, parv) continue; } sendto_one(sptr, - ":%s NOTICE %s :KILL changed from %s to %s", + ":%s NOTICE %s :*** KILL changed from %s to %s", me.name, parv[0], nick, acptr->name); chasing = 1; } @@ -3252,18 +3249,6 @@ int m_kill(cptr, sptr, parc, parv) parv[0], parv[1]); return 0; } -/* if (IsULine(sptr) || (IsSAdmin(sptr) && !IsSAdmin(acptr)) || (IsNetAdmin(sptr)) || (IsTechAdmin(sptr) || (IsCoAdmin(sptr)))) { - goto aftermath; - } else if (IsULine(acptr)) { - goto error; - } else { - goto aftermath; - } - - error: - - return 0; -*/ aftermath: /* From here on, the kill is probably going to be successful. */ @@ -3273,7 +3258,7 @@ int m_kill(cptr, sptr, parc, parv) if (!IsServer(sptr) && (kcount > MAXKILLS)) { sendto_one(sptr, - ":%s NOTICE %s :Too many targets, kill list was truncated. Maximum is %d.", + ":%s NOTICE %s :*** Too many targets, kill list was truncated. Maximum is %d.", me.name, parv[0], MAXKILLS); break; } @@ -3777,11 +3762,17 @@ int m_oper(cptr, sptr, parc, parv) #else /* CRYPT_OPER_PASSWORD */ encr = password; #endif /* CRYPT_OPER_PASSWORD */ - if (StrEq(encr, aconf->password)) { int old = (sptr->umodes & ALL_UMODES); char *s; + + /* Put in the right class */ + if (sptr->class) + sptr->class->clients--; + + sptr->class = aconf->class; + sptr->class->clients++; if ((aconf->oflags & OFLAG_HELPOP)) {