diff --git a/Changes b/Changes index 4b94d0d32..52a142019 100644 --- a/Changes +++ b/Changes @@ -326,3 +326,5 @@ k/* - Fixed /stats C not showing N:lines, reported by auspice - Fixed codemastr (possible) fucked up the shell ircd script with overwriting it ... +- Created /shun, /gline style. /shun +user@host time reason /shun -user@host + will extend it so you can /shun +nick later diff --git a/include/msg.h b/include/msg.h index 765c1a466..2694e8501 100644 --- a/include/msg.h +++ b/include/msg.h @@ -306,7 +306,8 @@ #define MSG_CHGNAME "CHGNAME" #define MSG_SVSNAME "SVSNAME" #define TOK_CHGNAME "BK" - +#define MSG_SHUN "SHUN" +#define TOK_SHUN "BL" #define MAXPARA 15 extern int m_private(), m_topic(), m_join(), m_part(), m_mode(), m_svsmode(); @@ -343,7 +344,7 @@ extern int m_svsjoin(), m_sajoin(), m_svspart(), m_sapart(); extern int m_chgident(), m_swhois(), m_svso(), m_svsfline(); extern int m_tkl(), m_vhost(), m_botmotd(), m_sjoin(), m_htm(); extern int m_umode2(), m_dccdeny(), m_undccdeny(); -extern int m_chgname(); +extern int m_chgname(), m_shun(); #ifdef MSGTAB struct Message *msgmap[256]; @@ -478,6 +479,7 @@ struct Message msgtab[] = { { MSG_UNDCCDENY,m_undccdeny, 0, MAXPARA, 1, TOK_UNDCCDENY,0L }, { MSG_CHGNAME, m_chgname, 0, MAXPARA, 1, TOK_CHGNAME, 0L}, { MSG_SVSNAME, m_chgname, 0, MAXPARA, 1, TOK_CHGNAME, 0L}, + { MSG_SHUN, m_shun, 0, MAXPARA, 1, TOK_SHUN, 0L}, { (char *) 0, (int (*)()) 0 , 0, 0, 0, 0, 0L} }; diff --git a/include/struct.h b/include/struct.h index c2ed8347b..937580bb9 100644 --- a/include/struct.h +++ b/include/struct.h @@ -200,7 +200,7 @@ typedef unsigned int u_int32_t; /* XXX Hope this works! */ #define FLAGS_WRSOCKS 0x1000000 #define FLAGS_GOTSOCKS 0x2000000 #endif -#define FLAGS_HUSHED 0x4000000 +#define FLAGS_SHUNNED 0x4000000 #define FLAGS_MAP 0x80000000 /* Show this entry in /map */ /* Dec 26th, 1997 - added flags2 when I ran out of room in flags -DuffJ @@ -300,9 +300,9 @@ typedef unsigned int u_int32_t; /* XXX Hope this works! */ #define GotNetInfo(x) ((x)->flags & FLAGS_NETINFO) #define SetNetInfo(x) ((x)->flags |= FLAGS_NETINFO) -#define IsHushed(x) ((x)->flags & FLAGS_HUSHED) -#define SetHushed(x) ((x)->flags |= FLAGS_HUSHED) -#define ClearHushed(x) ((x)->flags &= ~FLAGS_HUSHED) +#define IsShunned(x) ((x)->flags & FLAGS_SHUNNED) +#define SetShunned(x) ((x)->flags |= FLAGS_SHUNNED) +#define ClearShunned(x) ((x)->flags &= ~FLAGS_SHUNNED) #define IsHybNotice(x) ((x)->flags & FLAGS_HYBNOTICE) #define SetHybNotice(x) ((x)->flags |= FLAGS_HYBNOTICE) @@ -697,6 +697,7 @@ struct t_hush { #define TKL_KILL 0x0001 #define TKL_ZAP 0x0002 #define TKL_GLOBAL 0x0004 +#define TKL_SHUN 0x0008 struct t_kline { diff --git a/src/parse.c b/src/parse.c index 193455db0..b96363e2d 100644 --- a/src/parse.c +++ b/src/parse.c @@ -266,7 +266,7 @@ int parse(cptr, buffer, bufend, mptr) ban_flooder(cptr); return 0; } - + /* this call is a bit obsolete? - takes up CPU*/ backupbuf[0] = '\0'; strcpy(backupbuf, buffer); @@ -501,6 +501,10 @@ int parse(cptr, buffer, bufend, mptr) /* There is code in s_serv.c for ADMIN and VERSION and * in s_user.c for NOTICE to limit commands by * unregistered users. -Studded */ + if (IsShunned(cptr) && IsRegistered(cptr)) + if ((mptr->func != m_admin) && (mptr->func != m_quit)) + return -4; + if ((!IsRegistered(cptr)) && (((mptr->func != m_user) && (mptr->func != m_nick) && (mptr->func != m_server) && (mptr->func != m_pong) && diff --git a/src/s_extra.c b/src/s_extra.c index 6425bb989..a026b74e7 100644 --- a/src/s_extra.c +++ b/src/s_extra.c @@ -796,61 +796,6 @@ int m_vhost(cptr, sptr, parc, parv) return 0; } -/* hush */ -#ifdef MOO -int hush_add(vhost, login, password, usermask, hostmask) - char *vhost, *login, *password, *usermask, *hostmask; -{ - aHush *fl; - - fl = (aHush *) MyMalloc(sizeof(aHush)); - - AllocCpy(fl->virthost, vhost); - AllocCpy(fl->usermask, usermask); - AllocCpy(fl->hostmask, hostmask); - AllocCpy(fl->login, login); - AllocCpy(fl->password, password); - fl->next = vhosts; - fl->prev = NULL; - if (vhosts) - vhosts->prev = fl; - vhosts = fl; -} - -aVhost *vhost_del(fl) - aVhost *fl; -{ - aVhost *p, *q; - for (p = vhosts; p; p = p->next) - { - if (p == fl) - { - q = p->next; - MyFree((char *)(fl->virthost)); - MyFree((char *)(fl->usermask)); - MyFree((char *)(fl->hostmask)); - MyFree((char *)(fl->login)); - MyFree((char *)(fl->password)); - /* chain1 to chain3 */ - if (p->prev) - { - p->prev->next = p->next; - } - else - { - vhosts = p->next; - } - if (p->next) - { - p->next->prev = p->prev; - } - MyFree((aVhost *) p); - return q; - } - } - return NULL; -} -#endif /* irc logs.. */ void ircd_log(char *format, ...) { diff --git a/src/s_kline.c b/src/s_kline.c index 6633543a7..7d19bbb9e 100644 --- a/src/s_kline.c +++ b/src/s_kline.c @@ -1,7 +1,6 @@ -/************************************************************************ -/************************************************************************ +/* * Unreal Internet Relay Chat Daemon, src/s_kline.c - * (C) 1999 Carsten Munk (Techie/Stskeeps) + * (C) 1999-2000 Carsten Munk (Techie/Stskeeps) * File to take care of dynamic K:/G:/Z: lines * * @@ -125,7 +124,10 @@ aTKline *tkl_del_line(tkl) aTKline *tkl_expire(aTKline * tmp) { char whattype[512]; - + long i, i1; + char *chost, *cname, *cip; + int is_ip; + aClient *acptr; if (!tmp) return NULL; @@ -149,6 +151,8 @@ aTKline *tkl_expire(aTKline * tmp) { strcpy(whattype, "Global Z:Line"); } + else if (tmp->type & TKL_SHUN) + strcpy(whattype, "Shun"); } else { @@ -160,6 +164,8 @@ aTKline *tkl_expire(aTKline * tmp) { strcpy(whattype, "Timed Z:Line"); } + else if (tmp->type & TKL_SHUN) + strcpy(whattype, "Local Shun"); } sendto_umode(UMODE_EYES, "*** Expiring %s (%s@%s) made by %s (Reason: %s) set %li seconds ago", @@ -171,6 +177,40 @@ aTKline *tkl_expire(aTKline * tmp) whattype, tmp->usermask, tmp->hostmask, tmp->setby, tmp->reason, TStime() - tmp->set_at); + if (tmp->type & TKL_SHUN) + { + for (i1 = 0; i1 <= 5; i1++) + { + for (i = 0; i <= (MAXCONNECTIONS - 1); i++) + { + if (acptr = local[i]) + if (MyClient(acptr) && IsShunned(acptr)) + { + chost = acptr->sockhost; + cname = acptr->user->username; + + cip = (char *)inet_ntoa(acptr->ip); + + + if (!(*tmp->hostmask < '0') && (*tmp->hostmask > '9')) + is_ip = 1; + else + is_ip = 0; + + if (is_ip == 0 ? (!match(tmp->hostmask, chost) + && !match(tmp->usermask, cname)) : (!match(tmp->hostmask, + chost) || !match(tmp->hostmask, cip)) + && !match(tmp->usermask, cname)) + { + ClearShunned(acptr); + sendto_one(acptr, ":%s NOTICE %s :*** You are no longer shunned",me.name, acptr->name); + } + } + } + } + } + + return (tkl_del_line(tmp)); } @@ -207,6 +247,7 @@ int find_tkline_match(cptr, xx) time_t nowtime; int is_ip; char msge[1024]; + char gmt2[256]; if (IsServer(cptr) || IsMe(cptr)) return -1; @@ -231,11 +272,12 @@ int find_tkline_match(cptr, xx) chost) || !match(lp->hostmask, cip)) && !match(lp->usermask, cname)) { - ircstp->is_ref++; + if ((lp->type & (TKL_KILL)) && (xx != 2)) { if (lp->type & TKL_GLOBAL) { + ircstp->is_ref++; sendto_one(cptr, "NOTICE %s :*** You are banned for %li seconds (%s)", cptr->name, @@ -249,6 +291,7 @@ int find_tkline_match(cptr, xx) } else { + ircstp->is_ref++; sendto_one(cptr, "NOTICE %s :*** You are banned for %li seconds (%s)", cptr->name, @@ -262,6 +305,7 @@ int find_tkline_match(cptr, xx) } else if (lp->type & (TKL_ZAP)) { + ircstp->is_ref++; ircsprintf(msge, "ERROR :Closing Link: [%s] Z:Lined (%s)\r\n", #ifndef INET6 @@ -273,6 +317,18 @@ int find_tkline_match(cptr, xx) strcpy(zlinebuf, msge); return (1); } + else if (lp->type & (TKL_SHUN)) + { + if (IsShunned(cptr)) + return -1; + SetShunned(cptr); + strncpy(gmt2, asctime(gmtime((clock_t *) &lp->expire_at)), + sizeof(gmt2)); + gmt2[strlen(gmt2) - 1] = '\0'; + sendto_one(cptr, ":%s NOTICE %s :*** You have been shunned by %s until %s (Reason: %s)", + me.name, cptr->name, lp->setby, gmt2, lp->reason); + return -1; + } } } return -1; @@ -298,6 +354,7 @@ int tkl_sweep() return 1; } + void tkl_stats(cptr) aClient *cptr; { @@ -333,6 +390,16 @@ void tkl_stats(cptr) } } for (tk = tklines; tk; tk = tk->next) + { + if (tk->type == (TKL_SHUN | TKL_GLOBAL)) + { + sendto_one(cptr, rpl_str(RPL_STATSGLINE), me.name, + cptr->name, 's', tk->usermask, tk->hostmask, + (tk->expire_at - curtime), (curtime - tk->set_at), + tk->setby, tk->reason); + } + } + for (tk = tklines; tk; tk = tk->next) { if (tk->type == (TKL_KILL)) { @@ -358,7 +425,7 @@ void tkl_stats(cptr) void tkl_synch(aClient *sptr) { aTKline *tk; - + char typ; for (tk = tklines; tk; tk = tk->next) { @@ -370,12 +437,20 @@ void tkl_synch(aClient *sptr) tk->usermask, tk->hostmask, tk->expire_at, tk->set_at, tk->setby, tk->reason); else + { + if (tk->type & TKL_KILL) + typ = 'G'; + if (tk->type & TKL_ZAP) + typ = 'Z'; + if (tk->type & TKL_SHUN) + typ = 's'; sendto_one(sptr, - ":%s %s + %s %s %s %s %li %li :%s", me.name, + ":%s %s + %c %s %s %s %li %li :%s", me.name, IsToken(sptr) ? TOK_TKL : MSG_TKL, - (tk->type & TKL_KILL ? "G" : "Z"), + typ, tk->usermask, tk->hostmask, tk->setby, tk->expire_at, tk->set_at, tk->reason); + } } } } @@ -430,8 +505,9 @@ int m_tkl(cptr, sptr, parc, parv) type = TKL_ZAP; else if (parv[2][0] == 'k') type = TKL_KILL; - else - return 0; + else if (parv[2][0] == 's') + type = TKL_SHUN |TKL_GLOBAL; + else return 0; found = 0; for (tk = tklines; tk; tk = tk->next) @@ -479,6 +555,9 @@ int m_tkl(cptr, sptr, parc, parv) case TKL_ZAP | TKL_GLOBAL: strcpy(txt, "Global Z:line"); break; + case TKL_SHUN | TKL_GLOBAL: + strcpy(txt, "Shun"); + break; default: strcpy(txt, "Unknown *:Line"); } @@ -515,8 +594,9 @@ int m_tkl(cptr, sptr, parc, parv) type = TKL_ZAP; else if (*parv[2] == 'k') type = TKL_KILL; - else - return 0; + else if (*parv[2] == 's') + type = TKL_SHUN | TKL_GLOBAL; + else return 0; switch (type) { @@ -532,6 +612,9 @@ int m_tkl(cptr, sptr, parc, parv) case TKL_ZAP | TKL_GLOBAL: strcpy(txt, "Global Z:line"); break; + case TKL_SHUN | TKL_GLOBAL: + strcpy(txt, "Shun"); + break; default: strcpy(txt, "Unknown *:Line"); } @@ -772,3 +855,187 @@ int m_gline(aClient *cptr, aClient *sptr, int parc, char *parv[]) } } + +/* +** m_shun (oper function - /TKL takes care of distribution) +** /gline [+|-]u@h mask time :reason +** +** parv[0] = sender +** parv[1] = [+|-]u@h mask +** parv[2] = for how long +** parv[3] = reason +*/ + +int m_shun(aClient *cptr, aClient *sptr, int parc, char *parv[]) +{ + aTKline *tk; + time_t secs; + int whattodo = 0; /* 0 = add 1 = del */ + int found = 0; + int i; + char *mask = NULL; + char mo[1024], mo2[1024]; + char *p, *usermask, *hostmask; + char *tkllayer[9] = { + me.name, /*0 server.name */ + NULL, /*1 +|- */ + "s", /*2 s */ + NULL, /*3 user */ + NULL, /*4 host */ + NULL, /*5 setby */ + NULL, /*6 expire_at */ + NULL, /*7 set_at */ + NULL /*8 reason */ + }; + + if (parc == 1) + { + tkl_stats(sptr); + return 0; + } + + if (!IsOper(sptr)) + { + sendto_one(sptr, err_str(ERR_NOPRIVILEGES), me.name, + sptr->name); + return 0; + } + + if (parc < 2) + { + sendto_one(sptr, err_str(ERR_NEEDMOREPARAMS), + me.name, sptr->name, "SHUN"); + return; + } + + mask = parv[1]; + if (*mask == '-') + { + if (parc < 2) + { + sendto_one(sptr, err_str(ERR_NEEDMOREPARAMS), + me.name, sptr->name, "SHUN"); + return; + } + whattodo = 1; + mask++; + } + else if (*mask == '+') + { + if (parc < 4) + { + sendto_one(sptr, err_str(ERR_NEEDMOREPARAMS), + me.name, sptr->name, "SHUN"); + return; + } + whattodo = 0; + mask++; + } + if (whattodo == 0) + { + if (parc < 4) + { + sendto_one(sptr, err_str(ERR_NEEDMOREPARAMS), + me.name, sptr->name, "SHUN"); + return; + } + } + + /* Check if its a hostmask and legal .. */ + p = strchr(mask, '@'); + if (!p || (p == mask)) + { + sendto_one(sptr, + ":%s NOTICE %s :*** [Shun error] Please use a user@host mask.", + me.name, sptr->name); + return 0; + } + + if (whattodo == 1) + goto nochecks; + if (p) + { + p++; + i = 0; + while (*p) + { + if (*p != '*' && *p != '.') + i++; + p++; + } + if (i < 4) + { + sendto_one(sptr, + ":%s NOTICE %s :*** [Shun error] Too broad mask", + me.name, sptr->name); + return 0; + } + } + + nochecks: + usermask = strtok(mask, "@"); + hostmask = strtok(NULL, "@"); + tkl_check_expire(); + + for (tk = tklines; tk; tk = tk->next) + { + if (tk->type = (TKL_GLOBAL | TKL_SHUN)) + { + if (!match(tk->hostmask, usermask) + && !match(tk->usermask, hostmask)) + { + found = 1; + break; + } + } + } + + if ((found == 1) && whattodo == 0) + { + sendto_one(sptr, + ":%s NOTICE %s :*** [Shun error] Match already exists!", + me.name, sptr->name); + return 0; + } + if ((found == 1) && whattodo == 1) + { + sendto_one(sptr, + ":%s NOTICE %s :*** [Shun error] No such Shun", me.name, + sptr->name); + return 0; + } + if (whattodo == 0) + { + secs = atol(parv[2]); + if (secs < 1) + { + sendto_one(sptr, + ":%s NOTICE %s :*** [Shun error] Please specify a positive value for time", + me.name, sptr->name); + return 0; + } + } + tkllayer[1] = whattodo == 0 ? "+" : "-"; + tkllayer[3] = usermask; + tkllayer[4] = hostmask; + tkllayer[5] = + make_nick_user_host(sptr->name, sptr->user->username, + (IsHidden(sptr) ? sptr->user->virthost : sptr->user->realhost)); + if (whattodo == 0) + { + ircsprintf(mo, "%li", secs + TStime()); + ircsprintf(mo2, "%li", TStime()); + tkllayer[6] = mo; + tkllayer[7] = mo2; + tkllayer[8] = parv[3]; + /* call the tkl layer .. */ + m_tkl(&me, &me, 9, tkllayer); + } + else + { + /* call the tkl layer .. */ + m_tkl(&me, &me, 6, tkllayer); + + } +} + diff --git a/src/s_unreal.c b/src/s_unreal.c index 1e0de083f..155a821d1 100644 --- a/src/s_unreal.c +++ b/src/s_unreal.c @@ -1285,12 +1285,6 @@ int m_svso(cptr, sptr, parc, parv) } } -int m_shun(cptr, sptr, parc, parv) - aClient *cptr, *sptr; - int parc; - char *parv[]; -{ -} int m_htm(cptr, sptr, parc, parv) aClient *cptr, *sptr;