IRCForumları - IRC ve mIRC Kullanıcılarının Buluşma Noktası
  kral sohbet




1Beğeni(ler)

Yeni Konu aç Cevapla
 
LinkBack Seçenekler Stil
Alt 25 Nisan 2007, 07:52   #11
Çevrimdışı
Cevap: /* Yuzukchat.Net IRC(d) Dosyaları */




s_user.c

Kod:   Kodu kopyalamak için üzerine çift tıklayın!
/* * Unreal Internet Relay Chat Daemon, src/s_user.c * Copyright (C) 1990 Jarkko Oikarinen and * University of Oulu, Computing Center * * See file AUTHORS in IRC package for additional names of * the programmers. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef CLEAN_COMPILE static char sccsid[] = "@(#)s_user.c 2.74 2/8/94 (C) 1988 University of Oulu, \ Computing Center and Jarkko Oikarinen"; #endif #include "macros.h" #include "config.h" #include "struct.h" #include "common.h" #include "sys.h" #include "numeric.h" #include "msg.h" #include "channel.h" #include <time.h> #include <sys/stat.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #ifdef _WIN32 #include <io.h> #endif #include <fcntl.h> #include "h.h" #include "proto.h" #ifdef STRIPBADWORDS #include "badwords.h" #endif #ifdef _WIN32 #include "version.h" #endif void send_umode_out(aClient *, aClient *, long); void send_umode_out_nickv2(aClient *, aClient *, long); void send_umode(aClient *, aClient *, long, long, char *); void set_snomask(aClient *, char *); void create_snomask(aClient *, anUser *, char *); extern int short_motd(aClient *sptr); extern aChannel *get_channel(aClient *cptr, char *chname, int flag); /* static Link *is_banned(aClient *, aChannel *); */ int dontspread = 0; extern char *me_hash; extern char backupbuf[]; static char buf[BUFSIZE]; void iNAH_host(aClient *sptr, char *host) { DYN_LOCAL(char, did_parts, sptr->user->joined); if (!sptr->user) { DYN_FREE(did_parts); return; } if (UHOST_ALLOWED == UHALLOW_REJOIN) rejoin_doparts(sptr, did_parts); if (sptr->user->virthost) { MyFree(sptr->user->virthost); sptr->user->virthost = NULL; } sptr->user->virthost = strdup(host); if (MyConnect(sptr)) sendto_serv_butone_token(&me, sptr->name, MSG_SETHOST, TOK_SETHOST, "%s", sptr->user->virthost); sptr->umodes |= UMODE_SETHOST; if (UHOST_ALLOWED == UHALLOW_REJOIN) rejoin_dojoinandmode(sptr, did_parts); DYN_FREE(did_parts); } long set_usermode(char *umode) { int newumode; int what; char *m; int i; newumode = 0; what = MODE_ADD; for (m = umode; *m; m++) switch (*m) { case '+': what = MODE_ADD; break; case '-': what = MODE_DEL; break; case ' ': case '\n': case '\r': case '\t': break; default: for (i = 0; i <= Usermode_highest; i++) { if (!Usermode_Table[i].flag) continue; if (*m == Usermode_Table[i].flag) { if (what == MODE_ADD) newumode |= Usermode_Table[i].mode; else newumode &= ~Usermode_Table[i].mode; } } } return (newumode); } /* ** m_functions execute protocol messages on this server: ** ** cptr is always NON-NULL, pointing to a *LOCAL* client ** structure (with an open socket connected!). This ** identifies the physical socket where the message ** originated (or which caused the m_function to be ** executed--some m_functions may call others...). ** ** sptr is the source of the message, defined by the ** prefix part of the message if present. If not ** or prefix not found, then sptr==cptr. ** ** (!IsServer(cptr)) => (cptr == sptr), because ** prefixes are taken *only* from servers... ** ** (IsServer(cptr)) ** (sptr == cptr) => the message didn't ** have the prefix. ** ** (sptr != cptr && IsServer(sptr) means ** the prefix specified servername. (?) ** ** (sptr != cptr && !IsServer(sptr) means ** that message originated from a remote ** user (not local). ** ** combining ** ** (!IsServer(sptr)) means that, sptr can safely ** taken as defining the target structure of the ** message in this server. ** ** *Always* true (if 'parse' and others are working correct): ** ** 1) sptr->from == cptr (note: cptr->from == cptr) ** ** 2) MyConnect(sptr) <=> sptr == cptr (e.g. sptr ** *cannot* be a local connection, unless it's ** actually cptr!). [MyConnect(x) should probably ** be defined as (x == x->from) --msa ] ** ** parc number of variable parameter strings (if zero, ** parv is allowed to be NULL) ** ** parv a NULL terminated list of parameter pointers, ** ** parv[0], sender (prefix string), if not present ** this points to an empty string. ** parv[1]...parv[parc-1] ** pointers to additional parameters ** parv[parc] == NULL, *always* ** ** note: it is guaranteed that parv[0]..parv[parc-1] are all ** non-NULL pointers. */ /* #ifndef NO_FDLIST ** extern fdlist oper_fdlist; ** #endif */ /* Taken from AlemBurda.Gen.Tr by Peter Zelezny * changed very slightly by codemastr * RGB color stripping support added -- codemastr */ unsigned char *StripColors(unsigned char *text) { int i = 0, len = strlen(text), save_len=0; char nc = 0, col = 0, rgb = 0, *save_text=NULL; static unsigned char new_str[4096]; while (len > 0) { if ((col && isdigit(*text) && nc < 2) || (col && *text == ',' && nc < 3)) { nc++; if (*text == ',') nc = 0; } /* Syntax for RGB is ^DHHHHHH where H is a hex digit. * If < 6 hex digits are specified, the code is displayed * as text */ else if ((rgb && isxdigit(*text) && nc < 6) || (rgb && *text == ',' && nc < 7)) { nc++; if (*text == ',') nc = 0; } else { if (col) col = 0; if (rgb) { if (nc != 6) { text = save_text+1; len = save_len-1; rgb = 0; continue; } rgb = 0; } if (*text == '\003') { col = 1; nc = 0; } else if (*text == '\004') { save_text = text; save_len = len; rgb = 1; nc = 0; } else { new_str[i] = *text; i++; } } text++; len--; } new_str[i] = 0; return new_str; } /* strip color, bold, underline, and reverse codes from a string */ const char *StripControlCodes(unsigned char *text) { int i = 0, len = strlen(text), save_len=0; char nc = 0, col = 0, rgb = 0, *save_text=NULL; static unsigned char new_str[4096]; while (len > 0) { if ( col && ((isdigit(*text) && nc < 2) || (*text == ',' && nc < 3))) { nc++; if (*text == ',') nc = 0; } /* Syntax for RGB is ^DHHHHHH where H is a hex digit. * If < 6 hex digits are specified, the code is displayed * as text */ else if ((rgb && isxdigit(*text) && nc < 6) || (rgb && *text == ',' && nc < 7)) { nc++; if (*text == ',') nc = 0; } else { if (col) col = 0; if (rgb) { if (nc != 6) { text = save_text+1; len = save_len-1; rgb = 0; continue; } rgb = 0; } switch (*text) { case 3: /* color */ col = 1; nc = 0; break; case 4: /* RGB */ save_text = text; save_len = len; rgb = 1; nc = 0; break; case 2: /* bold */ break; case 31: /* underline */ break; case 22: /* reverse */ break; case 15: /* plain */ break; default: new_str[i] = *text; i++; break; } } text++; len--; } new_str[i] = 0; return new_str; } MODVAR char umodestring[UMODETABLESZ+1]; /* ** next_client ** Local function to find the next matching client. The search ** can be continued from the specified client entry. Normal ** usage loop is: ** ** for (x = client; x = next_client(x,mask); x = x->next) ** HandleMatchingClient; ** */ aClient *next_client(aClient *next, char *ch) { aClient *tmp = next; next = find_client(ch, tmp); if (tmp && tmp->prev == next) return NULL; if (next != tmp) return next; for (; next; next = next->next) { if (!match(ch, next->name) || !match(next->name, ch)) break; } return next; } /* ** hunt_server ** ** Do the basic thing in delivering the message (command) ** across the relays to the specific server (server) for ** actions. ** ** Note: The command is a format string and *MUST* be ** of prefixed style (e.g. ":%s COMMAND %s ..."). ** Command can have only max 8 parameters. ** ** server parv[server] is the parameter identifying the ** target server. ** ** *WARNING* ** parv[server] is replaced with the pointer to the ** real servername from the matched client (I'm lazy ** now --msa). ** ** returns: (see #defines) */ int hunt_server(aClient *cptr, aClient *sptr, char *command, int server, int parc, char *parv[]) { aClient *acptr; /* ** Assume it's me, if no server */ if (parc <= server || BadPtr(parv[server]) || match(me.name, parv[server]) == 0 || match(parv[server], me.name) == 0) return (HUNTED_ISME); /* ** These are to pickup matches that would cause the following ** message to go in the wrong direction while doing quick fast ** non-matching lookups. */ if ((acptr = find_client(parv[server], NULL))) if (acptr->from == sptr->from && !MyConnect(acptr)) acptr = NULL; if (!acptr && (acptr = find_server_quick(parv[server]))) if (acptr->from == sptr->from && !MyConnect(acptr)) acptr = NULL; if (!acptr) for (acptr = client, (void)collapse(parv[server]); (acptr = next_client(acptr, parv[server])); acptr = acptr->next) { if (acptr->from == sptr->from && !MyConnect(acptr)) continue; /* * Fix to prevent looping in case the parameter for * some reason happens to match someone from the from * link --jto */ if (IsRegistered(acptr) && (acptr != cptr)) break; } /* Fix for unregistered client receiving msgs: */ if (acptr && MyConnect(acptr) && IsUnknown(acptr)) acptr = NULL; if (acptr) { if (IsMe(acptr) || MyClient(acptr)) return HUNTED_ISME; if (match(acptr->name, parv[server])) parv[server] = acptr->name; sendto_one(acptr, command, parv[0], parv[1], parv[2], parv[3], parv[4], parv[5], parv[6], parv[7], parv[8]); return (HUNTED_PASS); } sendto_one(sptr, err_str(ERR_NOSUCHSERVER), me.name, parv[0], parv[server]); return (HUNTED_NOSUCH); } /* ** hunt_server_token ** ** Do the basic thing in delivering the message (command) ** across the relays to the specific server (server) for ** actions. This works like hunt_server, except if the ** server supports tokens, the token is used. ** ** command specifies the command name ** token specifies the token name ** params is a formated parameter string ** server parv[server] is the parameter identifying the ** target server. ** ** *WARNING* ** parv[server] is replaced with the pointer to the ** real servername from the matched client (I'm lazy ** now --msa). ** ** returns: (see #defines) */ int hunt_server_token(aClient *cptr, aClient *sptr, char *command, char *token, char *params, int server, int parc, char *parv[]) { aClient *acptr; /* ** Assume it's me, if no server */ if (parc <= server || BadPtr(parv[server]) || match(me.name, parv[server]) == 0 || match(parv[server], me.name) == 0) return (HUNTED_ISME); /* ** These are to pickup matches that would cause the following ** message to go in the wrong direction while doing quick fast ** non-matching lookups. */ if ((acptr = find_client(parv[server], NULL))) if (acptr->from == sptr->from && !MyConnect(acptr)) acptr = NULL; if (!acptr && (acptr = find_server_quick(parv[server]))) if (acptr->from == sptr->from && !MyConnect(acptr)) acptr = NULL; if (!acptr) for (acptr = client, (void)collapse(parv[server]); (acptr = next_client(acptr, parv[server])); acptr = acptr->next) { if (acptr->from == sptr->from && !MyConnect(acptr)) continue; /* * Fix to prevent looping in case the parameter for * some reason happens to match someone from the from * link --jto */ if (IsRegistered(acptr) && (acptr != cptr)) break; } /* Fix for unregistered client receiving msgs: */ if (acptr && MyConnect(acptr) && IsUnknown(acptr)) acptr = NULL; if (acptr) { char buff[1024]; if (IsMe(acptr) || MyClient(acptr)) return HUNTED_ISME; if (match(acptr->name, parv[server])) parv[server] = acptr->name; if (IsToken(acptr->from)) { sprintf(buff, ":%s %s ", parv[0], token); strcat(buff, params); sendto_one(acptr, buff, parv[1], parv[2], parv[3], parv[4], parv[5], parv[6], parv[7], parv[8]); } else { sprintf(buff, ":%s %s ", parv[0], command); strcat(buff, params); sendto_one(acptr, buff, parv[1], parv[2], parv[3], parv[4], parv[5], parv[6], parv[7], parv[8]); } return (HUNTED_PASS); } sendto_one(sptr, err_str(ERR_NOSUCHSERVER), me.name, parv[0], parv[server]); return (HUNTED_NOSUCH); } int hunt_server_token_quiet(aClient *cptr, aClient *sptr, char *command, char *token, char *params, int server, int parc, char *parv[]) { aClient *acptr; /* ** Assume it's me, if no server */ if (parc <= server || BadPtr(parv[server]) || match(me.name, parv[server]) == 0 || match(parv[server], me.name) == 0) return (HUNTED_ISME); /* ** These are to pickup matches that would cause the following ** message to go in the wrong direction while doing quick fast ** non-matching lookups. */ if ((acptr = find_client(parv[server], NULL))) if (acptr->from == sptr->from && !MyConnect(acptr)) acptr = NULL; if (!acptr && (acptr = find_server_quick(parv[server]))) if (acptr->from == sptr->from && !MyConnect(acptr)) acptr = NULL; if (!acptr) for (acptr = client, (void)collapse(parv[server]); (acptr = next_client(acptr, parv[server])); acptr = acptr->next) { if (acptr->from == sptr->from && !MyConnect(acptr)) continue; /* * Fix to prevent looping in case the parameter for * some reason happens to match someone from the from * link --jto */ if (IsRegistered(acptr) && (acptr != cptr)) break; } if (acptr) { char buff[1024]; if (IsMe(acptr) || MyClient(acptr)) return HUNTED_ISME; if (match(acptr->name, parv[server])) parv[server] = acptr->name; if (IsToken(acptr->from)) { sprintf(buff, ":%s %s ", parv[0], token); strcat(buff, params); sendto_one(acptr, buff, parv[1], parv[2], parv[3], parv[4], parv[5], parv[6], parv[7], parv[8]); } else { sprintf(buff, ":%s %s ", parv[0], command); strcat(buff, params); sendto_one(acptr, buff, parv[1], parv[2], parv[3], parv[4], parv[5], parv[6], parv[7], parv[8]); } return (HUNTED_PASS); } return (HUNTED_NOSUCH); } /* ** check_for_target_limit ** ** Return Values: ** True(1) == too many targets are addressed ** False(0) == ok to send message ** */ int check_for_target_limit(aClient *sptr, void *target, const char *name) { #ifndef _WIN32 /* This is not windows compatible */ u_char *p; #ifndef __alpha u_int tmp = ((u_int)target & 0xffff00) >> 8; #else u_int tmp = ((u_long)target & 0xffff00) >> 8; #endif u_char hash = (tmp * tmp) >> 12; if (IsAnOper(sptr)) return 0; if (sptr->targets[0] == hash) return 0; for (p = sptr->targets; p < &sptr->targets[MAXTARGETS - 1];) if (*++p == hash) { /* move targethash to first position... */ memmove(&sptr->targets[1], &sptr->targets[0], p - sptr->targets); sptr->targets[0] = hash; return 0; } if (TStime() < sptr->nexttarget) { sptr->since += TARGET_DELAY; /* lag them up */ sptr->nexttarget += TARGET_DELAY; sendto_one(sptr, err_str(ERR_TARGETTOOFAST), me.name, sptr->name, name, sptr->nexttarget - TStime()); return 1; } if (TStime() > sptr->nexttarget + TARGET_DELAY*MAXTARGETS) { sptr->nexttarget = TStime() - TARGET_DELAY*MAXTARGETS; } sptr->nexttarget += TARGET_DELAY; memmove(&sptr->targets[1], &sptr->targets[0], MAXTARGETS - 1); sptr->targets[0] = hash; #endif return 0; } /* ** canonize ** ** reduce a string of duplicate list entries to contain only the unique ** items. Unavoidably O(n^2). */ extern char *canonize(char *buffer) { static char cbuf[BUFSIZ]; char *s, *t, *cp = cbuf; int l = 0; char *p = NULL, *p2; *cp = '\0'; for (s = strtoken(&p, buffer, ","); s; s = strtoken(&p, NULL, ",")) { if (l) { for (p2 = NULL, t = strtoken(&p2, cbuf, ","); t; t = strtoken(&p2, NULL, ",")) if (!mycmp(s, t)) break; else if (p2) p2[-1] = ','; } else t = NULL; if (!t) { if (l) *(cp - 1) = ','; else l = 1; (void)strcpy(cp, s); if (p) cp += (p - s); } else if (p2) p2[-1] = ','; } return cbuf; } extern MODVAR char cmodestring[512]; /* ** register_user ** This function is called when both NICK and USER messages ** have been accepted for the client, in whatever order. Only ** after this the USER message is propagated. ** ** NICK's must be propagated at once when received, although ** it would be better to delay them too until full info is ** available. Doing it is not so simple though, would have ** to implement the following: ** ** 1) user telnets in and gives only "NICK foobar" and waits ** 2) another user far away logs in normally with the nick ** "foobar" (quite legal, as this server didn't propagate ** it). ** 3) now this server gets nick "foobar" from outside, but ** has already the same defined locally. Current server ** would just issue "KILL foobar" to clean out dups. But, ** this is not fair. It should actually request another ** nick from local user or kill him/her... */ extern MODVAR aTKline *tklines; extern int badclass; int register_user(aClient *cptr, aClient *sptr, char *nick, char *username, char *umode, char *virthost, char *ip) { ConfigItem_ban *bconf; char *parv[3], *tmpstr; #ifdef HOSTILENAME char stripuser[USERLEN + 1], *u1 = stripuser, *u2, olduser[USERLEN + 1], userbad[USERLEN * 2 + 1], *ubad = userbad, noident = 0; #endif int xx; anUser *user = sptr->user; aClient *nsptr; int i; char mo[256]; char *tkllayer[9] = { me.name, /*0 server.name */ "+", /*1 +|- */ "z", /*2 G */ "*", /*3 user */ NULL, /*4 host */ NULL, NULL, /*6 expire_at */ NULL, /*7 set_at */ NULL /*8 reason */ }; ConfigItem_tld *tlds; cptr->last = TStime(); parv[0] = sptr->name; parv[1] = parv[2] = NULL; nick = sptr->name; /* <- The data is always the same, but the pointer is sometimes not, * I need this for one of my modules, so do not remove! ;) -- Syzop */ if (MyConnect(sptr)) { if ((i = check_client(sptr, username))) { /* This had return i; before -McSkaf */ if (i == -5) return FLUSH_BUFFER; sendto_snomask(SNO_CLIENT, "*** Notice -- %s from %s.", i == -3 ? "Too many connections" : "Unauthorized connection", get_client_host(sptr)); ircstp->is_ref++; ircsprintf(mo, "This server is full."); return exit_client(cptr, sptr, &me, i == -3 ? mo : "You are not authorized to connect to this server"); } if (sptr->hostp) { /* No control-chars or ip-like dns replies... I cheat :) -- OnyxDragon */ for (tmpstr = sptr->sockhost; *tmpstr > ' ' && *tmpstr < 127; tmpstr++); if (*tmpstr || !*user->realhost || isdigit(*(tmpstr - 1))) strncpyzt(sptr->sockhost, (char *)Inet_ia2p((struct IN_ADDR*)&sptr->ip), sizeof(sptr->sockhost)); /* Fix the sockhost for debug jic */ strncpyzt(user->realhost, sptr->sockhost, sizeof(sptr->sockhost)); } else /* Failsafe point, don't let the user define their own hostname via the USER command --Cabal95 */ strncpyzt(user->realhost, sptr->sockhost, HOSTLEN + 1); strncpyzt(user->realhost, user->realhost, sizeof(user->realhost)); /* * I do not consider *, ~ or ! 'hostile' in usernames, * as it is easy to differentiate them (Use \*, \? and \\) * with the possible? * exception of !. With mIRC etc. ident is easy to fake * to contain @ though, so if that is found use non-ident * username. -Donwulff * * I do, We only allow a-z A-Z 0-9 _ - and . now so the * !strchr(sptr->username, '@') check is out of date. -Cabal95 * * Moved the noident stuff here. -OnyxDragon */ if (!(sptr->flags & FLAGS_DOID)) strncpyzt(user->username, username, USERLEN + 1); else if (sptr->flags & FLAGS_GOTID) strncpyzt(user->username, sptr->username, USERLEN + 1); else { /* because username may point to user->username */ char temp[USERLEN + 1]; strncpyzt(temp, username, USERLEN + 1); if (IDENT_CHECK == 0) { strncpyzt(user->username, temp, USERLEN + 1); } else { *user->username = '~'; strncpyzt((user->username + 1), temp, USERLEN); #ifdef HOSTILENAME noident = 1; #endif } } #ifdef HOSTILENAME /* * Limit usernames to just 0-9 a-z A-Z _ - and . * It strips the "bad" chars out, and if nothing is left * changes the username to the first 8 characters of their * nickname. After the MOTD is displayed it sends numeric * 455 to the user telling them what(if anything) happened. * -Cabal95 * * Moved the noident thing to the right place - see above * -OnyxDragon * * No longer use nickname if the entire ident is invalid, * if thats the case, it is likely the user is trying to cause * problems so just ban them. (Using the nick could introduce * hostile chars) -- codemastr */ for (u2 = user->username + noident; *u2; u2++) { if (isallowed(*u2)) *u1++ = *u2; else if (*u2 < 32) { /* * Make sure they can read what control * characters were in their username. */ *ubad++ = '^'; *ubad++ = *u2 + '@'; } else *ubad++ = *u2; } *u1 = '\0'; *ubad = '\0'; if (strlen(stripuser) != strlen(user->username + noident)) { if (stripuser[0] == '\0') { return exit_client(cptr, cptr, cptr, "Hostile username. Please use only 0-9 a-z A-Z _ - and . in your username."); } strcpy(olduser, user->username + noident); strncpy(user->username + 1, stripuser, USERLEN - 1); user->username[0] = '~'; user->username[USERLEN] = '\0'; } else u1 = NULL; #endif /* * following block for the benefit of time-dependent K:-lines */ if ((bconf = Find_ban(sptr, make_user_host(user->username, user->realhost), CONF_BAN_USER))) { ircstp->is_ref++; sendto_one(cptr, ":%s %d %s :*** You are not welcome on this server (%s)" " Email %s for more information.", me.name, ERR_YOUREBANNEDCREEP, cptr->name, bconf->reason ? bconf->reason : "", KLINE_ADDRESS); return exit_client(cptr, cptr, cptr, "You are banned"); } if ((bconf = Find_ban(NULL, sptr->info, CONF_BAN_REALNAME))) { ircstp->is_ref++; sendto_one(cptr, ":%s %d %s :*** Your GECOS (real name) is not allowed on this server (%s)" " Please change it and reconnect", me.name, ERR_YOUREBANNEDCREEP, cptr->name, bconf->reason ? bconf->reason : ""); return exit_client(cptr, sptr, &me, "Your GECOS (real name) is banned from this server"); } tkl_check_expire(NULL); /* Check G/Z lines before shuns -- kill before quite -- codemastr */ if ((xx = find_tkline_match(sptr, 0)) < 0) { ircstp->is_ref++; return xx; } find_shun(sptr); xx = find_spamfilter_user(sptr); if (xx < 0) return xx; RunHookReturnInt(HOOKTYPE_PRE_LOCAL_CONNECT, sptr, !=0); } else { strncpyzt(user->username, username, USERLEN + 1); } SetClient(sptr); IRCstats.clients++; if (sptr->srvptr && sptr->srvptr->serv) sptr->srvptr->serv->users++; user->virthost = (char *)make_virthost(user->realhost, user->virthost, 1); if (MyConnect(sptr)) { IRCstats.unknown--; IRCstats.me_clients++; if (IsHidden(sptr)) ircd_log(LOG_CLIENT, "Connect - %s!%s@%s [VHOST %s]", nick, user->username, user->realhost, user->virthost); else ircd_log(LOG_CLIENT, "Connect - %s!%s@%s", nick, user->username, user->realhost); sendto_one(sptr, rpl_str(RPL_WELCOME), me.name, nick, ircnetwork, nick, user->username, user->realhost); /* This is a duplicate of the NOTICE but see below... */ sendto_one(sptr, rpl_str(RPL_YOURHOST), me.name, nick, me.name, version); sendto_one(sptr, rpl_str(RPL_CREATED), me.name, nick, creation); if (!(sptr->listener->umodes & LISTENER_JAVACLIENT)) sendto_one(sptr, rpl_str(RPL_MYINFO), me.name, parv[0], me.name, version, umodestring, cmodestring); else sendto_one(sptr, ":%s 004 %s %s CR1.8.03-%s %s %s", me.name, parv[0], me.name, version, umodestring, cmodestring); { extern char *IsupportStrings[]; int i; for (i = 0; IsupportStrings[i]; i++) sendto_one(sptr, rpl_str(RPL_ISUPPORT), me.name, nick, IsupportStrings[i]); } #ifdef USE_SSL if (sptr->flags & FLAGS_SSL) if (sptr->ssl) sendto_one(sptr, ":%s NOTICE %s :*** You are connected to %s with %s", me.name, sptr->name, me.name, ssl_get_cipher(sptr->ssl)); #endif do_cmd(sptr, sptr, "LUSERS", 1, parv); short_motd(sptr); sendto_one(sptr, err_str(ERR_TARGETTOOFAST),me.name, sptr->name, me.name); sendto_one(sptr, ":Yuzukchat.Net PRIVMSG %s :1Merhaba sunucumuza hosgeldiniz ;",me.name, sptr->name, me.name); sendto_one(sptr, ":Yuzukchat.Net PRIVMSG %s :1Genel tanitim için özelinize gelmis bulunmaktayim.",me.name, sptr->name, me.name); sendto_one(sptr, ":Yuzukchat.Net PRIVMSG %s :1Sunucumuzdaki yetkilileri görmek için : 2/Motd",me.name, sptr->name, me.name); sendto_one(sptr, ":Yuzukchat.Net PRIVMSG %s :1Sunucumuzdaki kurallari görmek için : 2/Rules",me.name, sptr->name, me.name); sendto_one(sptr, ":Yuzukchat.Net PRIVMSG %s :1GLobal sunucu kanallarimiz : 2#Yuzukchat #Game #Radio",me.name, sptr->name, me.name); sendto_one(sptr, ":Yuzukchat.Net PRIVMSG %s :1Genel yardim kanalimiz : 2#Help #OperHelp",me.name, sptr->name, me.name); sendto_one(sptr, ":Yuzukchat.Net PRIVMSG %s :1Sunucumuzda hos vakit geçirmenizi dileriz..",me.name, sptr->name, me.name); #ifdef EXPERIMENTAL sendto_one(sptr, ":%s NOTICE %s :*** \2NOTE:\2 This server (%s) is running experimental IRC server software. If you find any bugs or problems, please mail
Bu forumdaki linkleri ve resimleri görebilmek için en az 25 mesajınız olması gerekir.
about it", me.name, sptr->name, me.name); #endif #ifdef HOSTILENAME /* * Now send a numeric to the user telling them what, if * anything, happened. */ if (u1) sendto_one(sptr, err_str(ERR_HOSTILENAME), me.name, sptr->name, olduser, userbad, stripuser); #endif nextping = TStime(); sendto_connectnotice(nick, user, sptr, 0, NULL); if (IsSecure(sptr)) sptr->umodes |= UMODE_SECURE; } else if (IsServer(cptr)) { aClient *acptr; if (!(acptr = (aClient *)find_server_quick(user->server))) { sendto_ops ("Bad USER [%s] :%s USER %s %s : No such server", cptr->name, nick, user->username, user->server); sendto_one(cptr, ":%s KILL %s :%s (No such server: %s)", me.name, sptr->name, me.name, user->server); sptr->flags |= FLAGS_KILLED; return exit_client(sptr, sptr, &me, "USER without prefix(2.8) or wrong prefix"); } else if (acptr->from != sptr->from) { sendto_ops("Bad User [%s] :%s USER %s %s, != %s[%s]", cptr->name, nick, user->username, user->server, acptr->name, acptr->from->name); sendto_one(cptr, ":%s KILL %s :%s (%s != %s[%s])", me.name, sptr->name, me.name, user->server, acptr->from->name, acptr->from->sockhost); sptr->flags |= FLAGS_KILLED; return exit_client(sptr, sptr, &me, "USER server wrong direction"); } else sptr->flags |= acptr->flags; /* *FINALL* this gets in ircd... -- Barubary */ /* We change this a bit .. */ if (IsULine(sptr->srvptr)) sptr->flags |= FLAGS_ULINE; } if (sptr->umodes & UMODE_INVISIBLE) { IRCstats.invisible++; } if (virthost && umode) { tkllayer[0] = nick; tkllayer[1] = nick; tkllayer[2] = umode; dontspread = 1; do_cmd(cptr, sptr, "MODE", 3, tkllayer); dontspread = 0; if (virthost && *virthost != '*') { if (sptr->user->virthost) { MyFree(sptr->user->virthost); sptr->user->virthost = NULL; } /* Here pig.. yeah you .. -Stskeeps */ sptr->user->virthost = strdup(virthost); } if (ip && (*ip != '*')) sptr->user->ip_str = strdup(decode_ip(ip)); } hash_check_watch(sptr, RPL_LOGON); /* Uglier hack */ send_umode(NULL, sptr, 0, SEND_UMODES|UMODE_SERVNOTICE, buf); /* NICKv2 Servers ! */ sendto_serv_butone_nickcmd(cptr, sptr, nick, sptr->hopcount + 1, sptr->lastnick, user->username, user->realhost, user->server, user->servicestamp, sptr->info, (!buf || *buf == '\0' ? "+" : buf), sptr->umodes & UMODE_SETHOST ? sptr->user->virthost : NULL); /* Send password from sptr->passwd to NickServ for identification, * if passwd given and if NickServ is online. * - by taz, modified by Wizzu */ if (MyConnect(sptr)) { char userhost[USERLEN + HOSTLEN + 6]; if (sptr->passwd && (nsptr = find_person(NickServ, NULL))) sendto_one(nsptr, ":%s %s %s@%s :IDENTIFY %s", sptr->name, (IsToken(nsptr->from) ? TOK_PRIVATE : MSG_PRIVATE), NickServ, SERVICES_NAME, sptr->passwd); /* Force the user to join the given chans -- codemastr */ if (buf[0] != '\0' && buf[1] != '\0') sendto_one(cptr, ":%s MODE %s :%s", cptr->name, cptr->name, buf); if (user->snomask) sendto_one(sptr, rpl_str(RPL_SNOMASK), me.name, sptr->name, get_snostr(user->snomask)); strcpy(userhost,make_user_host(cptr->user->username, cptr->user->realhost)); for (tlds = conf_tld; tlds; tlds = (ConfigItem_tld *) tlds->next) { if (!match(tlds->mask, userhost)) break; } if (tlds && !BadPtr(tlds->channel)) { char *chans[3] = { sptr->name, tlds->channel, NULL }; do_cmd(sptr, sptr, "JOIN", 3, chans); } else if (!BadPtr(AUTO_JOIN_CHANS) && strcmp(AUTO_JOIN_CHANS, "0")) { char *chans[3] = { sptr->name, AUTO_JOIN_CHANS, NULL }; do_cmd(sptr, sptr, "JOIN", 3, chans); } } if (MyConnect(sptr) && !BadPtr(sptr->passwd)) { MyFree(sptr->passwd); sptr->passwd = NULL; } return 0; } /* ** get_mode_str ** by vmlinuz ** returns an ascii string of modes */ char *get_sno_str(aClient *sptr) { int i; char *m; m = buf; *m++ = '+'; for (i = 0; i <= Snomask_highest && (m - buf < BUFSIZE - 4); i++) if (Snomask_Table[i].flag && sptr->user->snomask & Snomask_Table[i].mode) *m++ = Snomask_Table[i].flag; *m = 0; return buf; } char *get_mode_str(aClient *acptr) { int i; char *m; m = buf; *m++ = '+'; for (i = 0; (i <= Usermode_highest) && (m - buf < BUFSIZE - 4); i++) if (Usermode_Table[i].flag && (acptr->umodes & Usermode_Table[i].mode)) *m++ = Usermode_Table[i].flag; *m = '\0'; return buf; } char *get_modestr(long umodes) { int i; char *m; m = buf; *m++ = '+'; for (i = 0; (i <= Usermode_highest) && (m - buf < BUFSIZE - 4); i++) if (Usermode_Table[i].flag && (umodes & Usermode_Table[i].mode)) *m++ = Usermode_Table[i].flag; *m = '\0'; return buf; } char *get_snostr(long sno) { int i; char *m; m = buf; *m++ = '+'; for (i = 0; i <= Snomask_highest && (m - buf < BUFSIZE - 4); i++) if (Snomask_Table[i].flag && sno & Snomask_Table[i].mode) *m++ = Snomask_Table[i].flag; *m = 0; return buf; } void set_snomask(aClient *sptr, char *snomask) { int what = MODE_ADD; /* keep this an int. -- Syzop */ char *p; int i; if (snomask == NULL) { sptr->user->snomask = 0; return; } for (p = snomask; p && *p; p++) { switch (*p) { case '+': what = MODE_ADD; break; case '-': what = MODE_DEL; break; default: for (i = 0; i <= Snomask_highest; i++) { if (!Snomask_Table[i].flag) continue; if (*p == Snomask_Table[i].flag) { if (Snomask_Table[i].allowed && !Snomask_Table[i].allowed(sptr,what)) continue; if (what == MODE_ADD) sptr->user->snomask |= Snomask_Table[i].mode; else sptr->user->snomask &= ~Snomask_Table[i].mode; } } } } } void create_snomask(aClient *sptr, anUser *user, char *snomask) { int what = MODE_ADD; /* keep this an int. -- Syzop */ char *p; int i; if (snomask == NULL) { user->snomask = 0; return; } for (p = snomask; p && *p; p++) { switch (*p) { case '+': what = MODE_ADD; break; case '-': what = MODE_DEL; break; default: for (i = 0; i <= Snomask_highest; i++) { if (!Snomask_Table[i].flag) continue; if (*p == Snomask_Table[i].flag) { if (Snomask_Table[i].allowed && !Snomask_Table[i].allowed(sptr,what)) continue; if (what == MODE_ADD) user->snomask |= Snomask_Table[i].mode; else user->snomask &= ~Snomask_Table[i].mode; } } } } } /* * send the MODE string for user (user) to connection cptr * -avalon */ void send_umode(aClient *cptr, aClient *sptr, long old, long sendmask, char *umode_buf) { int i; long flag; char *m; int what = MODE_NULL; /* * build a string in umode_buf to represent the change in the user's * mode between the new (sptr->flag) and 'old'. */ m = umode_buf; *m = '\0'; for (i = 0; i <= Usermode_highest; i++) { if (!Usermode_Table[i].flag) continue; flag = Usermode_Table[i].mode; if (MyClient(sptr) && !(flag & sendmask)) continue; if ((flag & old) && !(sptr->umodes & flag)) { if (what == MODE_DEL) *m++ = Usermode_Table[i].flag; else { what = MODE_DEL; *m++ = '-'; *m++ = Usermode_Table[i].flag; } } else if (!(flag & old) && (sptr->umodes & flag)) { if (what == MODE_ADD) *m++ = Usermode_Table[i].flag; else { what = MODE_ADD; *m++ = '+'; *m++ = Usermode_Table[i].flag; } } } *m = '\0'; if (*umode_buf && cptr) sendto_one(cptr, ":%s %s %s :%s", sptr->name, (IsToken(cptr) ? TOK_MODE : MSG_MODE), sptr->name, umode_buf); } /* * added Sat Jul 25 07:30:42 EST 1992 */ void send_umode_out(aClient *cptr, aClient *sptr, long old) { int i; aClient *acptr; send_umode(NULL, sptr, old, SEND_UMODES, buf); for (i = LastSlot; i >= 0; i--) if ((acptr = local[i]) && IsServer(acptr) && (acptr != cptr) && (acptr != sptr) && *buf) { if (!SupportUMODE2(acptr)) { sendto_one(acptr, ":%s MODE %s :%s", sptr->name, sptr->name, buf); } else { sendto_one(acptr, ":%s %s %s", sptr->name, (IsToken(acptr) ? TOK_UMODE2 : MSG_UMODE2), buf); } } if (cptr && MyClient(cptr)) send_umode(cptr, sptr, old, ALL_UMODES, buf); } void send_umode_out_nickv2(aClient *cptr, aClient *sptr, long old) { int i; aClient *acptr; send_umode(NULL, sptr, old, SEND_UMODES, buf); for (i = LastSlot; i >= 0; i--) if ((acptr = local[i]) && IsServer(acptr) && !SupportNICKv2(acptr) && (acptr != cptr) && (acptr != sptr) && *buf) sendto_one(acptr, ":%s MODE %s :%s", sptr->name, sptr->name, buf); if (cptr && MyClient(cptr)) send_umode(cptr, sptr, old, ALL_UMODES, buf); } int del_silence(aClient *sptr, char *mask) { Link **lp; Link *tmp; for (lp = &(sptr->user->silence); *lp; lp = &((*lp)->next)) if (mycmp(mask, (*lp)->value.cp) == 0) { tmp = *lp; *lp = tmp->next; MyFree(tmp->value.cp); free_link(tmp); return 0; } return -1; } int add_silence(aClient *sptr, char *mask, int senderr) { Link *lp; int cnt = 0; for (lp = sptr->user->silence; lp; lp = lp->next) { if (MyClient(sptr)) if ((strlen(lp->value.cp) > MAXSILELENGTH) || (++cnt >= SILENCE_LIMIT)) { if (senderr) sendto_one(sptr, err_str(ERR_SILELISTFULL), me.name, sptr->name, mask); return -1; } else { if (!match(lp->value.cp, mask)) return -1; } else if (!mycmp(lp->value.cp, mask)) return -1; } lp = make_link(); bzero((char *)lp, sizeof(Link)); lp->next = sptr->user->silence; lp->value.cp = (char *)MyMalloc(strlen(mask) + 1); (void)strcpy(lp->value.cp, mask); sptr->user->silence = lp; return 0; }


  Alıntı ile Cevapla

IRCForumlari.NET Reklamlar
radyo44.com.tr
Alt 25 Nisan 2007, 07:53   #12
Çevrimdışı
Cevap: /* Yuzukchat.Net IRC(d) Dosyaları */




s_kline.c
Kod:   Kodu kopyalamak için üzerine çift tıklayın!
/* * Unreal Internet Relay Chat Daemon, src/s_kline.c * (C) 1999-2000 Carsten Munk (Techie/Stskeeps) <
Bu forumdaki linkleri ve resimleri görebilmek için en az 25 mesajınız olması gerekir.
> * File to take care of dynamic K:/G:/Z: lines * * * See file AUTHORS in IRC package for additional names of * the programmers. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 1, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "struct.h" #include "common.h" #include "sys.h" #include "numeric.h" #include "msg.h" #include "channel.h" #include <time.h> #include <sys/stat.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #ifdef _WIN32 #include <io.h> #endif #include <fcntl.h> #include "h.h" #include "proto.h" #include "inet.h" aTKline *tklines[TKLISTLEN]; extern MODVAR char zlinebuf[BUFSIZE]; int MODVAR spamf_ugly_vchanoverride = 0; /** tkl hash method. * NOTE1: the input value 'c' is assumed to be in range a-z or A-Z! * NOTE2: don't blindly change the hashmethod, some things depend on * 'z'/'Z' getting the same bucket. */ inline int tkl_hash(char c) { #ifdef DEBUGMODE if ((c >= 'a') && (c <= 'z')) return c-'a'; else if ((c >= 'A') && (c <= 'Z')) return c-'A'; else { sendto_realops("[BUG] tkl_hash() called with out of range parameter (c = '%c') !!!", c); ircd_log(LOG_ERROR, "[BUG] tkl_hash() called with out of range parameter (c = '%c') !!!", c); return 0; } #else return (isupper(c) ? c-'A' : c-'a'); #endif } /** tkl type to tkl character. * NOTE: type is assumed to be valid. */ char tkl_typetochar(int type) { if (type & TKL_GLOBAL) { if (type & TKL_KILL) return 'G'; if (type & TKL_ZAP) return 'Z'; if (type & TKL_SHUN) return 's'; if (type & TKL_KILL) return 'G'; if (type & TKL_SPAMF) return 'F'; if (type & TKL_NICK) return 'Q'; } else { if (type & TKL_ZAP) return 'z'; if (type & TKL_KILL) return 'k'; if (type & TKL_SPAMF) return 'f'; if (type & TKL_NICK) return 'q'; } sendto_realops("[BUG]: tkl_typetochar(): unknown type 0x%x !!!", type); ircd_log(LOG_ERROR, "[BUG] tkl_typetochar(): unknown type 0x%x !!!", type); return 0; } void tkl_init(void) { memset(tklines, 0, sizeof(tklines)); } /* * type = TKL_* * usermask@hostmask * reason * setby = whom set it * expire_at = when to expire - 0 if not to expire * set_at = was set at * spamf_tkl_duration = duration of *line placed by spamfilter [1] * spamf_tkl_reason = escaped reason field for *lines placed by spamfilter [1] * * [1]: only relevant for spamfilters, else ignored (eg 0, NULL). */ 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; int index; nl = (aTKline *) MyMallocEx(sizeof(aTKline)); if (!nl) return NULL; nl->type = type; nl->expire_at = expire_at; nl->set_at = set_at; strncpyzt(nl->usermask, usermask, sizeof(nl->usermask)); nl->hostmask = strdup(hostmask); nl->reason = strdup(reason); nl->setby = strdup(setby); if (type & TKL_SPAMF) { /* Need to set some additional flags like 'targets' and 'action'.. */ nl->subtype = spamfilter_gettargets(usermask, NULL); nl->ptr.spamf = unreal_buildspamfilter(reason); nl->ptr.spamf->action = banact_chartoval(*hostmask); nl->expire_at = 0; /* temporary spamfilters are NOT supported! (makes no sense) */ if (!spamf_tkl_reason) { /* no exttkl support, use default values... */ nl->ptr.spamf->tkl_duration = SPAMFILTER_BAN_TIME; nl->ptr.spamf->tkl_reason = strdup(unreal_encodespace(SPAMFILTER_BAN_REASON)); } else { nl->ptr.spamf->tkl_duration = spamf_tkl_duration; nl->ptr.spamf->tkl_reason = strdup(spamf_tkl_reason); /* already encoded */ } if (nl->subtype & SPAMF_USER) loop.do_bancheck_spamf_user = 1; if (nl->subtype & SPAMF_AWAY) loop.do_bancheck_spamf_away = 1; } else if (type & TKL_KILL || type & TKL_ZAP || type & TKL_SHUN) { struct irc_netmask tmp; if ((tmp.type = parse_netmask(nl->hostmask, &tmp)) != HM_HOST) { nl->ptr.netmask = MyMallocEx(sizeof(struct irc_netmask)); bcopy(&tmp, nl->ptr.netmask, sizeof(struct irc_netmask)); } } index = tkl_hash(tkl_typetochar(type)); AddListItem(nl, tklines[index]); return nl; } aTKline *tkl_del_line(aTKline *tkl) { aTKline *p, *q; int index = tkl_hash(tkl_typetochar(tkl->type)); for (p = tklines[index]; p; p = p->next) { if (p == tkl) { q = p->next; MyFree(p->hostmask); MyFree(p->reason); MyFree(p->setby); if (p->type & TKL_SPAMF && p->ptr.spamf) { regfree(&p->ptr.spamf->expr); if (p->ptr.spamf->tkl_reason) MyFree(p->ptr.spamf->tkl_reason); MyFree(p->ptr.spamf); } if ((p->type & TKL_KILL || p->type & TKL_ZAP || p->type & TKL_SHUN) && p->ptr.netmask) MyFree(p->ptr.netmask); DelListItem(p, tklines[index]); MyFree(p); return q; } } return NULL; } /* * tkl_check_local_remove_shun: * removes shun from currently connected users affected by tmp. */ static void tkl_check_local_remove_shun(aTKline *tmp) { long i1, i; char *chost, *cname, *cip; int is_ip; aClient *acptr; for (i1 = 0; i1 <= 5; i1++) { /* winlocal for (i = 0; i <= (MAXCONNECTIONS - 1); i++) */ for (i = 0; i <= LastSlot; ++i) { if ((acptr = local[i])) if (MyClient(acptr) && IsShunned(acptr)) { chost = acptr->sockhost; cname = acptr->user->username; cip = GetIP(acptr); 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); #ifdef SHUN_NOTICES sendto_one(acptr, ":%s NOTICE %s :*** You are no longer shunned", me.name, acptr->name); #endif } } } } } aTKline *tkl_expire(aTKline * tmp) { char whattype[512]; if (!tmp) return NULL; whattype[0] = 0; if ((tmp->expire_at == 0) || (tmp->expire_at > TStime())) { sendto_ops ("tkl_expire(): expire for not-yet-expired tkline %s@%s", tmp->usermask, tmp->hostmask); return (tmp->next); } /* Using strlcpy here is wasteful, we know it is < 512 */ if (tmp->type & TKL_GLOBAL) { if (tmp->type & TKL_KILL) strcpy(whattype, "G:Line"); else if (tmp->type & TKL_ZAP) strcpy(whattype, "Global Z:Line"); else if (tmp->type & TKL_SHUN) strcpy(whattype, "Shun"); else if (tmp->type & TKL_NICK) strcpy(whattype, "Global Q:line"); } else { if (tmp->type & TKL_KILL) strcpy(whattype, "K:Line"); else if (tmp->type & TKL_ZAP) strcpy(whattype, "Z:Line"); else if (tmp->type & TKL_SHUN) strcpy(whattype, "Local Shun"); else if (tmp->type & TKL_NICK) strcpy(whattype, "Q:line"); } if (!(tmp->type & TKL_NICK)) { sendto_snomask(SNO_TKL, "*** Expiring %s (%s@%s) made by %s (Reason: %s) set %li seconds ago", whattype, tmp->usermask, tmp->hostmask, tmp->setby, tmp->reason, TStime() - tmp->set_at); ircd_log (LOG_TKL, "Expiring %s (%s@%s) made by %s (Reason: %s) set %li seconds ago", whattype, tmp->usermask, tmp->hostmask, tmp->setby, tmp->reason, TStime() - tmp->set_at); } else if (!(*tmp->usermask == 'H')) /* Q:line but not a hold */ { sendto_snomask(SNO_TKL, "*** Expiring %s (%s) made by %s (Reason: %s) set %li seconds ago", whattype, tmp->hostmask, tmp->setby, tmp->reason, TStime() - tmp->set_at); ircd_log (LOG_TKL, "Expiring %s (%s) made by %s (Reason: %s) set %li seconds ago", whattype, tmp->hostmask, tmp->setby, tmp->reason, TStime() - tmp->set_at); } if (tmp->type & TKL_SHUN) tkl_check_local_remove_shun(tmp); RunHook5(HOOKTYPE_TKL_DEL, NULL, NULL, tmp, 0, NULL); return (tkl_del_line(tmp)); } EVENT(tkl_check_expire) { aTKline *gp, *next; TS nowtime; int index; nowtime = TStime(); for (index = 0; index < TKLISTLEN; index++) for (gp = tklines[index]; gp; gp = next) { next = gp->next; if (gp->expire_at <= nowtime && !(gp->expire_at == 0)) { tkl_expire(gp); } } } /* returns <0 if client exists (banned) returns 1 if it is excepted */ int find_tkline_match(aClient *cptr, int xx) { aTKline *lp; char *chost, *cname, *cip; TS nowtime; char msge[1024]; int points = 0; ConfigItem_except *excepts; char host[NICKLEN+USERLEN+HOSTLEN+6], host2[NICKLEN+USERLEN+HOSTLEN+6]; int match_type = 0; int index; Hook *tmphook; if (IsServer(cptr) || IsMe(cptr)) return -1; nowtime = TStime(); chost = cptr->sockhost; cname = cptr->user ? cptr->user->username : "unknown"; cip = GetIP(cptr); points = 0; for (index = 0; index < TKLISTLEN; index++) { for (lp = tklines[index]; lp; lp = lp->next) { if ((lp->type & TKL_SHUN) || (lp->type & TKL_SPAMF) || (lp->type & TKL_NICK)) continue; /* If it's tangy and brown, you're in CIDR town! */ if (lp->ptr.netmask) { if (match_ip(cptr->ip, NULL, NULL, lp->ptr.netmask) && !match(lp->usermask, cname)) { points = 1; break; } continue; } if (!match(lp->usermask, cname) && !match(lp->hostmask, chost)) { points = 1; break; } if (!match(lp->usermask, cname) && !match(lp->hostmask, cip)) { points = 1; break; } } if (points) break; } if (points != 1) return 1; strcpy(host, make_user_host(cname, chost)); strcpy(host2, make_user_host(cname, cip)); if (((lp->type & TKL_KILL) || (lp->type & TKL_ZAP)) && !(lp->type & TKL_GLOBAL)) match_type = CONF_EXCEPT_BAN; else match_type = CONF_EXCEPT_TKL; for (excepts = conf_except; excepts; excepts = (ConfigItem_except *)excepts->next) { if (excepts->flag.type != match_type || (match_type == CONF_EXCEPT_TKL && excepts->type != lp->type)) continue; if (excepts->netmask) { if (match_ip(cptr->ip, host2, excepts->mask, excepts->netmask)) return 1; } else if (!match(excepts->mask, host) || !match(excepts->mask, host2)) return 1; } for (tmphook = Hooks[HOOKTYPE_TKL_EXCEPT]; tmphook; tmphook = tmphook->next) if (tmphook->func.intfunc(cptr, lp) > 0) return 1; if ((lp->type & TKL_KILL) && (xx != 2)) { if (lp->type & TKL_GLOBAL) { ircstp->is_ref++; if (GLINE_ADDRESS) sendto_one(cptr, ":%s NOTICE %s :*** You are %s from %s (1Serverdan uzaklastirildiniz. 2[ 5Reklam, Küfür, Clone, Trojan 2] 1Gibi eylemler yasaktir. Servera girisinizde 2[ 3/Rules 2) 4Komutunu Kullanip Server Kurallarini Okuyunuz!)" " Email %s for more information.", me.name, cptr->name, (lp->expire_at ? "banned" : "permanently banned"), ircnetwork, lp->reason, GLINE_ADDRESS); else sendto_one(cptr, ":%s NOTICE %s :*** You are %s from %s (1Serverdan uzaklastirildiniz. 2[ 5Reklam, Küfür, Clone, Trojan 2] 1Gibi eylemler yasaktir. Servera girisinizde 2[ 3/Rules 2) 4Komutunu Kullanip Server Kurallarini Okuyunuz!)", me.name, cptr->name, (lp->expire_at ? "banned" : "permanently banned"), ircnetwork, lp->reason); ircsprintf(msge, "User has been %s from %s (1Serverdan uzaklastirildiniz. 2[ 5Reklam, Küfür, Clone, Trojan 2] 1Gibi eylemler yasaktir. Servera girisinizde 2[ 3/Rules 2) 4Komutunu Kullanip Server Kurallarini Okuyunuz!)", (lp->expire_at ? "banned" : "permanently banned"), ircnetwork, lp->reason); return (exit_client(cptr, cptr, &me, msge)); } else { ircstp->is_ref++; sendto_one(cptr, ":%s NOTICE %s :*** You are %s from %s (1Serverdan uzaklastirildiniz. 2[ 5Reklam, Küfür, Clone, Trojan 2] 1Gibi eylemler yasaktir. Servera girisinizde 2[ 3/Rules 2) 4Komutunu Kullanip Server Kurallarini Okuyunuz!)" " Email %s for more information.", me.name, cptr->name, (lp->expire_at ? "banned" : "permanently banned"), me.name, lp->reason, KLINE_ADDRESS); ircsprintf(msge, "User is %s (1Serverdan uzaklastirildiniz. 2[ 5Reklam, Küfür, Clone, Trojan 2] 1Gibi eylemler yasaktir. Servera girisinizde 2[ 3/Rules 2) 4Komutunu Kullanip Server Kurallarini Okuyunuz!)", (lp->expire_at ? "banned" : "permanently banned"), lp->reason); return (exit_client(cptr, cptr, &me, msge)); } } if (lp->type & TKL_ZAP) { ircstp->is_ref++; ircsprintf(msge, "Z:lined (1Serverdan uzaklastirildiniz. 2[ 5Reklam, Küfür, Clone, Trojan 2] 1Gibi eylemler yasaktir. Servera girisinizde 2[ 3/Rules 2) 4Komutunu Kullanip Server Kurallarini Okuyunuz!)",lp->reason); return exit_client(cptr, cptr, &me, msge); } return 3; } int find_shun(aClient *cptr) { aTKline *lp; char *chost, *cname, *cip; TS nowtime; int points = 0; ConfigItem_except *excepts; char host[NICKLEN+USERLEN+HOSTLEN+6], host2[NICKLEN+USERLEN+HOSTLEN+6]; int match_type = 0; if (IsServer(cptr) || IsMe(cptr)) return -1; if (IsShunned(cptr)) return 1; if (IsAdmin(cptr)) return 1; nowtime = TStime(); chost = cptr->sockhost; cname = cptr->user ? cptr->user->username : "unknown"; cip = GetIP(cptr); for (lp = tklines[tkl_hash('s')]; lp; lp = lp->next) { points = 0; if (!(lp->type & TKL_SHUN)) continue; /* CIDR */ if (lp->ptr.netmask) { if (match_ip(cptr->ip, NULL, NULL, lp->ptr.netmask) && !match(lp->usermask, cname)) { points = 1; break; } continue; } if (!match(lp->usermask, cname) && !match(lp->hostmask, chost)) { points = 1; break; } if (!match(lp->usermask, cname) && !match(lp->hostmask, cip)) { points = 1; break; } else points = 0; } if (points != 1) return 1; strcpy(host, make_user_host(cname, chost)); strcpy(host2, make_user_host(cname, cip)); match_type = CONF_EXCEPT_TKL; for (excepts = conf_except; excepts; excepts = (ConfigItem_except *)excepts->next) { if (excepts->flag.type != match_type || (match_type == CONF_EXCEPT_TKL && excepts->type != lp->type)) continue; if (excepts->netmask) { if (match_ip(cptr->ip, NULL, NULL, excepts->netmask)) return 1; } else if (!match(excepts->mask, host) || !match(excepts->mask, host2)) return 1; } SetShunned(cptr); return 2; } /** Checks if the user matches a spamfilter of type 'u' (user, * nick!user@host:realname ban). * Written by: Syzop * Assumes: only call for clients, possible assume on local clients [?] * Return values: see dospamfilter() */ int find_spamfilter_user(aClient *sptr) { char spamfilter_user[NICKLEN + USERLEN + HOSTLEN + REALLEN + 64]; /* n!u@h:r */ if (IsAnOper(sptr)) return 0; ircsprintf(spamfilter_user, "%s!%s@%s:%s", sptr->name, sptr->user->username, sptr->user->realhost, sptr->info); return dospamfilter(sptr, spamfilter_user, SPAMF_USER, NULL); } aTKline *find_qline(aClient *cptr, char *nick, int *ishold) { aTKline *lp; char *chost, *cname, *cip; char host[NICKLEN+USERLEN+HOSTLEN+6], hostbuf2[NICKLEN+USERLEN+HOSTLEN+6], *host2 = NULL; int points = 0; ConfigItem_except *excepts; *ishold = 0; if (IsServer(cptr) || IsMe(cptr)) return NULL; for (lp = tklines[tkl_hash('q')]; lp; lp = lp->next) { points = 0; if (!(lp->type & TKL_NICK)) continue; if (!match(lp->hostmask, nick)) { points = 1; break; } } if (points != 1) return NULL; /* It's a services hold */ if (*lp->usermask == 'H') { *ishold = 1; return lp; } chost = cptr->user ? cptr->user->realhost : (MyConnect(cptr) ? cptr->sockhost : "unknown"); cname = cptr->user ? cptr->user->username : "unknown"; strcpy(host, make_user_host(cname, chost)); cip = GetIP(cptr); if (cip) { strcpy(hostbuf2, make_user_host(cname, cip)); host2 = hostbuf2; } for (excepts = conf_except; excepts; excepts = (ConfigItem_except *)excepts->next) { if (excepts->flag.type != CONF_EXCEPT_TKL || excepts->type != TKL_NICK) continue; if (excepts->netmask) { if (MyConnect(cptr) && match_ip(cptr->ip, NULL, NULL, excepts->netmask)) return NULL; } else if (!match(excepts->mask, host) || (host2 && !match(excepts->mask, host2))) return NULL; } return lp; } int find_tkline_match_zap(aClient *cptr) { aTKline *lp; char *cip; TS nowtime; char msge[1024]; ConfigItem_except *excepts; Hook *tmphook; if (IsServer(cptr) || IsMe(cptr)) return -1; nowtime = TStime(); cip = GetIP(cptr); for (lp = tklines[tkl_hash('z')]; lp; lp = lp->next) { if (lp->type & TKL_ZAP) { if ((lp->ptr.netmask && match_ip(cptr->ip, NULL, NULL, lp->ptr.netmask)) || !match(lp->hostmask, cip)) { for (excepts = conf_except; excepts; excepts = (ConfigItem_except *)excepts->next) { if (excepts->flag.type != CONF_EXCEPT_TKL || excepts->type != lp->type) continue; if (excepts->netmask) { if (match_ip(cptr->ip, NULL, NULL, excepts->netmask)) return -1; } else if (!match(excepts->mask, cip)) return -1; } for (tmphook = Hooks[HOOKTYPE_TKL_EXCEPT]; tmphook; tmphook = tmphook->next) if (tmphook->func.intfunc(cptr, lp) > 0) return -1; ircstp->is_ref++; ircsprintf(msge, "ERROR :Closing Link: [%s] Z:Lined (%s)\r\n", #ifndef INET6 inetntoa((char *)&cptr->ip), lp->reason); #else inet_ntop(AF_INET6, (char *)&cptr->ip, mydummy, MYDUMMY_SIZE), lp->reason); #endif strlcpy(zlinebuf, msge, sizeof zlinebuf); return (1); } } } return -1; } #define BY_MASK 0x1 #define BY_REASON 0x2 #define NOT_BY_MASK 0x4 #define NOT_BY_REASON 0x8 #define BY_SETBY 0x10 #define NOT_BY_SETBY 0x20 typedef struct { int flags; char *mask; char *reason; char *setby; } TKLFlag; void parse_tkl_para(char *para, TKLFlag *flag) { static char paratmp[512]; /* <- copy of para, because it gets fragged by strtok() */ char *flags, *tmp; char what = '+'; strncpyzt(paratmp, para, sizeof(paratmp)); flags = strtok(paratmp, " "); bzero(flag, sizeof(TKLFlag)); for (; *flags; flags++) { switch (*flags) { case '+': what = '+'; break; case '-': what = '-'; break; case 'm': if (flag->mask || !(tmp = strtok(NULL, " "))) continue; if (what == '+') flag->flags |= BY_MASK; else flag->flags |= NOT_BY_MASK; flag->mask = tmp; break; case 'r': if (flag->reason || !(tmp = strtok(NULL, " "))) continue; if (what == '+') flag->flags |= BY_REASON; else flag->flags |= NOT_BY_REASON; flag->reason = tmp; break; case 's': if (flag->setby || !(tmp = strtok(NULL, " "))) continue; if (what == '+') flag->flags |= BY_SETBY; else flag->flags |= NOT_BY_SETBY; flag->setby = tmp; break; } } } void tkl_stats(aClient *cptr, int type, char *para) { aTKline *tk; TS curtime; TKLFlag tklflags; int index; /* We output in this row: Glines,GZlines,KLine, ZLIne Character: G, Z, K, z */ if (!BadPtr(para)) parse_tkl_para(para, &tklflags); tkl_check_expire(NULL); curtime = TStime(); for (index = 0; index < TKLISTLEN; index++) for (tk = tklines[index]; tk; tk = tk->next) { if (type && tk->type != type) continue; if (!BadPtr(para)) { if (tklflags.flags & BY_MASK) { if (tk->type & TKL_NICK) { if (match(tklflags.mask, tk->hostmask)) continue; } else if (match(tklflags.mask, make_user_host(tk->usermask, tk->hostmask))) continue; } if (tklflags.flags & NOT_BY_MASK) { if (tk->type & TKL_NICK) { if (!match(tklflags.mask, tk->hostmask)) continue; } else if (!match(tklflags.mask, make_user_host(tk->usermask, tk->hostmask))) continue; } if (tklflags.flags & BY_REASON) if (match(tklflags.reason, tk->reason)) continue; if (tklflags.flags & NOT_BY_REASON) if (!match(tklflags.reason, tk->reason)) continue; if (tklflags.flags & BY_SETBY) if (match(tklflags.setby, tk->setby)) continue; if (tklflags.flags & NOT_BY_SETBY) if (!match(tklflags.setby, tk->setby)) continue; } if (tk->type == (TKL_KILL | TKL_GLOBAL)) { sendto_one(cptr, rpl_str(RPL_STATSGLINE), me.name, cptr->name, 'G', tk->usermask, tk->hostmask, (tk->expire_at != 0) ? (tk->expire_at - curtime) : 0, (curtime - tk->set_at), tk->setby, tk->reason); } if (tk->type == (TKL_ZAP | TKL_GLOBAL)) { sendto_one(cptr, rpl_str(RPL_STATSGLINE), me.name, cptr->name, 'Z', tk->usermask, tk->hostmask, (tk->expire_at != 0) ? (tk->expire_at - curtime) : 0, (curtime - tk->set_at), tk->setby, tk->reason); } 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 != 0) ? (tk->expire_at - curtime) : 0, (curtime - tk->set_at), tk->setby, tk->reason); } if (tk->type == (TKL_KILL)) { sendto_one(cptr, rpl_str(RPL_STATSGLINE), me.name, cptr->name, 'K', tk->usermask, tk->hostmask, (tk->expire_at != 0) ? (tk->expire_at - curtime) : 0, (curtime - tk->set_at), tk->setby, tk->reason); } if (tk->type == (TKL_ZAP)) { sendto_one(cptr, rpl_str(RPL_STATSGLINE), me.name, cptr->name, 'z', tk->usermask, tk->hostmask, (tk->expire_at != 0) ? (tk->expire_at - curtime) : 0, (curtime - tk->set_at), tk->setby, tk->reason); } if (tk->type & TKL_SPAMF) { sendto_one(cptr, rpl_str(RPL_STATSSPAMF), me.name, cptr->name, (tk->type & TKL_GLOBAL) ? 'F' : 'f', spamfilter_target_inttostring(tk->subtype), banact_valtostring(tk->ptr.spamf->action), (tk->expire_at != 0) ? (tk->expire_at - curtime) : 0, curtime - tk->set_at, tk->ptr.spamf->tkl_duration, tk->ptr.spamf->tkl_reason, tk->setby, tk->reason); } if (tk->type & TKL_NICK) sendto_one(cptr, rpl_str(RPL_STATSQLINE), me.name, cptr->name, (tk->type & TKL_GLOBAL) ? 'Q' : 'q', tk->hostmask, (tk->expire_at != 0) ? (tk->expire_at - curtime) : 0, curtime - tk->set_at, tk->setby, tk->reason); } } void tkl_synch(aClient *sptr) { aTKline *tk; char typ = 0; int index; for (index = 0; index < TKLISTLEN; index++) for (tk = tklines[index]; tk; tk = tk->next) { if (tk->type & TKL_GLOBAL) { if (tk->type & TKL_KILL) typ = 'G'; if (tk->type & TKL_ZAP) typ = 'Z'; if (tk->type & TKL_SHUN) typ = 's'; if (tk->type & TKL_SPAMF) typ = 'F'; if (tk->type & TKL_NICK) typ = 'Q'; if ((tk->type & TKL_SPAMF) && (sptr->proto & PROTO_TKLEXT)) { sendto_one(sptr, ":%s %s + %c %s %s %s %li %li %li %s :%s", me.name, IsToken(sptr) ? TOK_TKL : MSG_TKL, typ, tk->usermask, tk->hostmask, tk->setby, tk->expire_at, tk->set_at, tk->ptr.spamf->tkl_duration, tk->ptr.spamf->tkl_reason, tk->reason); } else sendto_one(sptr, ":%s %s + %c %s %s %s %li %li :%s", me.name, IsToken(sptr) ? TOK_TKL : MSG_TKL, typ, tk->usermask ? tk->usermask : "*", tk->hostmask, tk->setby, tk->expire_at, tk->set_at, tk->reason); } } } /* * m_tkl: * HISTORY: * This was originall called Timed KLines, but today it's * used by various *line types eg: zline, gline, gzline, shun, * but also by spamfilter etc... * USAGE: * This routine is used both internally by the ircd (to * for example add local klines, zlines, etc) and over the * network (glines, gzlines, spamfilter, etc). * add: remove: spamfilter: spamfilter+TKLEXT sqline: * parv[ 1]: + - +/- + +/- * parv[ 2]: type type type type type * parv[ 3]: user user target target hold * parv[ 4]: host host action action host * parv[ 5]: setby removedby (un)setby setby setby * parv[ 6]: expire_at expire_at (0) expire_at (0) expire_at * parv[ 7]: set_at set_at set_at set_at * parv[ 8]: reason regex tkl duration reason * parv[ 9]: tkl reason [A] * parv[10]: regex * * [A] tkl reason field must be escaped by caller [eg: use unreal_encodespace() * if m_tkl is called internally]. * */ int m_tkl(aClient *cptr, aClient *sptr, int parc, char *parv[]) { aTKline *tk; int type; int found = 0; char gmt[256], gmt2[256]; char txt[256]; TS expiry_1, setat_1, spamf_tklduration = 0; char *reason = NULL; if (!IsServer(sptr) && !IsOper(sptr) && !IsMe(sptr)) return 0; if (parc < 2) return 0; tkl_check_expire(NULL); switch (*parv[1]) { case '+': { /* we relay on servers to be failsafe.. */ if (!IsServer(sptr) && !IsMe(sptr)) return 0; if (parc < 9) return 0; if (parv[2][0] == 'G') type = TKL_KILL | TKL_GLOBAL; else if (parv[2][0] == 'Z') type = TKL_ZAP | TKL_GLOBAL; else if (parv[2][0] == 'z') type = TKL_ZAP; else if (parv[2][0] == 'k') type = TKL_KILL; else if (parv[2][0] == 's') type = TKL_SHUN | TKL_GLOBAL; else if (parv[2][0] == 'f') type = TKL_SPAMF; else if (parv[2][0] == 'F') type = TKL_SPAMF | TKL_GLOBAL; else if (parv[2][0] == 'Q') type = TKL_NICK | TKL_GLOBAL; else if (parv[2][0] == 'q') type = TKL_NICK; else return 0; expiry_1 = atol(parv[6]); setat_1 = atol(parv[7]); reason = parv[8]; found = 0; if ((type & TKL_SPAMF) && (parc >= 11)) { reason = parv[10]; spamf_tklduration = config_checkval(parv[8], CFG_TIME); /* was: atol(parv[8]); */ } for (tk = tklines[tkl_hash(parv[2][0])]; tk; tk = tk->next) { if (tk->type == type) { if ((tk->type & TKL_NICK) && !stricmp(tk->hostmask, parv[4])) { found = 1; break; } else if (!strcmp(tk->hostmask, parv[4]) && !strcmp(tk->usermask, parv[3]) && (!(type & TKL_SPAMF) || !stricmp(tk->reason, reason))) { found = 1; break; } } } /* *:Line already exists! */ if (found == 1) { /* SYZTAG: TODO: check for tklreason/tklduration differnces */ /* do they differ in ANY way? */ if (type & TKL_NICK) { /* for sqline: usermask = H overrides */ if (*parv[3] == 'H') *tk->usermask = 'H'; } if ((setat_1 != tk->set_at) || (expiry_1 != tk->expire_at) || strcmp(tk->reason, reason) || strcmp(tk->setby, parv[5])) { /* here's how it goes: * set_at: oldest wins * expire_at: longest wins * reason: highest strcmp wins * setby: highest strcmp wins * We broadcast the result of this back to all servers except * cptr's direction, because cptr will do the same thing and * send it back to his servers (except us)... no need for a * double networkwide flood ;p. -- Syzop */ tk->set_at = MIN(tk->set_at, setat_1); if (!tk->expire_at || !expiry_1) tk->expire_at = 0; else tk->expire_at = MAX(tk->expire_at, expiry_1); if (strcmp(tk->reason, reason) < 0) { MyFree(tk->reason); tk->reason = strdup(reason); } if (strcmp(tk->setby, parv[5]) < 0) { MyFree(tk->setby); tk->setby = strdup(parv[5]); } if (tk->type & TKL_NICK) { if (!(*tk->usermask) == 'H') sendto_snomask(SNO_JUNK, "tkl update for %s/reason='%s'/by=%s/set=%ld/expire=%ld [causedby: %s]", tk->hostmask, tk->reason, tk->setby, tk->set_at, tk->expire_at, sptr->name); } else sendto_snomask(SNO_JUNK, "tkl update for %s@%s/reason='%s'/by=%s/set=%ld/expire=%ld [causedby: %s]", tk->usermask, tk->hostmask, tk->reason, tk->setby, tk->set_at, tk->expire_at, sptr->name); if ((parc == 11) && (type & TKL_SPAMF)) { /* I decided to only send updates to OPT_TKLEXT in this case, * it's pretty useless to send it also to OPT_NOT_TKLEXT because * spamfilter entries are permanent (no expire time), the only stuff * that can differ for non-opt is the 'setby' and 'setat' field... */ sendto_serv_butone_token_opt(cptr, OPT_TKLEXT, sptr->name, MSG_TKL, TOK_TKL, "%s %s %s %s %s %ld %ld %ld %s :%s", parv[1], parv[2], parv[3], parv[4], tk->setby, tk->expire_at, tk->set_at, tk->ptr.spamf->tkl_duration, tk->ptr.spamf->tkl_reason, tk->reason); } else if (type & TKL_GLOBAL) sendto_serv_butone(cptr, ":%s TKL %s %s %s %s %s %ld %ld :%s", sptr->name, parv[1], parv[2], parv[3], parv[4], tk->setby, tk->expire_at, tk->set_at, tk->reason); } return 0; } /* there is something fucked here? */ if ((type & TKL_SPAMF) && (parc >= 11)) tk = tkl_add_line(type, parv[3], parv[4], reason, parv[5], expiry_1, setat_1, spamf_tklduration, parv[9]); else tk = tkl_add_line(type, parv[3], parv[4], reason, parv[5], expiry_1, setat_1, 0, NULL); if (tk) RunHook5(HOOKTYPE_TKL_ADD, cptr, sptr, tk, parc, parv); strncpyzt(gmt, asctime(gmtime((TS *)&setat_1)), sizeof(gmt)); strncpyzt(gmt2, asctime(gmtime((TS *)&expiry_1)), sizeof(gmt2)); iCstrip(gmt); iCstrip(gmt2); switch (type) { case TKL_KILL: strcpy(txt, "K:Line"); break; case TKL_ZAP: strcpy(txt, "Z:Line"); break; case TKL_KILL | TKL_GLOBAL: strcpy(txt, "G:Line"); break; case TKL_ZAP | TKL_GLOBAL: strcpy(txt, "Global Z:line"); break; case TKL_SHUN | TKL_GLOBAL: strcpy(txt, "Shun"); break; case TKL_NICK | TKL_GLOBAL: strcpy(txt, "Global Q:line"); break; case TKL_NICK: strcpy(txt, "Q:line"); break; default: strcpy(txt, "Unknown *:Line"); } if (type & TKL_SPAMF) { char buf[512]; snprintf(buf, 512, "Spamfilter added: '%s' [target: %s] [action: %s] [reason: %s] on %s GMT (from %s)", reason, parv[3], banact_valtostring(banact_chartoval(*parv[4])), parc >= 10 ? unreal_decodespace(parv[9]) : SPAMFILTER_BAN_REASON, gmt, parv[5]); sendto_snomask(SNO_TKL, "*** %s", buf); ircd_log(LOG_TKL, "%s", buf); } else { char buf[512]; if (expiry_1 != 0) { if (type & TKL_NICK) { if (*parv[3] != 'H') snprintf(buf, 512, "%s added for %s on %s GMT (from %s to expire at %s GMT: %s)", txt, parv[4], gmt, parv[5], gmt2, reason); } else snprintf(buf, 512, "%s added for %s@%s on %s GMT (from %s to expire at %s GMT: %s)", txt, parv[3], parv[4], gmt, parv[5], gmt2, reason); } else { if (type & TKL_NICK) { if (*parv[3] != 'H') snprintf(buf, 512, "Permanent %s added for %s on %s GMT (from %s: %s)", txt, parv[4], gmt, parv[5], reason); } else snprintf(buf, 512, "Permanent %s added for %s@%s on %s GMT (from %s: %s)", txt, parv[3], parv[4], gmt, parv[5], reason); } if (!((type & TKL_NICK) && *parv[3] == 'H')) { sendto_snomask(SNO_TKL, "*** %s", buf); ircd_log(LOG_TKL, "%s", buf); } } loop.do_bancheck = 1; /* Makes check_pings be run ^^ */ if (type & TKL_GLOBAL) { if ((parc == 11) && (type & TKL_SPAMF)) { sendto_serv_butone_token_opt(cptr, OPT_TKLEXT, sptr->name, MSG_TKL, TOK_TKL, "%s %s %s %s %s %s %s %s %s :%s", parv[1], parv[2], parv[3], parv[4], parv[5], parv[6], parv[7], parv[8], parv[9], parv[10]); sendto_serv_butone_token_opt(cptr, OPT_NOT_TKLEXT, sptr->name, MSG_TKL, TOK_TKL, "%s %s %s %s %s %s %s :%s", parv[1], parv[2], parv[3], parv[4], parv[5], parv[6], parv[7], parv[10]); } else sendto_serv_butone(cptr, ":%s TKL %s %s %s %s %s %s %s :%s", sptr->name, parv[1], parv[2], parv[3], parv[4], parv[5], parv[6], parv[7], parv[8]); } /* TKL_GLOBAL */ return 0; } case '-': if (!IsServer(sptr) && !IsMe(sptr)) return 0; if (*parv[2] == 'G') type = TKL_KILL | TKL_GLOBAL; else if (*parv[2] == 'Z') type = TKL_ZAP | TKL_GLOBAL; else if (*parv[2] == 'z') type = TKL_ZAP; else if (*parv[2] == 'k') type = TKL_KILL; else if (*parv[2] == 's') type = TKL_SHUN | TKL_GLOBAL; else if (*parv[2] == 'Q') type = TKL_NICK | TKL_GLOBAL; else if (*parv[2] == 'q') type = TKL_NICK; else if (*parv[2] == 'F') { if (parc < 8) { sendto_realops("[BUG] m_tkl called with bogus spamfilter removal request [F], from=%s, parc=%d", sptr->name, parc); return 0; /* bogus */ } type = TKL_SPAMF | TKL_GLOBAL; if (parc >= 11) reason = parv[10]; else reason = parv[8]; } else if (*parv[2] == 'f') { if (parc < 8) { sendto_realops("[BUG] m_tkl called with bogus spamfilter removal request [f], from=%s, parc=%d", sptr->name, parc); return 0; /* bogus */ } type = TKL_SPAMF; if (parc >= 11) reason = parv[10]; else reason = parv[8]; } else return 0; switch (type) { case TKL_KILL: strcpy(txt, "K:Line"); break; case TKL_ZAP: strcpy(txt, "Z:Line"); break; case TKL_KILL | TKL_GLOBAL: strcpy(txt, "G:Line"); break; case TKL_ZAP | TKL_GLOBAL: strcpy(txt, "Global Z:line"); break; case TKL_SHUN | TKL_GLOBAL: strcpy(txt, "Shun"); break; case TKL_NICK | TKL_GLOBAL: strcpy(txt, "Global Q:line"); break; case TKL_NICK: strcpy(txt, "Q:line"); break; default: strcpy(txt, "Unknown *:Line"); } found = 0; for (tk = tklines[tkl_hash(parv[2][0])]; tk; tk = tk->next) { if (tk->type == type) { int match = 0; if (type & TKL_NICK) { if (!stricmp(tk->hostmask, parv[4])) match = 1; } else if (type & TKL_SPAMF) { if (!strcmp(tk->hostmask, parv[4]) && !strcmp(tk->usermask, parv[3]) && !stricmp(tk->reason, reason)) match = 1; } else /* all other types... */ if (!stricmp(tk->hostmask, parv[4]) && !stricmp(tk->usermask, parv[3])) match = 1; if (match) { strncpyzt(gmt, asctime(gmtime((TS *)&tk->set_at)), sizeof(gmt)); iCstrip(gmt); /* broadcast remove msg to opers... */ if (type & TKL_NICK) { if (!(*parv[3] == 'H')) { sendto_snomask(SNO_TKL, "%s removed %s %s (set at %s - reason: %s)", parv[5], txt, tk->hostmask, gmt, tk->reason); ircd_log(LOG_TKL, "%s removed %s %s (set at %s - reason: %s)", parv[5], txt, tk->hostmask, gmt, tk->reason); } } else if (type & TKL_SPAMF) { sendto_snomask(SNO_TKL, "%s removed Spamfilter '%s' (set at %s)", parv[5], tk->reason, gmt); ircd_log(LOG_TKL, "%s removed Spamfilter '%s' (set at %s)", parv[5], tk->reason, gmt); } else { sendto_snomask(SNO_TKL, "%s removed %s %s@%s (set at %s - reason: %s)", parv[5], txt, tk->usermask, tk->hostmask, gmt, tk->reason); ircd_log(LOG_TKL, "%s removed %s %s@%s (set at %s - reason: %s)", parv[5], txt, tk->usermask, tk->hostmask, gmt, tk->reason); } if (type & TKL_SHUN) tkl_check_local_remove_shun(tk); RunHook5(HOOKTYPE_TKL_DEL, cptr, sptr, tk, parc, parv); tkl_del_line(tk); if (type & TKL_GLOBAL) { if (parc < 8) sendto_serv_butone(cptr, ":%s TKL %s %s %s %s %s", sptr->name, parv[1], parv[2], parv[3], parv[4], parv[5]); else sendto_serv_butone(cptr, ":%s TKL %s %s %s %s %s %s %s :%s", sptr->name, parv[1], parv[2], parv[3], parv[4], parv[5], parv[6], parv[7], reason); } break; } } } break; case '?': if (IsAnOper(sptr)) tkl_stats(sptr,0,NULL); } return 0; } /* execute_ban_action, a tkl helper. (Syzop/2003) * PARAMETERS: * sptr: the client which is affected * action: type of ban (BAN_ACT*) * reason: ban reason * duration: duration of ban in seconds * WHAT IT DOES: * This function will shun/kline/gline/zline the user. * If the action field is 0 (BAN_ACT_KILL) the user is * just killed (and the time parameter is ignored). * ASSUMES: * This function assumes that sptr is locally connected. * RETURN VALUE: * -1 in case of block/tempshun, FLUSH_BUFFER in case of * kill/zline/gline/etc.. (you should NOT read from 'sptr' * after you got FLUSH_BUFFER!!!) */ int place_host_ban(aClient *sptr, int action, char *reason, long duration) { switch(action) { case BAN_ACT_TEMPSHUN: /* We simply mark this connection as shunned and do not add a ban record */ 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 : GetIP(sptr), reason); SetShunned(sptr); break; case BAN_ACT_SHUN: case BAN_ACT_KLINE: case BAN_ACT_ZLINE: case BAN_ACT_GLINE: case BAN_ACT_GZLINE: { char hostip[128], mo[100], mo2[100]; char *tkllayer[9] = { me.name, /*0 server.name */ "+", /*1 +|- */ "?", /*2 type */ "*", /*3 user */ NULL, /*4 host */ NULL, NULL, /*6 expire_at */ NULL, /*7 set_at */ NULL /*8 reason */ }; strlcpy(hostip, GetIP(sptr), sizeof(hostip)); if (action == BAN_ACT_KLINE) tkllayer[2] = "k"; else if (action == BAN_ACT_ZLINE) tkllayer[2] = "z"; else if (action == BAN_ACT_GZLINE) tkllayer[2] = "Z"; else if (action == BAN_ACT_GLINE) tkllayer[2] = "G"; else if (action == BAN_ACT_SHUN) tkllayer[2] = "s"; tkllayer[4] = hostip; tkllayer[5] = me.name; if (!duration) strcpy(mo, "0"); /* perm */ else ircsprintf(mo, "%li", duration + TStime()); ircsprintf(mo2, "%li", TStime()); tkllayer[6] = mo; tkllayer[7] = mo2; tkllayer[8] = reason; m_tkl(&me, &me, 9, tkllayer); if (action == BAN_ACT_SHUN) { find_shun(sptr); return -1; } else return find_tkline_match(sptr, 0); } case BAN_ACT_KILL: default: return exit_client(sptr, sptr, sptr, reason); } return -1; } /** Checks if 'target' is on the spamfilter exception list. * RETURNS 1 if found in list, 0 if not. */ int target_is_spamexcept(char *target) { SpamExcept *e; for (e = iConf.spamexcept; e; e = e->next) { if (!match(e->name, target)) return 1; } return 0; } /** dospamfilter: executes the spamfilter onto the string. * str: the text (eg msg text, notice text, part text, quit text, etc * type: the spamfilter type (SPAMF_*) * RETURN VALUE: * 0 if not matched, non-0 if it should be blocked. * Return value can be FLUSH_BUFFER (-2) which means 'sptr' is * _NOT_ valid anymore so you should return immediately * (like from m_message, m_part, m_quit, etc). */ int dospamfilter(aClient *sptr, char *str_in, int type, char *target) { aTKline *tk; char *str; if (type == SPAMF_USER) str = str_in; else str = (char *)StripControlCodes(str_in); /* (note: using sptr->user check here instead of IsPerson() * due to SPAMF_USER where user isn't marked as client/person yet. */ if (!sptr->user || IsAnOper(sptr) || IsULine(sptr)) return 0; for (tk = tklines[tkl_hash('F')]; tk; tk = tk->next) { if (!(tk->subtype & type)) continue; if (!regexec(&tk->ptr.spamf->expr, str, 0, NULL, 0)) { /* matched! */ char buf[1024]; char targetbuf[48]; if (target) { targetbuf[0] = ' '; strlcpy(targetbuf+1, target, sizeof(targetbuf)-1); /* cut it off */ } else targetbuf[0] = '\0'; /* Hold on.. perhaps it's on the exceptions list... */ if (target && target_is_spamexcept(target)) return 0; /* No problem! */ ircsprintf(buf, "[Spamfilter] %s!%s@%s matches filter '%s': [%s%s: '%s'] [%s]", sptr->name, sptr->user->username, sptr->user->realhost, tk->reason, spamfilter_inttostring_long(type), targetbuf, str, unreal_decodespace(tk->ptr.spamf->tkl_reason)); sendto_snomask(SNO_SPAMF, "%s", buf); sendto_serv_butone_token(NULL, me.name, MSG_SENDSNO, TOK_SENDSNO, "S :%s", buf); ircd_log(LOG_SPAMFILTER, "%s", buf); if (tk->ptr.spamf->action == BAN_ACT_BLOCK) { switch(type) { case SPAMF_USERMSG: case SPAMF_USERNOTICE: sendnotice(sptr, "Message to %s blocked: %s", target, unreal_decodespace(tk->ptr.spamf->tkl_reason)); break; case SPAMF_CHANMSG: case SPAMF_CHANNOTICE: sendto_one(sptr, ":%s 404 %s %s :Message blocked: %s", me.name, sptr->name, target, unreal_decodespace(tk->ptr.spamf->tkl_reason)); break; case SPAMF_DCC: sendnotice(sptr, "DCC to %s blocked: %s", target, unreal_decodespace(tk->ptr.spamf->tkl_reason)); break; case SPAMF_AWAY: /* hack to deal with 'after-away-was-set-filters' */ if (sptr->user->away && !strcmp(str_in, sptr->user->away)) { /* free away & broadcast the unset */ MyFree(sptr->user->away); sptr->user->away = NULL; sendto_serv_butone_token(sptr, sptr->name, MSG_AWAY, TOK_AWAY, ""); } break; case SPAMF_TOPIC: //... sendnotice(sptr, "Setting of topic on %s to that text is blocked: %s", target, unreal_decodespace(tk->ptr.spamf->tkl_reason)); break; default: break; } return -1; } else if (tk->ptr.spamf->action == BAN_ACT_DCCBLOCK) { if (type == SPAMF_DCC) { sendnotice(sptr, "DCC to %s blocked: %s", target, unreal_decodespace(tk->ptr.spamf->tkl_reason)); sendnotice(sptr, "*** You have been blocked from sending files, " "reconnect to regain permission to send files"); sptr->flags |= FLAGS_DCCBLOCK; } return -1; } else if (tk->ptr.spamf->action == BAN_ACT_VIRUSCHAN) { char *xparv[3], chbuf[CHANNELLEN + 16]; aChannel *chptr; int ret; if (IsVirus(sptr)) /* Already tagged */ return 0; ircsprintf(buf, "0,%s", SPAMFILTER_VIRUSCHAN); xparv[0] = sptr->name; xparv[1] = buf; xparv[2] = NULL; /* RECURSIVE CAUTION in case we ever add blacklisted chans */ spamf_ugly_vchanoverride = 1; ret = do_cmd(sptr, sptr, "JOIN", 2, xparv); spamf_ugly_vchanoverride = 0; if (ret == FLUSH_BUFFER) return FLUSH_BUFFER; /* don't ask me how we could have died... */ sendnotice(sptr, "You are now restricted to talking in %s: %s", SPAMFILTER_VIRUSCHAN, unreal_decodespace(tk->ptr.spamf->tkl_reason)); /* todo: send notice to channel? */ chptr = find_channel(SPAMFILTER_VIRUSCHAN, NULL); if (chptr) { ircsprintf(chbuf, "@%s", chptr->chname); ircsprintf(buf, "[Spamfilter] %s matched filter '%s' [%s%s] [%s]", sptr->name, tk->reason, spamfilter_inttostring_long(type), targetbuf, unreal_decodespace(tk->ptr.spamf->tkl_reason)); sendto_channelprefix_butone_tok(NULL, &me, chptr, PREFIX_OP|PREFIX_ADMIN|PREFIX_OWNER, MSG_NOTICE, TOK_NOTICE, chbuf, buf, 0); } SetVirus(sptr); return -1; } else return place_host_ban(sptr, tk->ptr.spamf->action, unreal_decodespace(tk->ptr.spamf->tkl_reason), tk->ptr.spamf->tkl_duration); } } return 0; }


  Alıntı ile Cevapla

Alt 25 Nisan 2007, 07:55   #13
Çevrimdışı
Cevap: /* Yuzukchat.Net IRC(d) Dosyaları */




Arkadaşlar, neyi nereye atacağınızı bilmiyorsanız daha detaylı bilgi almak için bu başlık altında sorularınızı yöneltebilirsiniz.

Faydalı paylaşımlar..

  Alıntı ile Cevapla

Alt 02 Mayıs 2007, 22:08   #14
Çevrimdışı
Cevap: /* Yuzukchat.Net IRC(d) Dosyaları */




öncelikle Paylaşım için tşkler ama Bu ircop.c dosyası nerede ben bulamadım bi yardım etsen

  Alıntı ile Cevapla

Alt 13 Mayıs 2007, 04:04   #15
Çevrimdışı
Cevap: /* Yuzukchat.Net IRC(d) Dosyaları */




Bende bunlar kurulu
Bu forumdaki linkleri ve resimleri görebilmek için en az 25 mesajınız olması gerekir.

  Alıntı ile Cevapla

Alt 13 Mayıs 2007, 08:55   #16
Çevrimdışı
Cevap: /* Yuzukchat.Net IRC(d) Dosyaları */




MaRaShaL Nickli Üyeden Alıntı
Bende bunlar kurulu
Bu forumdaki linkleri ve resimleri görebilmek için en az 25 mesajınız olması gerekir.

nasıl kurulu herkezde kurulu zaten

  Alıntı ile Cevapla

Alt 13 Mayıs 2007, 10:36   #17
Çevrimdışı
Yanıt: /* Yuzukchat.Net IRC(d) Dosyaları */




evet ) Herkeste KuruLu Yinede Confolarak Ziplese Di Daha iyi Olacaqini saniyordum

  Alıntı ile Cevapla

Alt 13 Mayıs 2007, 13:40   #18
Çevrimdışı
Cevap: /* Yuzukchat.Net IRC(d) Dosyaları */




rootmaster m_ircops.c , Unreal/src/modules icinde.

  Alıntı ile Cevapla

Cevapla

Etiketler
dosyalari, dosyaları, ircd, yuzukchatnet

Seçenekler
Stil

Yetkileriniz
Konu Acma Yetkiniz Yok
Cevap Yazma Yetkiniz Yok
Eklenti Yükleme Yetkiniz Yok
Mesajınızı Değiştirme Yetkiniz Yok

BB code is Açık
Smileler Açık
[IMG] Kodları Açık
HTML-Kodu Kapalı
Trackbacks are Kapalı
Pingbacks are Açık
Refbacks are Açık