[IRC-Dev CVS] [CVS] Module ircd-ircdev: Change committed
Brought to you by:
zolty
From: Toni G. <zo...@us...> - 2005-07-03 18:45:09
|
CVSROOT : /cvsroot/irc-dev Module : ircd-ircdev Commit time: 2005-07-03 18:45:02 UTC Modified files: ChangeLog ChangeLog.es include/ddb.h include/s_user.h ircd/ddb.c ircd/ddb_events.c ircd/s_conf.c ircd/s_user.c Log message: Author: zoltan <zo...@ir...> Log message: 2005-07-03 Toni García <zo...@ir...> 1.0.alpha41 * IPs cifradas (sólo IPv4) ---------------------- diff included ---------------------- Index: ircd-ircdev/ChangeLog diff -u ircd-ircdev/ChangeLog:1.42 ircd-ircdev/ChangeLog:1.43 --- ircd-ircdev/ChangeLog:1.42 Wed Jun 22 02:58:52 2005 +++ ircd-ircdev/ChangeLog Sun Jul 3 11:44:51 2005 @@ -1,10 +1,13 @@ # # ChangeLog for ircd-ircdev # -# $Id: ChangeLog,v 1.42 2005/06/22 09:58:52 zolty Exp $ +# $Id: ChangeLog,v 1.43 2005/07/03 18:44:51 zolty Exp $ # # Insert new changes at beginning of the change list. # +2005-07-03 Toni García <zo...@ir...> 1.0.alpha41 + * Crypted ips (only IPv4) + 2005-06-22 Toni García <zo...@ir...> 1.0.alpha40 * Vhosts table v * /LIST with wildcards Index: ircd-ircdev/ChangeLog.es diff -u ircd-ircdev/ChangeLog.es:1.42 ircd-ircdev/ChangeLog.es:1.43 --- ircd-ircdev/ChangeLog.es:1.42 Wed Jun 22 02:58:52 2005 +++ ircd-ircdev/ChangeLog.es Sun Jul 3 11:44:51 2005 @@ -1,10 +1,13 @@ # # Log de Cambios para ircd-ircdev # -# $Id: ChangeLog.es,v 1.42 2005/06/22 09:58:52 zolty Exp $ +# $Id: ChangeLog.es,v 1.43 2005/07/03 18:44:51 zolty Exp $ # # Insertar los nuevos cambios al principio de esta lista de cambios. # +2005-07-03 Toni García <zo...@ir...> 1.0.alpha41 + * IPs cifradas (sólo IPv4) + 2005-06-22 Toni García <zo...@ir...> 1.0.alpha40 * Tabla v de Vhosts * /LIST con comodines Index: ircd-ircdev/include/ddb.h diff -u ircd-ircdev/include/ddb.h:1.11 ircd-ircdev/include/ddb.h:1.12 --- ircd-ircdev/include/ddb.h:1.11 Wed Jun 22 02:58:52 2005 +++ ircd-ircdev/include/ddb.h Sun Jul 3 11:44:51 2005 @@ -21,7 +21,7 @@ */ /** @file * @brief Distributed DataBases structures, macros and functions. - * @version $Id: ddb.h,v 1.11 2005/06/22 09:58:52 zolty Exp $ + * @version $Id: ddb.h,v 1.12 2005/07/03 18:44:51 zolty Exp $ */ #ifndef INCLUDED_ddb_h #define INCLUDED_ddb_h @@ -70,7 +70,8 @@ #define DDB_CONFIGDB_MAX_CLONES_PER_IP "maxclones" /** Message to clients with too many clones from your ip */ #define DDB_CONFIGDB_MSG_TOO_MANY_FROM_IP "msgmanyperip" - +/** Key to crypt ips */ +#define DDB_CONFIGDB_IP_CRYPT_KEY "ipcryptkey" /* * PseudoBots @@ -163,6 +164,12 @@ extern void ddb_db_hash_write(unsigned char table); extern void ddb_db_end(void); +/* PROVISIONAL */ +extern int max_clones; +extern char *msg_many_clones; +extern char *ip_crypt_key; +extern unsigned int binary_ip_crypt_key[2]; + #endif /* defined(DDB) */ #endif /* INCLUDED_ddb_h */ Index: ircd-ircdev/include/s_user.h diff -u ircd-ircdev/include/s_user.h:1.7 ircd-ircdev/include/s_user.h:1.8 --- ircd-ircdev/include/s_user.h:1.7 Thu Mar 31 04:58:03 2005 +++ ircd-ircdev/include/s_user.h Sun Jul 3 11:44:51 2005 @@ -21,7 +21,7 @@ */ /** @file s_user.h * @brief Miscellaneous user-related helper functions. - * @version $Id: s_user.h,v 1.7 2005/03/31 12:58:03 zolty Exp $ + * @version $Id: s_user.h,v 1.8 2005/07/03 18:44:51 zolty Exp $ */ #ifndef INCLUDED_s_user_h #define INCLUDED_s_user_h @@ -123,7 +123,7 @@ extern void send_user_info(struct Client* to, char* names, int rpl, InfoFormatter fmt); -extern int hide_hostmask(struct Client *cptr, unsigned int flags); +extern int hide_hostmask(struct Client *cptr, const char *vhost, unsigned int flags); extern int set_user_mode(struct Client *cptr, struct Client *sptr, int parc, char *parv[]); extern int is_silenced(struct Client *sptr, struct Client *acptr); Index: ircd-ircdev/ircd/ddb.c diff -u ircd-ircdev/ircd/ddb.c:1.12 ircd-ircdev/ircd/ddb.c:1.13 --- ircd-ircdev/ircd/ddb.c:1.12 Wed Jun 22 02:58:52 2005 +++ ircd-ircdev/ircd/ddb.c Sun Jul 3 11:44:52 2005 @@ -22,7 +22,7 @@ */ /** @file * @brief Implementation of Distributed DataBase. - * @version $Id: ddb.c,v 1.12 2005/06/22 09:58:52 zolty Exp $ + * @version $Id: ddb.c,v 1.13 2005/07/03 18:44:52 zolty Exp $ */ #include "config.h" @@ -344,9 +344,7 @@ else ddb_del_key(table, keytemp); - /* TODO */ - /* Ejecutamos los eventos */ - /* if (!cptr && ddb_events_table[table]) */ +/* if (cptr && ddb_events_table[table]) */ if (ddb_events_table[table]) ddb_events_table[table](key, content, update); } Index: ircd-ircdev/ircd/ddb_events.c diff -u ircd-ircdev/ircd/ddb_events.c:1.8 ircd-ircdev/ircd/ddb_events.c:1.9 --- ircd-ircdev/ircd/ddb_events.c:1.8 Wed Jun 22 02:58:52 2005 +++ ircd-ircdev/ircd/ddb_events.c Sun Jul 3 11:44:52 2005 @@ -21,7 +21,7 @@ */ /** @file * @brief Events of Distributed DataBases. - * @version $Id: ddb_events.c,v 1.8 2005/06/22 09:58:52 zolty Exp $ + * @version $Id: ddb_events.c,v 1.9 2005/07/03 18:44:52 zolty Exp $ */ #include "config.h" @@ -38,6 +38,7 @@ #include "send.h" #include <stdio.h> +#include <stdlib.h> #include <string.h> /** It indicates events is initialized */ @@ -51,6 +52,11 @@ static void ddb_events_table_v(char *key, char *content, int update); static void ddb_events_table_z(char *key, char *content, int update); +/* PROVISIONAL */ +int max_clones; +char *msg_many_clones; +char *ip_crypt_key; +unsigned int binary_ip_crypt_key[2]; /** Initialize events module of %DDB Distributed DataBases. */ @@ -359,24 +365,18 @@ /* Droping Key */ if (!content) { - /* if (IsHiddenHost(cptr)) { - ircd_snprintf(0, cli_user(cptr)->host, HOSTLEN, "SINIP"); - hide_hostmask(cptr, FLAG_HIDDENHOST); - + hide_hostmask(cptr, 0, FLAG_NICKREG); } - */ } - else if (content) + else if (content && update) { - if (IsHiddenHost(cptr)) - { - ircd_snprintf(0, cli_user(cptr)->host, HOSTLEN, content); - hide_hostmask(cptr, FLAG_NICKREG); - - } - } + if (strcmp(content, cli_user(cptr)->host)) + hide_hostmask(cptr, content, FLAG_NICKREG); + } + else + hide_hostmask(cptr, content, FLAG_NICKREG); } } @@ -388,4 +388,38 @@ static void ddb_events_table_z(char *key, char *content, int update) { + if (content) + { + if (!strcmp(key, DDB_CONFIGDB_MAX_CLONES_PER_IP)) + max_clones = atoi(content); + else if (!strcmp(key, DDB_CONFIGDB_MSG_TOO_MANY_FROM_IP)) + msg_many_clones = content; + else if (!strcmp(key, DDB_CONFIGDB_IP_CRYPT_KEY)) + { + char keytmp[12 + 1]; + char c; + + ip_crypt_key = content; + strncpy(keytmp, content, 12); + keytmp[12] = '\0'; + c = keytmp[6]; + keytmp[6] = '\0'; + binary_ip_crypt_key[0] = base64toint(keytmp); + keytmp[6] = c; + binary_ip_crypt_key[1] = base64toint(keytmp + 6); + } + } + else + { + if (!strcmp(key, DDB_CONFIGDB_MAX_CLONES_PER_IP)) + max_clones = 0; + else if (!strcmp(key, DDB_CONFIGDB_MSG_TOO_MANY_FROM_IP)) + msg_many_clones = NULL; + else if (!strcmp(key, DDB_CONFIGDB_IP_CRYPT_KEY)) + { + ip_crypt_key = NULL; + binary_ip_crypt_key[0] = 0; + binary_ip_crypt_key[1] = 0; + } + } } Index: ircd-ircdev/ircd/s_conf.c diff -u ircd-ircdev/ircd/s_conf.c:1.18 ircd-ircdev/ircd/s_conf.c:1.19 --- ircd-ircdev/ircd/s_conf.c:1.18 Wed Jun 22 00:54:30 2005 +++ ircd-ircdev/ircd/s_conf.c Sun Jul 3 11:44:52 2005 @@ -21,7 +21,7 @@ */ /** @file * @brief ircd configuration file driver - * @version $Id: s_conf.c,v 1.18 2005/06/22 07:54:30 zolty Exp $ + * @version $Id: s_conf.c,v 1.19 2005/07/03 18:44:52 zolty Exp $ */ #include "config.h" @@ -375,20 +375,17 @@ ddb = ddb_find_key(DDB_ILINEDB, (char *)ircd_ntoa(&cli_ip(cptr))); if (ddb && (clones = atoi(ddb_content(ddb)))) maxclones = clones; - else if ((ddb = ddb_find_key(DDB_CONFIGDB, DDB_CONFIGDB_MAX_CLONES_PER_IP)) - && (clones = atoi(ddb_content(ddb)))) - maxclones = clones; + else if (max_clones) /* DDB */ + maxclones = max_clones; else maxclones = aconf->maximum; if (IPcheck_nr(cptr) > maxclones) { - ddb = ddb_find_key(DDB_CONFIGDB, DDB_CONFIGDB_MSG_TOO_MANY_FROM_IP); - sendcmdto_one(&me, CMD_NOTICE, cptr, "%C :In the %s IRC Network only allows %d clones for your IP (%s)%s%s", cptr, feature_str(FEAT_NETWORK), maxclones, ircd_ntoa(&cli_ip(cptr)), - ddb ? ". " : "", ddb ? ddb_content(ddb) : ""); + msg_many_clones ? ". " : "", msg_many_clones ? msg_many_clones : ""); return ACR_TOO_MANY_FROM_IP; } #else Index: ircd-ircdev/ircd/s_user.c diff -u ircd-ircdev/ircd/s_user.c:1.22 ircd-ircdev/ircd/s_user.c:1.23 --- ircd-ircdev/ircd/s_user.c:1.22 Wed Jun 22 02:58:52 2005 +++ ircd-ircdev/ircd/s_user.c Sun Jul 3 11:44:52 2005 @@ -21,7 +21,7 @@ */ /** @file * @brief Miscellaneous user-related helper functions. - * @version $Id: s_user.c,v 1.22 2005/06/22 09:58:52 zolty Exp $ + * @version $Id: s_user.c,v 1.23 2005/07/03 18:44:52 zolty Exp $ */ #include "config.h" @@ -1165,10 +1165,8 @@ } } if (ddbv) - { - ircd_snprintf(0, cli_user(sptr)->host, HOSTLEN, ddb_content(ddbv)); - hide_hostmask(sptr, FLAG_HIDDENHOST); - } + hide_hostmask(sptr, ddb_content(ddbv), FLAG_HIDDENHOST); + #endif /* defined(DDB) */ /* Notify change nick local/remote user */ @@ -1406,11 +1404,12 @@ /** Set \a flag on \a cptr and possibly hide the client's hostmask. * @param[in,out] cptr User who is getting a new flag. + * @param[in] vhost Vhost of the user. * @param[in] flag Some flag that affects host-hiding (FLAG_HIDDENHOST, FLAG_ACCOUNT). * @return Zero. */ int -hide_hostmask(struct Client *cptr, unsigned int flag) +hide_hostmask(struct Client *cptr, const char *vhost, unsigned int flag) { struct Membership *chan; @@ -1443,7 +1442,8 @@ #if defined(UNDERNET) if (!HasFlag(cptr, FLAG_HIDDENHOST) || !HasFlag(cptr, FLAG_ACCOUNT)) #elsif defined(DDB) || defined(SERVICES) - if (!HasFlag(cptr, FLAG_HIDDENHOST) || !HasFlag(cptr, FLAG_NICKREG)) + /* if (!HasFlag(cptr, FLAG_HIDDENHOST) || !HasFlag(cptr, FLAG_NICKREG)) */ + if (1 == 0) #else if (!HasFlag(cptr, FLAG_HIDDENHOST)) #endif @@ -1459,6 +1459,53 @@ # endif #else sendcmdto_common_channels_butone(cptr, CMD_QUIT, cptr, ":Changing virtualhost"); + if (!vhost) + { + char ipcrypted[HOSTLEN + 1]; + + if (!ip_crypt_key) + { + strncpy(ipcrypted, "No.there.is.a.crypt.key", HOSTLEN); + } + /* IPv4 */ + else if (irc_in_addr_is_ipv4(&cli_ip(cptr))) + { + unsigned int v[2], x[2]; + unsigned int ts = 0; + + do { + x[0] = x[1] = 0; + v[0] = (binary_ip_crypt_key[0] & 0xffff0000) + ts; + v[1] = (ntohl(cli_ip(cptr).in6_16[6]) << 16) | ntohl(cli_ip(cptr).in6_16[7]); + + ircd_tea(v, binary_ip_crypt_key, x); + + /* Virtualhost format: qWeRty.AsDfGh.v4 */ + inttobase64(ipcrypted, x[0], 6); + ipcrypted[6] = '.'; + inttobase64(ipcrypted + 7, x[1], 6); + strncpy(ipcrypted + 13, ".v4", HOSTLEN); + log_write(LS_SYSTEM, L_CRIT, 0, "%u - %u", x[0], x[1]); + + /* No debería ocurrir nunca... */ + if (++ts == 65535) + { + strncpy(ipcrypted, cli_user(cptr)->realhost, HOSTLEN); + strncat(ipcrypted, ".v4", HOSTLEN); + break; + } + } while (strchr(ipcrypted, ']') || strchr(ipcrypted, '[')); + } + /* IPv6 */ + else + { + strncpy(ipcrypted, cli_user(cptr)->realhost, HOSTLEN); + strncat(ipcrypted, ".v6", HOSTLEN); + } + ircd_snprintf(0, cli_user(cptr)->host, HOSTLEN, ipcrypted); + } + else + ircd_snprintf(0, cli_user(cptr)->host, HOSTLEN, vhost); #endif /* ok, the client is now fully hidden, so let them know -- hikari */ @@ -1480,19 +1527,25 @@ #if defined(DDB) || defined(SERVICES) if (IsChanOwner(chan) || IsChanOp(chan) || HasVoice(chan)) + /* TODO-zoltan: Optimizar esto */ sendcmdto_channel_butserv_butone(&me, CMD_MODE, chan->channel, cptr, 0, - "%H +%s%s%s %C %C", chan->channel, cptr, + "%H +%s%s%s %s%s%s%s%s", chan->channel, IsChanOwner(chan) ? "q" : "", IsChanOp(chan) ? "o" : "", HasVoice(chan) ? "v" : "", - cptr); + IsChanOwner(chan) ? cli_name(cptr) : "", + IsChanOwner(chan) ? " " : "", + IsChanOp(chan) ? cli_name(cptr) : "", + IsChanOp(chan) ? " " : "", + HasVoice(chan) ? cli_name(cptr) : ""); #else - if (IsChanOp(chan) || HasVoice(chan)) + if (IsChanOp(chan) && HasVoice(chan)) sendcmdto_channel_butserv_butone(&me, CMD_MODE, chan->channel, cptr, 0, - "%H +%s%s %C %C", chan->channel, cptr, - IsChanOp(chan) ? "o" : "", - HasVoice(chan) ? "v" : "", + "%H +ov %C %C", chan->channel, cptr, cptr); + else if (IsChanOp(chan) || HasVoice(chan)) + sendcmdto_channel_butserv_butone(&me, CMD_MODE, chan->channel, cptr, 0, + "%H +%c %C", chan->channel, IsChanOp(chan) ? 'o' : 'v', cptr); #endif } return 0; @@ -1768,7 +1821,7 @@ if (!FlagHas(&setflags, FLAG_INVISIBLE) && IsInvisible(sptr)) ++UserStats.inv_clients; if (!FlagHas(&setflags, FLAG_HIDDENHOST) && do_host_hiding) - hide_hostmask(sptr, FLAG_HIDDENHOST); + hide_hostmask(sptr, 0, FLAG_HIDDENHOST); /* TODO-ZOLTAN */ send_umode_out(cptr, sptr, &setflags, prop); return 0; ----------------------- End of diff ----------------------- |