diff options
author | michael <michael@82007160-df01-0410-b94d-b575c5fd34c7> | 2013-05-29 19:36:51 +0000 |
---|---|---|
committer | michael <michael@82007160-df01-0410-b94d-b575c5fd34c7> | 2013-05-29 19:36:51 +0000 |
commit | cead4299606b2512732879e6d377cdef777dc659 (patch) | |
tree | 6e82c5e77655f49be6c9515c63d6ab0a31af5dbd | |
parent | 6c9292470dfdd5508a7bc0d28c3702e6188f4575 (diff) |
- Finished proper implementation of usermode 'x' (UMODE_HIDDENHOST)
Only services may set a fakehost via SVSMODE.
git-svn-id: svn://svn.ircd-hybrid.org/svnroot/ircd-hybrid/branches/8.1.x@2136 82007160-df01-0410-b94d-b575c5fd34c7
-rw-r--r-- | include/client.h | 2 | ||||
-rw-r--r-- | include/numeric.h | 1 | ||||
-rw-r--r-- | include/s_user.h | 2 | ||||
-rw-r--r-- | modules/m_svsmode.c | 4 | ||||
-rw-r--r-- | src/numeric.c | 2 | ||||
-rw-r--r-- | src/s_user.c | 27 |
6 files changed, 28 insertions, 10 deletions
diff --git a/include/client.h b/include/client.h index d6734e4..c85de6e 100644 --- a/include/client.h +++ b/include/client.h @@ -159,6 +159,7 @@ #define UMODE_OPER 0x00400000 /**< Operator */ #define UMODE_ADMIN 0x00800000 /**< Admin on server */ #define UMODE_FARCONNECT 0x01000000 /**< Can see remote client connects/exits */ +#define UMODE_HIDDENHOST 0x02000000 /**< User's host is hidden */ #define UMODE_ALL UMODE_SERVNOTICE @@ -257,6 +258,7 @@ #define SetExemptResv(x) ((x)->flags |= FLAGS_EXEMPTRESV) #define SetIPSpoof(x) ((x)->flags |= FLAGS_IP_SPOOFING) #define IsIPSpoof(x) ((x)->flags & FLAGS_IP_SPOOFING) +#define DelIPSpoof(x) ((x)->flags &= ~FLAGS_IP_SPOOFING) #define IsFloodDone(x) ((x)->flags & FLAGS_FLOODDONE) #define SetFloodDone(x) ((x)->flags |= FLAGS_FLOODDONE) diff --git a/include/numeric.h b/include/numeric.h index 87296dd..0f9bca6 100644 --- a/include/numeric.h +++ b/include/numeric.h @@ -108,6 +108,7 @@ extern const char *form_str(unsigned int); #define RPL_GLOBALUSERS 266 #define RPL_ACCEPTLIST 281 #define RPL_ENDOFACCEPT 282 +#define RPL_NEWHOSTIS 285 /* numeric_replies */ #define RPL_AWAY 301 diff --git a/include/s_user.h b/include/s_user.h index b6f7a2f..77e5949 100644 --- a/include/s_user.h +++ b/include/s_user.h @@ -55,6 +55,6 @@ extern void add_isupport(const char *, const char *, int); extern void delete_isupport(const char *); extern void init_isupport(void); extern void rebuild_isupport_message_line(void); -extern void user_set_hostmask(struct Client *, const char *); +extern void user_set_hostmask(struct Client *, const char *, const int); #endif diff --git a/modules/m_svsmode.c b/modules/m_svsmode.c index a045aa1..d54f664 100644 --- a/modules/m_svsmode.c +++ b/modules/m_svsmode.c @@ -106,8 +106,8 @@ ms_svsmode(struct Client *client_p, struct Client *source_p, break; case 'x': - if (what == MODE_ADD && extarg) - user_set_hostmask(target_p, extarg); + if (!EmptyString(extarg) && valid_hostname(extarg)) + user_set_hostmask(target_p, extarg, what); break; case 'o': diff --git a/src/numeric.c b/src/numeric.c index 5f15738..0d4058f 100644 --- a/src/numeric.c +++ b/src/numeric.c @@ -312,7 +312,7 @@ static const char *replies[] = { /* 282 RPL_ENDOFACCEPT */ ":%s 282 %s :End of /ACCEPT list.", /* 283 */ NULL, /* 284 */ NULL, -/* 285 */ NULL, +/* 285 RPL_NEWHOSTIS */ ":%s 285 %s :Your new host is - [%s@%s]", /* 286 */ NULL, /* 287 */ NULL, /* 288 */ NULL, diff --git a/src/s_user.c b/src/s_user.c index 1d5120d..709e0d9 100644 --- a/src/s_user.c +++ b/src/s_user.c @@ -135,7 +135,7 @@ const unsigned int user_modes[256] = UMODE_UNAUTH, /* u */ 0, /* v */ UMODE_WALLOP, /* w */ - 0, /* x */ + UMODE_HIDDENHOST, /* x */ UMODE_SPY, /* y */ UMODE_OPERWALL, /* z 0x7A */ 0,0,0,0,0, /* 0x7B - 0x7F */ @@ -903,6 +903,7 @@ set_user_mode(struct Client *client_p, struct Client *source_p, break; case 'r': /* Only services may set +r */ + case 'x': /* Only services may set +x */ break; default: @@ -1052,22 +1053,36 @@ send_umode_out(struct Client *client_p, struct Client *source_p, } void -user_set_hostmask(struct Client *target_p, const char *hostname) +user_set_hostmask(struct Client *target_p, const char *hostname, const int what) { - if (!valid_hostname(hostname)) - return; - if (IsUserHostIp(target_p)) delete_user_host(target_p->username, target_p->host, !MyConnect(target_p)); strlcpy(target_p->host, hostname, sizeof(target_p->host)); - SetIPSpoof(target_p); add_user_host(target_p->username, target_p->host, !MyConnect(target_p)); SetUserHost(target_p); + switch (what) + { + case MODE_ADD: + AddUMode(target_p, UMODE_HIDDENHOST); + AddFlag(target_p, FLAGS_IP_SPOOFING); + break; + case MODE_DEL: + DelUMode(target_p, UMODE_HIDDENHOST); + DelFlag(target_p, FLAGS_IP_SPOOFING); + break; + default: break; + } + if (MyClient(target_p)) + { + sendto_one(target_p, form_str(RPL_NEWHOSTIS), me.name, + target_p->name, target_p->username, + target_p->host); clear_ban_cache_client(target_p); + } } /* user_welcome() |