Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff -Npru ircu2.10.12.13-rc2/doc/example.conf ircu2.10.12.13-rc2-fakehost/doc/example.conf
- --- ircu2.10.12.13-rc2/doc/example.conf 2007-11-04 21:01:34.000000000 -0600
- +++ ircu2.10.12.13-rc2-fakehost/doc/example.conf 2010-05-16 16:54:03.000000000 -0500
- @@ -228,10 +228,11 @@ Class {
- # badchan (can issue Gchans to other servers)
- # force_opmode (can use OPMODE/CLEARMODE on quarantined global channels)
- # apass_opmode (can use OPMODE/CLEARMODE on +A and +U keys)
- + # set_fakehost (can set own fakehost with /fake)
- #
- # For global opers (with propagate = yes or local = no), the default
- # is to grant all of the above privileges EXCEPT walk_lchan,
- - # unlimit_query, set, badchan, local_badchan and apass_opmode.
- + # unlimit_query, set, badchan, local_badchan, apass_opmode, and set_fakehost.
- # For local opers, the default is to grant ONLY the following
- # privileges:
- # chan_limit, mode_lchan, show_invis, show_all_invis, local_kill,
- diff -Npru ircu2.10.12.13-rc2/include/class.h ircu2.10.12.13-rc2-fakehost/include/class.h
- --- ircu2.10.12.13-rc2/include/class.h 2005-10-04 20:53:30.000000000 -0500
- +++ ircu2.10.12.13-rc2-fakehost/include/class.h 2010-05-16 16:55:43.000000000 -0500
- @@ -42,6 +42,8 @@ struct ConnectionClass {
- char *cc_name; /**< Name of connection class. */
- char *default_umode; /**< Default usermode for users
- in this class. */
- + char *default_fakehost; /**< Default fakehost for users
- + in this class */
- struct Privs privs; /**< Privilege bits that are set on
- or off. */
- struct Privs privs_dirty; /**< Indication of which bits in
- @@ -86,6 +88,8 @@ struct ConnectionClass {
- #define ConfLinks(x) ((x)->conn_class->ref_count)
- /** Get default usermode for ConfItem \a x. */
- #define ConfUmode(x) ((x)->conn_class->default_umode)
- +/** Get default fakehost for ConfItem \a x. */
- +#define ConfFakehost(x) ((x)->conn_class->default_fakehost)
- /** Find a valid configuration class by name. */
- #define find_class(name) do_find_class((name), 0)
- diff -Npru ircu2.10.12.13-rc2/include/client.h ircu2.10.12.13-rc2-fakehost/include/client.h
- --- ircu2.10.12.13-rc2/include/client.h 2009-02-08 22:11:04.000000000 -0600
- +++ ircu2.10.12.13-rc2-fakehost/include/client.h 2010-05-16 16:58:45.000000000 -0500
- @@ -126,6 +126,7 @@ enum Priv
- PRIV_FORCE_OPMODE, /**< can hack modes on quarantined channels */
- PRIV_FORCE_LOCAL_OPMODE, /**< can hack modes on quarantined local channels */
- PRIV_APASS_OPMODE, /**< can hack modes +A/-A/+U/-U */
- + PRIV_SET_FAKEHOST, /**< can set own fakehost with /fake */
- PRIV_LAST_PRIV /**< number of privileges */
- };
- @@ -166,6 +167,7 @@ enum Flag
- FLAG_DEBUG, /**< send global debug/anti-hack info */
- FLAG_ACCOUNT, /**< account name has been set */
- FLAG_HIDDENHOST, /**< user's host is hidden */
- + FLAG_FAKEHOST, /**< user has been assigned a fake host */
- FLAG_LAST_FLAG, /**< number of flags */
- FLAG_LOCAL_UMODES = FLAG_LOCOP, /**< First local mode flag */
- FLAG_GLOBAL_UMODES = FLAG_OPER /**< First global mode flag */
- @@ -585,7 +587,9 @@ struct Client {
- /** Return non-zero if the client has operator or server privileges. */
- #define IsPrivileged(x) (IsAnOper(x) || IsServer(x))
- /** Return non-zero if the client's host is hidden. */
- -#define HasHiddenHost(x) (IsHiddenHost(x) && IsAccount(x))
- +#define HasHiddenHost(x) (IsHiddenHost(x) && (IsAccount(x) || HasFakeHost(x)))
- +/** Return non-zero if the client has a fake host set. */
- +#define HasFakeHost(x) HasFlag(x, FLAG_FAKEHOST)
- /** Mark a client as having an in-progress net.burst. */
- #define SetBurst(x) SetFlag(x, FLAG_BURST)
- @@ -625,6 +629,8 @@ struct Client {
- #define SetAccount(x) SetFlag(x, FLAG_ACCOUNT)
- /** Mark a client as having mode +x (hidden host). */
- #define SetHiddenHost(x) SetFlag(x, FLAG_HIDDENHOST)
- +/** Mark a client as having a fake host. */
- +#define SetFakeHost(x) SetFlag(x, FLAG_FAKEHOST)
- /** Mark a client as having a pending PING. */
- #define SetPingSent(x) SetFlag(x, FLAG_PINGSENT)
- @@ -658,6 +664,8 @@ struct Client {
- #define ClearServNotice(x) ClrFlag(x, FLAG_SERVNOTICE)
- /** Remove mode +x (hidden host) from the client. */
- #define ClearHiddenHost(x) ClrFlag(x, FLAG_HIDDENHOST)
- +/** Clear the client's fake host flag. */
- +#define ClearFakeHost(x) ClrFlag(x, FLAG_FAKEHOST)
- /** Clear the client's pending PING flag. */
- #define ClearPingSent(x) ClrFlag(x, FLAG_PINGSENT)
- /** Clear the client's HUB flag. */
- @@ -729,6 +737,7 @@ struct Client {
- extern const char* get_client_name(const struct Client* sptr, int showip);
- extern const char* client_get_default_umode(const struct Client* sptr);
- +extern const char* client_get_default_fakehost(const struct Client* sptr);
- extern int client_get_ping(const struct Client* local_client);
- extern void client_drop_sendq(struct Connection* con);
- extern void client_add_sendq(struct Connection* con,
- diff -Npru ircu2.10.12.13-rc2/include/handlers.h ircu2.10.12.13-rc2-fakehost/include/handlers.h
- --- ircu2.10.12.13-rc2/include/handlers.h 2010-01-02 14:33:10.000000000 -0600
- +++ ircu2.10.12.13-rc2-fakehost/include/handlers.h 2010-05-16 16:59:54.000000000 -0500
- @@ -91,6 +91,7 @@ extern int m_away(struct Client*, struct
- extern int m_cap(struct Client*, struct Client*, int, char*[]);
- extern int m_cnotice(struct Client*, struct Client*, int, char*[]);
- extern int m_cprivmsg(struct Client*, struct Client*, int, char*[]);
- +extern int m_fakehost(struct Client*, struct Client*, int, char*[]);
- extern int m_gline(struct Client*, struct Client*, int, char*[]);
- extern int m_help(struct Client*, struct Client*, int, char*[]);
- extern int m_ignore(struct Client*, struct Client*, int, char*[]);
- @@ -188,6 +189,7 @@ extern int ms_desynch(struct Client*, st
- extern int ms_end_of_burst(struct Client*, struct Client*, int, char*[]);
- extern int ms_end_of_burst_ack(struct Client*, struct Client*, int, char*[]);
- extern int ms_error(struct Client*, struct Client*, int, char*[]);
- +extern int ms_fakehost(struct Client*, struct Client*, int, char*[]);
- extern int ms_gline(struct Client*, struct Client*, int, char*[]);
- extern int ms_info(struct Client*, struct Client*, int, char*[]);
- extern int ms_invite(struct Client*, struct Client*, int, char*[]);
- diff -Npru ircu2.10.12.13-rc2/include/msg.h ircu2.10.12.13-rc2-fakehost/include/msg.h
- --- ircu2.10.12.13-rc2/include/msg.h 2010-01-02 14:33:10.000000000 -0600
- +++ ircu2.10.12.13-rc2-fakehost/include/msg.h 2010-05-16 17:01:22.000000000 -0500
- @@ -340,6 +340,10 @@ struct Client;
- #define TOK_ASLL "LL"
- #define CMD_ASLL MSG_ASLL, TOK_ASLL
- +#define MSG_FAKEHOST "FAKE" /* FAKE */
- +#define TOK_FAKEHOST "FA"
- +#define CMD_FAKEHOST MSG_FAKEHOST, TOK_FAKEHOST
- +
- #define MSG_POST "POST" /* POST */
- #define TOK_POST "POST"
- diff -Npru ircu2.10.12.13-rc2/include/s_user.h ircu2.10.12.13-rc2-fakehost/include/s_user.h
- --- ircu2.10.12.13-rc2/include/s_user.h 2007-07-13 21:40:01.000000000 -0500
- +++ ircu2.10.12.13-rc2-fakehost/include/s_user.h 2010-05-16 17:06:49.000000000 -0500
- @@ -79,7 +79,8 @@ extern int whisper(struct Client* source
- 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 void make_hidden_hostmask(char *buffer, struct Client *cptr);
- +extern int hide_hostmask(struct Client *cptr);
- extern int set_user_mode(struct Client *cptr, struct Client *sptr,
- int parc, char *parv[], int allow_modes);
- extern int is_silenced(struct Client *sptr, struct Client *acptr);
- diff -Npru ircu2.10.12.13-rc2/include/struct.h ircu2.10.12.13-rc2-fakehost/include/struct.h
- --- ircu2.10.12.13-rc2/include/struct.h 2007-01-14 21:08:23.000000000 -0600
- +++ ircu2.10.12.13-rc2-fakehost/include/struct.h 2010-05-16 17:07:12.000000000 -0500
- @@ -82,6 +82,7 @@ struct User {
- char username[USERLEN + 1];
- char host[HOSTLEN + 1]; /**< displayed hostname */
- char realhost[HOSTLEN + 1]; /**< actual hostname */
- + char fakehost[HOSTLEN + 1]; /**< fake hostname */
- char account[ACCOUNTLEN + 1]; /**< IRC account name */
- time_t acc_create; /**< IRC account timestamp */
- };
- diff -Npru ircu2.10.12.13-rc2/ircd/Makefile.in ircu2.10.12.13-rc2-fakehost/ircd/Makefile.in
- --- ircu2.10.12.13-rc2/ircd/Makefile.in 2010-01-04 11:15:13.000000000 -0600
- +++ ircu2.10.12.13-rc2-fakehost/ircd/Makefile.in 2010-05-16 17:08:37.000000000 -0500
- @@ -130,6 +130,7 @@ IRCD_SRC = \
- m_die.c \
- m_endburst.c \
- m_error.c \
- + m_fakehost.c \
- m_get.c \
- m_gline.c \
- m_help.c \
- @@ -591,6 +592,13 @@ m_asll.o: m_asll.c ../config.h ../includ
- ../include/ircd_string.h ../include/ircd_chattr.h ../include/numeric.h \
- ../include/numnicks.h ../include/match.h ../include/msg.h \
- ../include/send.h ../include/s_bsd.h ../include/s_user.h
- +m_fakehost.o: m_fakehost.c ../config.h ../include/client.h \
- + ../include/ircd_defs.h ../include/dbuf.h ../include/msgq.h \
- + ../include/ircd_events.h ../include/ircd_handler.h ../include/hash.h \
- + ../include/ircd.h ../include/struct.h ../include/ircd_reply.h \
- + ../include/ircd_string.h ../include/ircd_chattr.h ../include/msg.h \
- + ../include/numeric.h ../include/numnicks.h ../include/s_conf.h \
- + ../include/s_user.h ../include/send.h
- m_away.o: m_away.c ../config.h ../include/client.h ../include/ircd_defs.h \
- ../include/dbuf.h ../include/msgq.h ../include/ircd_events.h \
- ../config.h ../include/ircd_handler.h ../include/res.h \
- diff -Npru ircu2.10.12.13-rc2/ircd/channel.c ircu2.10.12.13-rc2-fakehost/ircd/channel.c
- --- ircu2.10.12.13-rc2/ircd/channel.c 2010-01-03 15:04:54.000000000 -0600
- +++ ircu2.10.12.13-rc2-fakehost/ircd/channel.c 2010-05-16 17:11:10.000000000 -0500
- @@ -374,17 +374,26 @@ struct Ban *find_ban(struct Client *cptr
- char tmphost[HOSTLEN + 1];
- char iphost[SOCKIPLEN + 1];
- char *hostmask;
- - char *sr;
- + char *sr, *sr2;
- struct Ban *found;
- /* Build nick!user and alternate host names. */
- ircd_snprintf(0, nu, sizeof(nu), "%s!%s",
- cli_name(cptr), cli_user(cptr)->username);
- ircd_ntoa_r(iphost, &cli_ip(cptr));
- + sr2 = NULL;
- if (!IsAccount(cptr))
- sr = NULL;
- else if (HasHiddenHost(cptr))
- + {
- sr = cli_user(cptr)->realhost;
- + if (HasFakeHost(cptr))
- + {
- + ircd_snprintf(0, tmphost, HOSTLEN, "%s.%s",
- + cli_user(cptr)->account, feature_str(FEAT_HIDDEN_HOST));
- + sr2 = tmphost;
- + }
- + }
- else
- {
- ircd_snprintf(0, tmphost, HOSTLEN, "%s.%s",
- @@ -409,7 +418,8 @@ struct Ban *find_ban(struct Client *cptr
- if (!((banlist->flags & BAN_IPMASK)
- && ipmask_check(&cli_ip(cptr), &banlist->address, banlist->addrbits))
- && match(hostmask, cli_user(cptr)->host)
- - && !(sr && !match(hostmask, sr)))
- + && !(sr && !match(hostmask, sr))
- + && !(sr2 && !match(hostmask, sr2)))
- continue;
- /* If an exception matches, no ban can match. */
- if (banlist->flags & BAN_EXCEPTION)
- diff -Npru ircu2.10.12.13-rc2/ircd/client.c ircu2.10.12.13-rc2-fakehost/ircd/client.c
- --- ircu2.10.12.13-rc2/ircd/client.c 2005-10-12 18:52:12.000000000 -0500
- +++ ircu2.10.12.13-rc2-fakehost/ircd/client.c 2010-05-16 17:13:27.000000000 -0500
- @@ -88,6 +88,26 @@ const char* client_get_default_umode(con
- return NULL;
- }
- +/*
- + * client_get_default_fakehost
- + * returns default fakehost in attached client connection class
- + */
- +const char* client_get_default_fakehost(const struct Client* sptr)
- +{
- + struct ConfItem* aconf;
- + struct SLink* link;
- +
- + assert(cli_verify(sptr));
- +
- + for (link = cli_confs(sptr); link; link = link->next) {
- + aconf = link->value.aconf;
- + if ((aconf->status & CONF_CLIENT) && ConfFakehost(aconf))
- + return ConfFakehost(aconf);
- + }
- +
- + return NULL;
- +}
- +
- /** Remove a connection from the list of connections with queued data.
- * @param[in] con Connection with no queued data.
- */
- @@ -158,6 +178,7 @@ client_set_privs(struct Client *client,
- FlagClr(&privs_global, PRIV_BADCHAN);
- FlagClr(&privs_global, PRIV_LOCAL_BADCHAN);
- FlagClr(&privs_global, PRIV_APASS_OPMODE);
- + FlagClr(&privs_global, PRIV_SET_FAKEHOST);
- memset(&privs_local, 0, sizeof(privs_local));
- FlagSet(&privs_local, PRIV_CHAN_LIMIT);
- @@ -235,7 +256,7 @@ static struct {
- P(OPMODE), P(LOCAL_OPMODE), P(SET), P(WHOX),
- P(BADCHAN), P(LOCAL_BADCHAN), P(SEE_CHAN), P(PROPAGATE),
- P(DISPLAY), P(SEE_OPERS), P(WIDE_GLINE), P(LIST_CHAN),
- - P(FORCE_OPMODE), P(FORCE_LOCAL_OPMODE), P(APASS_OPMODE),
- + P(FORCE_OPMODE), P(FORCE_LOCAL_OPMODE), P(APASS_OPMODE), P(SET_FAKEHOST),
- #undef P
- { 0, 0 }
- };
- diff -Npru ircu2.10.12.13-rc2/ircd/ircd_lexer.l ircu2.10.12.13-rc2-fakehost/ircd/ircd_lexer.l
- --- ircu2.10.12.13-rc2/ircd/ircd_lexer.l 2007-11-30 16:10:04.000000000 -0600
- +++ ircu2.10.12.13-rc2-fakehost/ircd/ircd_lexer.l 2010-05-16 17:14:04.000000000 -0500
- @@ -101,6 +101,7 @@ static struct lexer_token {
- TOKEN(PSEUDO),
- TOKEN(PREPEND),
- TOKEN(USERMODE),
- + TOKEN(FAKEHOST),
- TOKEN(FAST),
- TOKEN(AUTOCONNECT),
- TOKEN(PROGRAM),
- @@ -144,6 +145,7 @@ static struct lexer_token {
- { "see_chan", TPRIV_SEE_CHAN },
- { "see_opers", TPRIV_SEE_OPERS },
- { "set", TPRIV_SET },
- + { "set_fakehost", TPRIV_SET_FAKEHOST },
- { "show_all_invis", TPRIV_SHOW_ALL_INVIS },
- { "show_invis", TPRIV_SHOW_INVIS },
- { "tb", TBYTES },
- diff -Npru ircu2.10.12.13-rc2/ircd/ircd_parser.y ircu2.10.12.13-rc2-fakehost/ircd/ircd_parser.y
- --- ircu2.10.12.13-rc2/ircd/ircd_parser.y 2009-02-08 22:11:04.000000000 -0600
- +++ ircu2.10.12.13-rc2-fakehost/ircd/ircd_parser.y 2010-05-16 17:17:39.000000000 -0500
- @@ -168,6 +168,7 @@ static void free_slist(struct SLink **li
- %token PSEUDO
- %token PREPEND
- %token USERMODE
- +%token FAKEHOST
- %token IAUTH
- %token TIMEOUT
- %token FAST
- @@ -182,7 +183,7 @@ static void free_slist(struct SLink **li
- %token TPRIV_LOCAL_OPMODE TPRIV_OPMODE TPRIV_SET TPRIV_WHOX TPRIV_BADCHAN
- %token TPRIV_SEE_CHAN TPRIV_SHOW_INVIS TPRIV_SHOW_ALL_INVIS TPRIV_PROPAGATE
- %token TPRIV_UNLIMIT_QUERY TPRIV_DISPLAY TPRIV_SEE_OPERS TPRIV_WIDE_GLINE
- -%token TPRIV_FORCE_OPMODE TPRIV_FORCE_LOCAL_OPMODE TPRIV_APASS_OPMODE
- +%token TPRIV_FORCE_OPMODE TPRIV_FORCE_LOCAL_OPMODE TPRIV_APASS_OPMODE TPRIV_SET_FAKEHOST
- %token TPRIV_LIST_CHAN
- /* and some types... */
- %type <num> sizespec
- @@ -417,6 +418,7 @@ classblock: CLASS {
- c_class = find_class(name);
- MyFree(c_class->default_umode);
- c_class->default_umode = pass;
- + c_class->default_fakehost = host;
- memcpy(&c_class->privs, &privs, sizeof(c_class->privs));
- memcpy(&c_class->privs_dirty, &privs_dirty, sizeof(c_class->privs_dirty));
- }
- @@ -425,6 +427,7 @@ classblock: CLASS {
- }
- name = NULL;
- pass = NULL;
- + host = NULL;
- tconn = 0;
- maxlinks = 0;
- sendq = 0;
- @@ -433,7 +436,7 @@ classblock: CLASS {
- };
- classitems: classitem classitems | classitem;
- classitem: classname | classpingfreq | classconnfreq | classmaxlinks |
- - classsendq | classusermode | priv;
- + classsendq | classusermode | classfakehost | priv;
- classname: NAME '=' QSTRING ';'
- {
- MyFree(name);
- @@ -460,6 +463,12 @@ classusermode: USERMODE '=' QSTRING ';'
- MyFree(pass);
- pass = $3;
- };
- +classfakehost: FAKEHOST '=' QSTRING ';'
- +{
- + if (host)
- + MyFree(host);
- + DupString(host, yylval.text);
- +};
- connectblock: CONNECT
- {
- @@ -681,7 +690,8 @@ privtype: TPRIV_CHAN_LIMIT { $$ = PRIV_C
- LOCAL { $$ = PRIV_PROPAGATE; invert = 1; } |
- TPRIV_FORCE_OPMODE { $$ = PRIV_FORCE_OPMODE; } |
- TPRIV_FORCE_LOCAL_OPMODE { $$ = PRIV_FORCE_LOCAL_OPMODE; } |
- - TPRIV_APASS_OPMODE { $$ = PRIV_APASS_OPMODE; } ;
- + TPRIV_APASS_OPMODE { $$ = PRIV_APASS_OPMODE; } |
- + TPRIV_SET_FAKEHOST { $$ = PRIV_SET_FAKEHOST; } ;
- yesorno: YES { $$ = 1; } | NO { $$ = 0; };
- diff -Npru ircu2.10.12.13-rc2/ircd/m_account.c ircu2.10.12.13-rc2-fakehost/ircd/m_account.c
- --- ircu2.10.12.13-rc2/ircd/m_account.c 2004-12-10 23:14:07.000000000 -0600
- +++ ircu2.10.12.13-rc2-fakehost/ircd/m_account.c 2010-05-16 17:18:41.000000000 -0500
- @@ -106,6 +106,7 @@ int ms_account(struct Client* cptr, stru
- char* parv[])
- {
- struct Client *acptr;
- + int hidden;
- if (parc < 3)
- return need_more_params(sptr, "ACCOUNT");
- @@ -135,9 +136,12 @@ int ms_account(struct Client* cptr, stru
- Debug((DEBUG_DEBUG, "Received timestamped account: account \"%s\", "
- "timestamp %Tu", parv[2], cli_user(acptr)->acc_create));
- }
- -
- +
- + hidden = HasHiddenHost(acptr);
- + SetAccount(acptr);
- ircd_strncpy(cli_user(acptr)->account, parv[2], ACCOUNTLEN);
- - hide_hostmask(acptr, FLAG_ACCOUNT);
- + if (!hidden)
- + hide_hostmask(acptr);
- sendcmdto_serv_butone(sptr, CMD_ACCOUNT, cptr,
- cli_user(acptr)->acc_create ? "%C %s %Tu" : "%C %s",
- diff -Npru ircu2.10.12.13-rc2/ircd/m_fakehost.c ircu2.10.12.13-rc2-fakehost/ircd/m_fakehost.c
- --- ircu2.10.12.13-rc2/ircd/m_fakehost.c 1969-12-31 18:00:00.000000000 -0600
- +++ ircu2.10.12.13-rc2-fakehost/ircd/m_fakehost.c 2010-05-16 17:20:02.000000000 -0500
- @@ -0,0 +1,160 @@
- +/*
- + * IRC - Internet Relay Chat, ircd/m_fakehost.c
- + * Copyright (C) 2004 Zoot <zoot@gamesurge.net>
- + *
- + * 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.
- + *
- + * $Id$
- + */
- +
- +/*
- + * 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.
- + */
- +#include "config.h"
- +
- +#include "client.h"
- +#include "hash.h"
- +#include "ircd.h"
- +#include "ircd_reply.h"
- +#include "ircd_string.h"
- +#include "msg.h"
- +#include "numeric.h"
- +#include "numnicks.h"
- +#include "s_conf.h"
- +#include "s_user.h"
- +#include "send.h"
- +#include <assert.h>
- +
- +/*
- + * m_fakehost - fakehost user message handler
- + *
- + * parv[0] = sender prefix
- + * parv[1] = new fake host
- + */
- +int m_fakehost(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
- +{
- + if (!HasPriv(sptr, PRIV_SET_FAKEHOST))
- + return send_reply(sptr, ERR_NOPRIVILEGES);
- +
- + if (parc < 2)
- + return need_more_params(sptr, "FAKEHOST");
- +
- + /* Ignore the assignment if it changes nothing */
- + if (HasFakeHost(cptr) &&
- + ircd_strcmp(cli_user(cptr)->fakehost, parv[1]) == 0)
- + {
- + return 0;
- + }
- +
- + /* Assign and propagate the fakehost */
- + SetFakeHost(cptr);
- + ircd_strncpy(cli_user(cptr)->fakehost, parv[1], HOSTLEN);
- + hide_hostmask(cptr);
- +
- + sendcmdto_serv_butone(sptr, CMD_FAKEHOST, cptr, "%C %s", sptr,
- + cli_user(cptr)->fakehost);
- + return 0;
- +}
- +
- +/*
- + * ms_fakehost - fakehost server message handler
- + *
- + * parv[0] = sender prefix
- + * parv[1] = target user numeric
- + * parv[2] = target user's new fake host
- + */
- +int ms_fakehost(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
- +{
- + struct Client *target;
- +
- + if (parc < 3)
- + return need_more_params(sptr, "FAKEHOST");
- +
- + /* Locate our target user; ignore the message if we can't */
- + if(!(target = findNUser(parv[1])))
- + return 0;
- +
- + /* Ignore the assignment if it changes nothing */
- + if (HasFakeHost(target) &&
- + ircd_strcmp(cli_user(target)->fakehost, parv[2]) == 0)
- + {
- + return 0;
- + }
- +
- + /* Assign and propagate the fakehost */
- + SetFakeHost(target);
- + ircd_strncpy(cli_user(target)->fakehost, parv[2], HOSTLEN);
- + hide_hostmask(target);
- +
- + sendcmdto_serv_butone(sptr, CMD_FAKEHOST, cptr, "%C %s", target,
- + cli_user(target)->fakehost);
- + return 0;
- +}
- diff -Npru ircu2.10.12.13-rc2/ircd/parse.c ircu2.10.12.13-rc2-fakehost/ircd/parse.c
- --- ircu2.10.12.13-rc2/ircd/parse.c 2010-01-02 14:33:10.000000000 -0600
- +++ ircu2.10.12.13-rc2-fakehost/ircd/parse.c 2010-05-16 17:23:42.000000000 -0500
- @@ -640,6 +640,13 @@ struct Message msgtab[] = {
- { m_cap, m_cap, m_ignore, m_cap, m_ignore }
- },
- #endif
- + {
- + MSG_FAKEHOST,
- + TOK_FAKEHOST,
- + 0, MAXPARA, MFLG_SLOW, 0, NULL,
- + /* UNREG, CLIENT, SERVER, OPER, SERVICE */
- + { m_ignore, m_not_oper, ms_fakehost, m_fakehost, m_ignore }
- + },
- /* This command is an alias for QUIT during the unregistered part of
- * of the server. This is because someone jumping via a broken web
- * proxy will send a 'POST' as their first command - which we will
- diff -Npru ircu2.10.12.13-rc2/ircd/s_auth.c ircu2.10.12.13-rc2-fakehost/ircd/s_auth.c
- --- ircu2.10.12.13-rc2/ircd/s_auth.c 2010-01-04 11:15:13.000000000 -0600
- +++ ircu2.10.12.13-rc2-fakehost/ircd/s_auth.c 2010-05-16 17:25:27.000000000 -0500
- @@ -366,6 +366,7 @@ static int check_auth_finished(struct Au
- {
- enum AuthRequestFlag flag;
- int res;
- + const char *fakehost;
- /* Check non-iauth registration blocking flags. */
- for (flag = 0; flag <= AR_LAST_SCAN; ++flag)
- @@ -382,6 +383,14 @@ static int check_auth_finished(struct Au
- && preregister_user(auth->client))
- return CPTR_KILLED;
- + /* Set fakehost if client's connection class has a default fakehost. */
- + fakehost = client_get_default_fakehost(auth->client);
- + if (fakehost)
- + {
- + ircd_strncpy(cli_user(auth->client)->fakehost, fakehost, HOSTLEN);
- + SetFakeHost(auth->client);
- + }
- +
- /* If we have not done so, check client password. Do this as soon
- * as possible so that iauth's challenge/response (which uses PASS
- * for responses) is not confused with the client's password.
- diff -Npru ircu2.10.12.13-rc2/ircd/s_user.c ircu2.10.12.13-rc2-fakehost/ircd/s_user.c
- --- ircu2.10.12.13-rc2/ircd/s_user.c 2009-07-30 21:04:15.000000000 -0500
- +++ ircu2.10.12.13-rc2-fakehost/ircd/s_user.c 2010-05-16 21:47:59.000000000 -0500
- @@ -340,10 +340,12 @@ int hunt_server_prio_cmd(struct Client *
- */
- int register_user(struct Client *cptr, struct Client *sptr)
- {
- + const char* fakehost;
- char* parv[4];
- char* tmpstr;
- struct User* user = cli_user(sptr);
- char ip_base64[25];
- + struct Flags setflags;
- user->last = CurrentTime;
- parv[0] = cli_name(sptr);
- @@ -358,6 +360,7 @@ int register_user(struct Client *cptr, s
- /*
- * Set user's initial modes
- */
- + setflags = cli_flags(sptr);
- tmpstr = (char*)client_get_default_umode(sptr);
- if (tmpstr) {
- char *umodev[] = { NULL, NULL, NULL, NULL };
- @@ -438,7 +441,7 @@ int register_user(struct Client *cptr, s
- * account assignment causes a numeric reply during registration.
- */
- if (HasHiddenHost(sptr))
- - hide_hostmask(sptr, FLAG_HIDDENHOST);
- + hide_hostmask(sptr);
- if (IsInvisible(sptr))
- ++UserStats.inv_clients;
- if (IsOper(sptr))
- @@ -499,7 +502,8 @@ static const struct UserMode {
- { FLAG_CHSERV, 'k' },
- { FLAG_DEBUG, 'g' },
- { FLAG_ACCOUNT, 'r' },
- - { FLAG_HIDDENHOST, 'x' }
- + { FLAG_HIDDENHOST, 'x' },
- + { FLAG_FAKEHOST, 'f' }
- };
- /** Length of #userModeList. */
- @@ -871,39 +875,52 @@ void send_user_info(struct Client* sptr,
- msgq_clean(mb);
- }
- +/*
- + * make_hidden_hostmask()
- + * Generates a user's hidden hostmask based on their account unless
- + * they have a custom [vanity] host set. This function expects a
- + * buffer of sufficient size to hold the resulting hostmask.
- + */
- +void make_hidden_hostmask(char *buffer, struct Client *cptr)
- +{
- + assert(HasFakeHost(cptr) || IsAccount(cptr));
- +
- + if (HasFakeHost(cptr)) {
- + /* The user has a fake host; make that their hidden hostmask. */
- + ircd_strncpy(buffer, cli_user(cptr)->fakehost, HOSTLEN);
- + return;
- + }
- +
- + if (IsAccount(cptr)) {
- + /* Generate a hidden host based on the user's account name. */
- + ircd_snprintf(0, buffer, HOSTLEN, "%s.%s", cli_user(cptr)->account,
- + feature_str(FEAT_HIDDEN_HOST));
- + return;
- + }
- +}
- +
- /** 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] 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)
- {
- struct Membership *chan;
- - switch (flag) {
- - case FLAG_HIDDENHOST:
- - /* Local users cannot set +x unless FEAT_HOST_HIDING is true. */
- - if (MyConnect(cptr) && !feature_bool(FEAT_HOST_HIDING))
- - return 0;
- - break;
- - case FLAG_ACCOUNT:
- - /* Invalidate all bans against the user so we check them again */
- - for (chan = (cli_user(cptr))->channel; chan;
- - chan = chan->next_channel)
- - ClearBanValid(chan);
- - break;
- - default:
- + if (MyConnect(cptr) && !feature_bool(FEAT_HOST_HIDING))
- return 0;
- - }
- - SetFlag(cptr, flag);
- - if (!HasFlag(cptr, FLAG_HIDDENHOST) || !HasFlag(cptr, FLAG_ACCOUNT))
- + if (!HasHiddenHost(cptr))
- return 0;
- +
- + /* Invalidate all bans against the user so we can them again */
- + for (chan = (cli_user(cptr))->channel; chan; chan = chan->next_channel)
- + ClearBanValid(chan);
- sendcmdto_common_channels_butone(cptr, CMD_QUIT, cptr, ":Registered");
- - ircd_snprintf(0, cli_user(cptr)->host, HOSTLEN, "%s.%s",
- - cli_user(cptr)->account, feature_str(FEAT_HIDDEN_HOST));
- + make_hidden_hostmask(cli_user(cptr)->host, cptr);
- /* ok, the client is now fully hidden, so let them know -- hikari */
- if (MyConnect(cptr))
- @@ -917,8 +934,10 @@ hide_hostmask(struct Client *cptr, unsig
- {
- if (IsZombie(chan))
- continue;
- - /* Send a JOIN unless the user's join has been delayed. */
- - if (!IsDelayedJoin(chan))
- + /* For a user with no modes in a join-delayed channel, do not show the rejoin. */
- + if (!IsChanOp(chan) && !HasVoice(chan) && (chan->channel->mode.mode & MODE_DELJOINS))
- + SetDelayedJoin(chan);
- + else
- sendcmdto_channel_butserv_butone(cptr, CMD_JOIN, chan->channel, cptr, 0,
- "%H", chan->channel);
- if (IsChanOp(chan) && HasVoice(chan))
- @@ -959,6 +978,7 @@ int set_user_mode(struct Client *cptr, s
- int prop = 0;
- int do_host_hiding = 0;
- char* account = NULL;
- + char* fakehost = NULL;
- what = MODE_ADD;
- @@ -969,7 +989,8 @@ int set_user_mode(struct Client *cptr, s
- for (i = 0; i < USERMODELIST_SIZE; i++)
- {
- if (HasFlag(sptr, userModeList[i].flag) &&
- - userModeList[i].flag != FLAG_ACCOUNT)
- + (userModeList[i].flag != FLAG_ACCOUNT) &&
- + (userModeList[i].flag != FLAG_FAKEHOST))
- *m++ = userModeList[i].c;
- }
- *m = '\0';
- @@ -1074,16 +1095,27 @@ int set_user_mode(struct Client *cptr, s
- ClearDebug(sptr);
- break;
- case 'x':
- - if (what == MODE_ADD)
- - do_host_hiding = 1;
- - break;
- + if (what == MODE_ADD) {
- + SetHiddenHost(sptr);
- + if (!FlagHas(&setflags, FLAG_HIDDENHOST))
- + do_host_hiding = 1;
- + }
- + break;
- case 'r':
- - if (*(p + 1) && (what == MODE_ADD)) {
- - account = *(++p);
- - SetAccount(sptr);
- - }
- - /* There is no -r */
- - break;
- + if (*(p + 1) && (what == MODE_ADD)) {
- + account = *(++p);
- + SetAccount(sptr);
- + }
- + /* There is no -r */
- + break;
- + case 'f':
- + if (*(p + 1) && (what == MODE_ADD)) {
- + fakehost = *(++p);
- + ircd_strncpy(cli_user(sptr)->fakehost, fakehost, HOSTLEN);
- + SetFakeHost(sptr);
- + }
- + /* There is no -f */
- + break;
- default:
- send_reply(sptr, ERR_UMODEUNKNOWNFLAG, *m);
- break;
- @@ -1157,7 +1189,7 @@ int set_user_mode(struct Client *cptr, s
- ircd_strncpy(cli_user(sptr)->account, account, len);
- }
- if (!FlagHas(&setflags, FLAG_HIDDENHOST) && do_host_hiding && allow_modes != ALLOWMODES_DEFAULT)
- - hide_hostmask(sptr, FLAG_HIDDENHOST);
- + hide_hostmask(sptr);
- if (IsRegistered(sptr)) {
- if (!FlagHas(&setflags, FLAG_OPER) && IsOper(sptr)) {
- @@ -1218,6 +1250,7 @@ char *umode_str(struct Client *cptr)
- *m++ = ' ';
- while ((*m++ = *t++))
- ; /* Empty loop */
- + m--; /* back up over previous null-termination */
- if (cli_user(cptr)->acc_create) {
- char nbuf[20];
- @@ -1226,12 +1259,21 @@ char *umode_str(struct Client *cptr)
- cli_user(cptr)->acc_create));
- ircd_snprintf(0, t = nbuf, sizeof(nbuf), ":%Tu",
- cli_user(cptr)->acc_create);
- - m--; /* back up over previous nul-termination */
- while ((*m++ = *t++))
- - ; /* Empty loop */
- + ; /* Empty loop */
- + m--; /* back up over previous nul-termination */
- }
- }
- + if (HasFakeHost(cptr))
- + {
- + char *t = cli_user(cptr)->fakehost;
- +
- + *m++ = ' ';
- + while ((*m++ = *t++))
- + ; /* Empty loop */
- + }
- +
- *m = '\0';
- return umodeBuf; /* Note: static buffer, gets
- @@ -1266,6 +1308,8 @@ void send_umode(struct Client *cptr, str
- if (FlagHas(old, flag)
- == HasFlag(sptr, flag))
- continue;
- + if (flag == FLAG_ACCOUNT || flag == FLAG_FAKEHOST)
- + continue;
- switch (sendset)
- {
- case ALL_UMODES:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement