1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-07-04 20:03:12 +02:00

- internal: Added GetIP() which we will now use instead of all the Inet_ia2p() stuff

because it's slightly faster (already replaced all of them in src/s_kline.c).
  GetIP(acptr) will return the ip for local users and remote users that support NICKIP,
  it returns NULL for remote users that are on non-NICKIP servers (or have non-NICKIP
  servers along their path).
- internal: tkl_add_line now returns aTKline *
- Added some more hooks:
  - HOOKTYPE_TKL_ADD [aClient *cptr, aClient *sptr, aTKline *tk]
  - HOOKTYPE_TKL_DEL [aClient *cptr, aClient *sptr, aTKline *tk]
    NOTE: 'NULL, NULL, tk' is used for *lines that are removed due to expiring
  - HOOKTYPE_LOCAL_KILL [aClient *sptr, aClient *target, char *comment]
This commit is contained in:
Bram Matthys
2004-06-19 22:49:02 +00:00
parent 05a96a3b56
commit 5385bd3f89
5 changed files with 41 additions and 23 deletions
+11
View File
@@ -3283,3 +3283,14 @@ This is the 3.2 fixes branch.
- Fixed a CIDR bug when compiled without IPv6 support
- Fixed an SVSNICK bug that could lead to duplicate users in very rare circumstances
(#0001874) reported by Jiuka.
- internal: Added GetIP() which we will now use instead of all the Inet_ia2p() stuff
because it's slightly faster (already replaced all of them in src/s_kline.c).
GetIP(acptr) will return the ip for local users and remote users that support NICKIP,
it returns NULL for remote users that are on non-NICKIP servers (or have non-NICKIP
servers along their path).
- internal: tkl_add_line now returns aTKline *
- Added some more hooks:
- HOOKTYPE_TKL_ADD [aClient *cptr, aClient *sptr, aTKline *tk]
- HOOKTYPE_TKL_DEL [aClient *cptr, aClient *sptr, aTKline *tk]
NOTE: 'NULL, NULL, tk' is used for *lines that are removed due to expiring
- HOOKTYPE_LOCAL_KILL [aClient *sptr, aClient *target, char *comment]
+5 -1
View File
@@ -24,7 +24,7 @@
#define MOD_VERSION "3.2-b5-1"
#define MOD_WE_SUPPORT "3.2-b5*"
#define MAXCUSTOMHOOKS 30
#define MAXHOOKTYPES 70
#define MAXHOOKTYPES 100
#define MAXCALLBACKS 30
#if defined(_WIN32)
#define DLLFUNC _declspec(dllexport)
@@ -566,6 +566,10 @@ int CallCmdoverride(Cmdoverride *ovr, aClient *cptr, aClient *sptr, int parc, ch
#define HOOKTYPE_UMODE_CHANGE 36
#define HOOKTYPE_TOPIC 37
#define HOOKTYPE_REHASH_COMPLETE 38
#define HOOKTYPE_TKL_ADD 39
#define HOOKTYPE_TKL_DEL 40
#define HOOKTYPE_LOCAL_KILL 41
/* Hook return values */
#define HOOK_CONTINUE 0
+1
View File
@@ -432,6 +432,7 @@ typedef unsigned int u_int32_t; /* XXX Hope this works! */
#endif
#define GetHost(x) (IsHidden(x) ? (x)->user->virthost : (x)->user->realhost)
#define GetIP(x) ((x->user && x->user->ip_str) ? x->user->ip_str : (MyConnect(x) ? Inet_ia2p(&x->ip) : NULL))
#define SetKillsF(x) ((x)->user->snomask |= SNO_KILLS)
#define SetClientF(x) ((x)->user->snomask |= SNO_CLIENT)
+2
View File
@@ -323,6 +323,8 @@ DLLFUNC int m_kill(aClient *cptr, aClient *sptr, int parc, char *parv[])
(void)ircsprintf(buf2, "Killed (%s)", killer);
}
if (MyClient(sptr))
RunHook3(HOOKTYPE_LOCAL_KILL, sptr, acptr, parv[2]);
if (exit_client(cptr, acptr, sptr, buf2) == FLUSH_BUFFER)
return FLUSH_BUFFER;
}
+22 -22
View File
@@ -120,7 +120,7 @@ void tkl_init(void)
* [1]: only relevant for spamfilters, else ignored (eg 0, NULL).
*/
int tkl_add_line(int type, char *usermask, char *hostmask, char *reason, char *setby,
aTKline *tkl_add_line(int type, char *usermask, char *hostmask, char *reason, char *setby,
TS expire_at, TS set_at, TS spamf_tkl_duration, char *spamf_tkl_reason)
{
aTKline *nl;
@@ -129,7 +129,7 @@ int tkl_add_line(int type, char *usermask, char *hostmask, char *reason, char *
nl = (aTKline *) MyMallocEx(sizeof(aTKline));
if (!nl)
return -1;
return NULL;
nl->type = type;
nl->expire_at = expire_at;
@@ -166,7 +166,8 @@ int tkl_add_line(int type, char *usermask, char *hostmask, char *reason, char *
}
index = tkl_hash(tkl_typetochar(type));
AddListItem(nl, tklines[index]);
return 0;
return nl;
}
aTKline *tkl_del_line(aTKline *tkl)
@@ -225,7 +226,7 @@ aClient *acptr;
cname = acptr->user->username;
cip = (char *)Inet_ia2p(&acptr->ip);
cip = GetIP(acptr);
if (!(*tmp->hostmask < '0') && (*tmp->hostmask > '9'))
is_ip = 1;
@@ -319,6 +320,7 @@ aTKline *tkl_expire(aTKline * tmp)
if (tmp->type & TKL_SHUN)
tkl_check_local_remove_shun(tmp);
RunHook3(HOOKTYPE_TKL_DEL, NULL, NULL, tmp);
return (tkl_del_line(tmp));
}
@@ -367,7 +369,7 @@ int find_tkline_match(aClient *cptr, int xx)
nowtime = TStime();
chost = cptr->sockhost;
cname = cptr->user ? cptr->user->username : "unknown";
cip = (char *)Inet_ia2p(&cptr->ip);
cip = GetIP(cptr);
points = 0;
for (index = 0; index < TKLISTLEN; index++)
@@ -492,8 +494,7 @@ int find_shun(aClient *cptr)
nowtime = TStime();
chost = cptr->sockhost;
cname = cptr->user ? cptr->user->username : "unknown";
cip = (char *)Inet_ia2p(&cptr->ip);
cip = GetIP(cptr);
for (lp = tklines[tkl_hash('s')]; lp; lp = lp->next)
{
@@ -555,7 +556,7 @@ aTKline *find_qline(aClient *cptr, char *nick, int *ishold)
{
aTKline *lp;
char *chost, *cname, *cip;
char host[NICKLEN+USERLEN+HOSTLEN+6], hostx2[NICKLEN+USERLEN+HOSTLEN+6], *host2 = NULL;
char host[NICKLEN+USERLEN+HOSTLEN+6], hostbuf2[NICKLEN+USERLEN+HOSTLEN+6], *host2 = NULL;
int points = 0;
ConfigItem_except *excepts;
*ishold = 0;
@@ -589,16 +590,11 @@ aTKline *find_qline(aClient *cptr, char *nick, int *ishold)
cname = cptr->user ? cptr->user->username : "unknown";
strcpy(host, make_user_host(cname, chost));
if (MyConnect(cptr))
cip = GetIP(cptr);
if (cip)
{
cip = (char *)Inet_ia2p(&cptr->ip);
strcpy(hostx2, make_user_host(cname, cip));
host2 = hostx2;
} else
if (cptr->user->ip_str)
{
strcpy(hostx2, make_user_host(cname, cptr->user->ip_str));
host2 = hostx2;
strcpy(hostbuf2, make_user_host(cname, cip));
host2 = hostbuf2;
}
for (excepts = conf_except; excepts; excepts = (ConfigItem_except *)excepts->next)
@@ -630,7 +626,7 @@ int find_tkline_match_zap(aClient *cptr)
return -1;
nowtime = TStime();
cip = (char *)Inet_ia2p(&cptr->ip);
cip = GetIP(cptr);
for (lp = tklines[tkl_hash('z')]; lp; lp = lp->next)
{
@@ -1075,12 +1071,15 @@ int m_tkl(aClient *cptr, aClient *sptr, int parc, char *parv[])
/* there is something fucked here? */
if ((type & TKL_SPAMF) && (parc >= 11))
tkl_add_line(type, parv[3], parv[4], reason, parv[5],
tk = tkl_add_line(type, parv[3], parv[4], reason, parv[5],
expiry_1, setat_1, spamf_tklduration, parv[9]);
else
tkl_add_line(type, parv[3], parv[4], reason, parv[5],
tk = tkl_add_line(type, parv[3], parv[4], reason, parv[5],
expiry_1, setat_1, 0, NULL);
if (tk)
RunHook3(HOOKTYPE_TKL_ADD, cptr, sptr, tk);
strncpyzt(gmt, asctime(gmtime((TS *)&setat_1)), sizeof(gmt));
strncpyzt(gmt2, asctime(gmtime((TS *)&expiry_1)), sizeof(gmt2));
iCstrip(gmt);
@@ -1304,6 +1303,7 @@ int m_tkl(aClient *cptr, aClient *sptr, int parc, char *parv[])
}
if (type & TKL_SHUN)
tkl_check_local_remove_shun(tk);
RunHook3(HOOKTYPE_TKL_DEL, cptr, sptr, tk);
tkl_del_line(tk);
if (type & TKL_GLOBAL)
{
@@ -1357,7 +1357,7 @@ int place_host_ban(aClient *sptr, int action, char *reason, long duration)
sendto_snomask(SNO_TKL, "Temporary shun added at user %s (%s@%s) [%s]",
sptr->name,
sptr->user ? sptr->user->username : "unknown",
sptr->user ? sptr->user->realhost : Inet_ia2p(&sptr->ip),
sptr->user ? sptr->user->realhost : GetIP(sptr),
reason);
SetShunned(sptr);
break;
@@ -1380,7 +1380,7 @@ int place_host_ban(aClient *sptr, int action, char *reason, long duration)
NULL /*8 reason */
};
strlcpy(hostip, Inet_ia2p(&sptr->ip), sizeof(hostip));
strlcpy(hostip, GetIP(sptr), sizeof(hostip));
if (action == BAN_ACT_KLINE)
tkllayer[2] = "k";