summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/users.h2
-rw-r--r--src/users.cpp34
-rw-r--r--src/xline.cpp73
3 files changed, 69 insertions, 40 deletions
diff --git a/include/users.h b/include/users.h
index 43150d169..c62e8617b 100644
--- a/include/users.h
+++ b/include/users.h
@@ -313,6 +313,8 @@ class userrec : public connection
*/
InvitedList* GetInviteList();
+ void MakeHost(char* nhost);
+
/** Shuts down and closes the user's socket
*/
void CloseSocket();
diff --git a/src/users.cpp b/src/users.cpp
index 2266075cb..256b04780 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -80,6 +80,18 @@ userrec::~userrec()
{
}
+void userrec::MakeHost(char* nhost)
+{
+ /* This is much faster than snprintf */
+ char* t = nhost;
+ for(char* n = ident; n; n++)
+ *t++ = *n;
+ *t++ = '@';
+ for(char* n = host; n; n++)
+ *t++ = *n;
+ *t = 0;
+}
+
void userrec::CloseSocket()
{
shutdown(this->fd,2);
@@ -89,7 +101,16 @@ void userrec::CloseSocket()
char* userrec::GetFullHost()
{
static char result[MAXBUF];
- snprintf(result,MAXBUF,"%s!%s@%s",nick,ident,dhost);
+ char* t = result;
+ for(char* n = nick; n; n++)
+ *t++ = *n;
+ *t++ = '!';
+ for(char* n = ident; n; n++)
+ *t++ = *n;
+ *t++ = '@';
+ for(char* n = dhost; n; n++)
+ *t++ = *n;
+ *t = 0;
return result;
}
@@ -106,7 +127,16 @@ int userrec::ReadData(void* buffer, size_t size)
char* userrec::GetFullRealHost()
{
static char fresult[MAXBUF];
- snprintf(fresult,MAXBUF,"%s!%s@%s",nick,ident,host);
+ char* t = fresult;
+ for(char* n = nick; n; n++)
+ *t++ = *n;
+ *t++ = '!';
+ for(char* n = ident; n; n++)
+ *t++ = *n;
+ *t++ = '@';
+ for(char* n = host; n; n++)
+ *t++ = *n;
+ *t = 0;
return fresult;
}
diff --git a/src/xline.cpp b/src/xline.cpp
index 4a7cfdea5..3437fe0d9 100644
--- a/src/xline.cpp
+++ b/src/xline.cpp
@@ -55,6 +55,7 @@ extern std::vector<Module*> modules;
extern std::vector<ircd_module*> factory;
extern ServerConfig* Config;
extern user_hash clientlist;
+extern std::vector<userrec*> local_users;
/* Version two, now with optimized expiry!
*
@@ -654,53 +655,49 @@ void apply_lines(const int What)
return;
CullList* Goners = new CullList();
-
- for (user_hash::const_iterator u = clientlist.begin(); u != clientlist.end(); u++)
+ for (std::vector<userrec*>::const_iterator u = local_users.begin(); u != local_users.end(); u++)
{
- if (u->second->fd > -1)
+ u->MakeHost(host);
+ if (elines.size())
{
- snprintf(host,MAXBUF,"%s@%s",u->second->ident,u->second->host);
- if (elines.size())
- {
- // ignore people matching exempts
- if (matches_exception(host))
- continue;
- }
- if ((What & APPLY_GLINES) && (glines.size() || pglines.size()))
+ // ignore people matching exempts
+ if (matches_exception(host))
+ continue;
+ }
+ if ((What & APPLY_GLINES) && (glines.size() || pglines.size()))
+ {
+ char* check = matches_gline(host);
+ if (check)
{
- char* check = matches_gline(host);
- if (check)
- {
- snprintf(reason,MAXBUF,"G-Lined: %s",check);
- Goners->AddItem(u->second,reason);
- }
+ snprintf(reason,MAXBUF,"G-Lined: %s",check);
+ Goners->AddItem(u->second,reason);
}
- if ((What & APPLY_KLINES) && (klines.size() || pklines.size()))
+ }
+ if ((What & APPLY_KLINES) && (klines.size() || pklines.size()))
+ {
+ char* check = matches_kline(host);
+ if (check)
{
- char* check = matches_kline(host);
- if (check)
- {
- snprintf(reason,MAXBUF,"K-Lined: %s",check);
- Goners->AddItem(u->second,reason);
- }
+ snprintf(reason,MAXBUF,"K-Lined: %s",check);
+ Goners->AddItem(u->second,reason);
}
- if ((What & APPLY_QLINES) && (qlines.size() || pqlines.size()))
+ }
+ if ((What & APPLY_QLINES) && (qlines.size() || pqlines.size()))
+ {
+ char* check = matches_qline(u->second->nick);
+ if (check)
{
- char* check = matches_qline(u->second->nick);
- if (check)
- {
- snprintf(reason,MAXBUF,"Matched Q-Lined nick: %s",check);
- Goners->AddItem(u->second,reason);
- }
+ snprintf(reason,MAXBUF,"Matched Q-Lined nick: %s",check);
+ Goners->AddItem(u->second,reason);
}
- if ((What & APPLY_ZLINES) && (zlines.size() || pzlines.size()))
+ }
+ if ((What & APPLY_ZLINES) && (zlines.size() || pzlines.size()))
+ {
+ char* check = matches_zline(u->second->ip);
+ if (check)
{
- char* check = matches_zline(u->second->ip);
- if (check)
- {
- snprintf(reason,MAXBUF,"Z-Lined: %s",check);
- Goners->AddItem(u->second,reason);
- }
+ snprintf(reason,MAXBUF,"Z-Lined: %s",check);
+ Goners->AddItem(u->second,reason);
}
}
}