mirror of
https://github.com/matrix-construct/construct
synced 2024-09-27 19:28:52 +02:00
Convert umodes to mode_lease mechanism.
This commit is contained in:
parent
b5d4fef865
commit
3ebde4ab50
22 changed files with 207 additions and 277 deletions
|
@ -320,6 +320,7 @@ RB_CHK_SYSHEADER([type_traits], [TYPE_TRAITS])
|
||||||
RB_CHK_SYSHEADER([utility], [UTILITY])
|
RB_CHK_SYSHEADER([utility], [UTILITY])
|
||||||
RB_CHK_SYSHEADER([functional], [FUNCTIONAL])
|
RB_CHK_SYSHEADER([functional], [FUNCTIONAL])
|
||||||
RB_CHK_SYSHEADER([algorithm], [ALGORITHM])
|
RB_CHK_SYSHEADER([algorithm], [ALGORITHM])
|
||||||
|
RB_CHK_SYSHEADER([numeric], [NUMERIC])
|
||||||
RB_CHK_SYSHEADER([memory], [MEMORY])
|
RB_CHK_SYSHEADER([memory], [MEMORY])
|
||||||
RB_CHK_SYSHEADER([exception], [EXCEPTION])
|
RB_CHK_SYSHEADER([exception], [EXCEPTION])
|
||||||
RB_CHK_SYSHEADER([cerrno], [CERRNO])
|
RB_CHK_SYSHEADER([cerrno], [CERRNO])
|
||||||
|
|
|
@ -58,11 +58,11 @@ static int eb_usermode(const char *data, client::client *client_p,
|
||||||
switch (dir)
|
switch (dir)
|
||||||
{
|
{
|
||||||
case MODE_DEL:
|
case MODE_DEL:
|
||||||
modes_nak |= user_modes[(unsigned char) *p];
|
modes_nak |= umode::table[(unsigned char) *p];
|
||||||
break;
|
break;
|
||||||
case MODE_ADD:
|
case MODE_ADD:
|
||||||
default:
|
default:
|
||||||
modes_ack |= user_modes[(unsigned char) *p];
|
modes_ack |= umode::table[(unsigned char) *p];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -27,8 +27,6 @@ mapi_hfn_list_av1 helpops_hfnlist[] = {
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
static int UMODE_HELPOPS = 0;
|
|
||||||
|
|
||||||
struct Message dehelper_msgtab = {
|
struct Message dehelper_msgtab = {
|
||||||
"DEHELPER", 0, 0, 0, 0,
|
"DEHELPER", 0, 0, 0, 0,
|
||||||
{mg_unreg, mg_not_oper, mg_not_oper, mg_ignore, {me_dehelper, 2}, {mo_dehelper, 2}}
|
{mg_unreg, mg_not_oper, mg_not_oper, mg_ignore, {me_dehelper, 2}, {mo_dehelper, 2}}
|
||||||
|
@ -36,6 +34,8 @@ struct Message dehelper_msgtab = {
|
||||||
|
|
||||||
mapi_clist_av1 helpops_clist[] = { &dehelper_msgtab, NULL };
|
mapi_clist_av1 helpops_clist[] = { &dehelper_msgtab, NULL };
|
||||||
|
|
||||||
|
umode::mode UMODE_HELPOPS { 'H' };
|
||||||
|
|
||||||
static void
|
static void
|
||||||
mo_dehelper(struct MsgBuf *msgbuf_p, client::client &client, client::client &source, int parc, const char **parv)
|
mo_dehelper(struct MsgBuf *msgbuf_p, client::client &client, client::client &source, int parc, const char **parv)
|
||||||
{
|
{
|
||||||
|
@ -96,21 +96,9 @@ do_dehelper(client::client &source, client::client &target)
|
||||||
static int
|
static int
|
||||||
_modinit(void)
|
_modinit(void)
|
||||||
{
|
{
|
||||||
/* add the usermode to the available slot */
|
|
||||||
user_modes['H'] = UMODE_HELPOPS = find_umode_slot();
|
|
||||||
construct_umodebuf();
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
_moddeinit(void)
|
|
||||||
{
|
|
||||||
/* disable the umode and remove it from the available list */
|
|
||||||
user_modes['H'] = UMODE_HELPOPS = 0;
|
|
||||||
construct_umodebuf();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
h_hdl_stats_request(hook_data_int *hdata)
|
h_hdl_stats_request(hook_data_int *hdata)
|
||||||
{
|
{
|
||||||
|
@ -169,7 +157,7 @@ h_hdl_umode_changed(hook_data_umode_changed *hdata)
|
||||||
{
|
{
|
||||||
if (my(source) && !HasPrivilege(&source, "usermode:helpops"))
|
if (my(source) && !HasPrivilege(&source, "usermode:helpops"))
|
||||||
{
|
{
|
||||||
source.mode &= umode(~UMODE_HELPOPS);
|
source.mode &= ~UMODE_HELPOPS;
|
||||||
sendto_one(&source, form_str(ERR_NOPRIVS), me.name, source.name, "usermode:helpops");
|
sendto_one(&source, form_str(ERR_NOPRIVS), me.name, source.name, "usermode:helpops");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -192,4 +180,4 @@ h_hdl_whois(hook_data_client *hdata)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DECLARE_MODULE_AV2(helpops, _modinit, _moddeinit, helpops_clist, NULL, helpops_hfnlist, NULL, NULL, helpops_desc);
|
DECLARE_MODULE_AV2(helpops, _modinit, nullptr, helpops_clist, NULL, helpops_hfnlist, NULL, NULL, helpops_desc);
|
||||||
|
|
|
@ -9,22 +9,17 @@ using namespace ircd;
|
||||||
|
|
||||||
static const char ip_cloaking_desc[] = "New IP cloaking module that uses user mode +x instead of +h";
|
static const char ip_cloaking_desc[] = "New IP cloaking module that uses user mode +x instead of +h";
|
||||||
|
|
||||||
|
umode::mode UMODE_IP_CLOAKING { 'x' };
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_modinit(void)
|
_modinit(void)
|
||||||
{
|
{
|
||||||
/* add the usermode to the available slot */
|
|
||||||
user_modes['x'] = find_umode_slot();
|
|
||||||
construct_umodebuf();
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_moddeinit(void)
|
_moddeinit(void)
|
||||||
{
|
{
|
||||||
/* disable the umode and remove it from the available list */
|
|
||||||
user_modes['x'] = 0;
|
|
||||||
construct_umodebuf();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void check_umode_change(void *data);
|
static void check_umode_change(void *data);
|
||||||
|
@ -162,14 +157,14 @@ check_umode_change(void *vdata)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* didn't change +h umode, we don't need to do anything */
|
/* didn't change +h umode, we don't need to do anything */
|
||||||
if (!((data->oldumodes ^ source_p->mode) & user_modes['x']))
|
if (!((data->oldumodes ^ source_p->mode) & UMODE_IP_CLOAKING))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (source_p->mode & user_modes['x'])
|
if (source_p->mode & UMODE_IP_CLOAKING)
|
||||||
{
|
{
|
||||||
if (is_ip_spoof(*source_p) || source_p->localClient->mangledhost == NULL || (is_dyn_spoof(*source_p) && strcmp(source_p->host, source_p->localClient->mangledhost)))
|
if (is_ip_spoof(*source_p) || source_p->localClient->mangledhost == NULL || (is_dyn_spoof(*source_p) && strcmp(source_p->host, source_p->localClient->mangledhost)))
|
||||||
{
|
{
|
||||||
source_p->mode &= umode(~user_modes['x']);
|
source_p->mode &= ~UMODE_IP_CLOAKING;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (strcmp(source_p->host, source_p->localClient->mangledhost))
|
if (strcmp(source_p->host, source_p->localClient->mangledhost))
|
||||||
|
@ -180,7 +175,7 @@ check_umode_change(void *vdata)
|
||||||
sendto_one_numeric(source_p, RPL_HOSTHIDDEN, "%s :is now your hidden host",
|
sendto_one_numeric(source_p, RPL_HOSTHIDDEN, "%s :is now your hidden host",
|
||||||
source_p->host);
|
source_p->host);
|
||||||
}
|
}
|
||||||
else if (!(source_p->mode & user_modes['x']))
|
else if (!(source_p->mode & UMODE_IP_CLOAKING))
|
||||||
{
|
{
|
||||||
if (source_p->localClient->mangledhost != NULL &&
|
if (source_p->localClient->mangledhost != NULL &&
|
||||||
!strcmp(source_p->host, source_p->localClient->mangledhost))
|
!strcmp(source_p->host, source_p->localClient->mangledhost))
|
||||||
|
@ -197,7 +192,7 @@ check_new_user(void *vdata)
|
||||||
|
|
||||||
if (is_ip_spoof(*source_p))
|
if (is_ip_spoof(*source_p))
|
||||||
{
|
{
|
||||||
source_p->mode &= umode(~user_modes['x']);
|
source_p->mode &= ~UMODE_IP_CLOAKING;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
source_p->localClient->mangledhost = (char *)rb_malloc(HOSTLEN + 1);
|
source_p->localClient->mangledhost = (char *)rb_malloc(HOSTLEN + 1);
|
||||||
|
@ -206,8 +201,8 @@ check_new_user(void *vdata)
|
||||||
else
|
else
|
||||||
do_host_cloak_host(source_p->orighost, source_p->localClient->mangledhost);
|
do_host_cloak_host(source_p->orighost, source_p->localClient->mangledhost);
|
||||||
if (is_dyn_spoof(*source_p))
|
if (is_dyn_spoof(*source_p))
|
||||||
source_p->mode &= umode(~user_modes['x']);
|
source_p->mode &= ~UMODE_IP_CLOAKING;
|
||||||
if (source_p->mode & user_modes['x'])
|
if (source_p->mode & UMODE_IP_CLOAKING)
|
||||||
{
|
{
|
||||||
rb_strlcpy(source_p->host, source_p->localClient->mangledhost, sizeof(source_p->host));
|
rb_strlcpy(source_p->host, source_p->localClient->mangledhost, sizeof(source_p->host));
|
||||||
if (irccmp(source_p->host, source_p->orighost))
|
if (irccmp(source_p->host, source_p->orighost))
|
||||||
|
|
|
@ -30,6 +30,8 @@ mapi_hfn_list_av1 override_hfnlist[] = {
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
umode::mode UMODE_OVERRIDE { 'p' };
|
||||||
|
|
||||||
#define CHFL_OVERRIDE 0x0004
|
#define CHFL_OVERRIDE 0x0004
|
||||||
#define IsOperOverride(x) (HasPrivilege((x), "oper:override"))
|
#define IsOperOverride(x) (HasPrivilege((x), "oper:override"))
|
||||||
|
|
||||||
|
@ -102,18 +104,18 @@ check_umode_change(void *vdata)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (data->oldumodes & umode::OPER && !is(*source_p, umode::OPER))
|
if (data->oldumodes & umode::OPER && !is(*source_p, umode::OPER))
|
||||||
source_p->mode &= umode(~user_modes['p']);
|
source_p->mode &= ~UMODE_OVERRIDE;
|
||||||
|
|
||||||
/* didn't change +p umode, we don't need to do anything */
|
/* didn't change +p umode, we don't need to do anything */
|
||||||
if (!((data->oldumodes ^ source_p->mode) & user_modes['p']))
|
if (!((data->oldumodes ^ source_p->mode) & UMODE_OVERRIDE))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (source_p->mode & user_modes['p'])
|
if (source_p->mode & UMODE_OVERRIDE)
|
||||||
{
|
{
|
||||||
if (!IsOperOverride(source_p))
|
if (!IsOperOverride(source_p))
|
||||||
{
|
{
|
||||||
sendto_one_notice(source_p, ":*** You need oper:override privilege for +p");
|
sendto_one_notice(source_p, ":*** You need oper:override privilege for +p");
|
||||||
source_p->mode &= umode(~user_modes['p']);
|
source_p->mode &= ~UMODE_OVERRIDE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +124,7 @@ check_umode_change(void *vdata)
|
||||||
sendto_realops_snomask(sno::GENERAL, L_NETWIDE, "%s has enabled oper-override (+p)",
|
sendto_realops_snomask(sno::GENERAL, L_NETWIDE, "%s has enabled oper-override (+p)",
|
||||||
get_oper_name(source_p));
|
get_oper_name(source_p));
|
||||||
}
|
}
|
||||||
else if (!(source_p->mode & user_modes['p']))
|
else if (!(source_p->mode & UMODE_OVERRIDE))
|
||||||
{
|
{
|
||||||
rb_dlink_node *n, *tn;
|
rb_dlink_node *n, *tn;
|
||||||
|
|
||||||
|
@ -153,7 +155,7 @@ hack_channel_access(void *vdata)
|
||||||
if (data->approved == chan::CHANOP)
|
if (data->approved == chan::CHANOP)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (data->client->mode & user_modes['p'])
|
if (data->client->mode & UMODE_OVERRIDE)
|
||||||
{
|
{
|
||||||
update_session_deadline(data->client, NULL);
|
update_session_deadline(data->client, NULL);
|
||||||
data->approved = CHFL_OVERRIDE;
|
data->approved = CHFL_OVERRIDE;
|
||||||
|
@ -173,7 +175,7 @@ hack_can_join(void *vdata)
|
||||||
if (data->approved == 0)
|
if (data->approved == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (data->client->mode & user_modes['p'])
|
if (data->client->mode & UMODE_OVERRIDE)
|
||||||
{
|
{
|
||||||
update_session_deadline(data->client, NULL);
|
update_session_deadline(data->client, NULL);
|
||||||
data->approved = 0;
|
data->approved = 0;
|
||||||
|
@ -193,7 +195,7 @@ hack_can_kick(void *vdata)
|
||||||
if (alevel != CHFL_OVERRIDE)
|
if (alevel != CHFL_OVERRIDE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (data->client->mode & user_modes['p'])
|
if (data->client->mode & UMODE_OVERRIDE)
|
||||||
{
|
{
|
||||||
update_session_deadline(data->client, NULL);
|
update_session_deadline(data->client, NULL);
|
||||||
sendto_realops_snomask(sno::GENERAL, L_NETWIDE, "%s is using oper-override on %s (KICK %s)",
|
sendto_realops_snomask(sno::GENERAL, L_NETWIDE, "%s is using oper-override on %s (KICK %s)",
|
||||||
|
@ -212,7 +214,7 @@ hack_can_send(void *vdata)
|
||||||
if (data->approved == chan::CAN_SEND_NONOP || data->approved == chan::CAN_SEND_OPV)
|
if (data->approved == chan::CAN_SEND_NONOP || data->approved == chan::CAN_SEND_OPV)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (data->client->mode & user_modes['p'])
|
if (data->client->mode & UMODE_OVERRIDE)
|
||||||
{
|
{
|
||||||
data->approved = chan::CAN_SEND_NONOP;
|
data->approved = chan::CAN_SEND_NONOP;
|
||||||
|
|
||||||
|
@ -249,22 +251,13 @@ struct ev_entry *expire_override_deadlines_ev = NULL;
|
||||||
static int
|
static int
|
||||||
_modinit(void)
|
_modinit(void)
|
||||||
{
|
{
|
||||||
/* add the usermode to the available slot */
|
|
||||||
user_modes['p'] = find_umode_slot();
|
|
||||||
construct_umodebuf();
|
|
||||||
|
|
||||||
expire_override_deadlines_ev = rb_event_add("expire_override_deadlines", expire_override_deadlines, NULL, 60);
|
expire_override_deadlines_ev = rb_event_add("expire_override_deadlines", expire_override_deadlines, NULL, 60);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_moddeinit(void)
|
_moddeinit(void)
|
||||||
{
|
{
|
||||||
/* disable the umode and remove it from the available list */
|
|
||||||
user_modes['p'] = 0;
|
|
||||||
construct_umodebuf();
|
|
||||||
|
|
||||||
rb_event_delete(expire_override_deadlines_ev);
|
rb_event_delete(expire_override_deadlines_ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,13 +32,15 @@ mapi_hfn_list_av1 umode_noctcp_hfnlist[] = {
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
umode::mode UMODE_NOCTCP { 'C' };
|
||||||
|
|
||||||
static void
|
static void
|
||||||
umode_noctcp_process(hook_data_privmsg_user *data) {
|
umode_noctcp_process(hook_data_privmsg_user *data) {
|
||||||
if (data->approved || data->msgtype == MESSAGE_TYPE_NOTICE) {
|
if (data->approved || data->msgtype == MESSAGE_TYPE_NOTICE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data->target_p->mode & user_modes['C'] && *data->text == '\001' && rb_strncasecmp(data->text + 1, "ACTION", 6)) {
|
if (data->target_p->mode & UMODE_NOCTCP && *data->text == '\001' && rb_strncasecmp(data->text + 1, "ACTION", 6)) {
|
||||||
sendto_one_numeric(data->source_p, ERR_CANNOTSENDTOUSER, form_str(ERR_CANNOTSENDTOUSER), data->target_p->name, "+C set");
|
sendto_one_numeric(data->source_p, ERR_CANNOTSENDTOUSER, form_str(ERR_CANNOTSENDTOUSER), data->target_p->name, "+C set");
|
||||||
data->approved = ERR_CANNOTSENDTOUSER;
|
data->approved = ERR_CANNOTSENDTOUSER;
|
||||||
return;
|
return;
|
||||||
|
@ -48,17 +50,7 @@ umode_noctcp_process(hook_data_privmsg_user *data) {
|
||||||
static int
|
static int
|
||||||
_modinit(void)
|
_modinit(void)
|
||||||
{
|
{
|
||||||
user_modes['C'] = find_umode_slot();
|
|
||||||
construct_umodebuf();
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
DECLARE_MODULE_AV2(umode_noctcp, _modinit, nullptr, NULL, NULL, umode_noctcp_hfnlist, NULL, NULL, umode_noctcp_desc);
|
||||||
_moddeinit(void)
|
|
||||||
{
|
|
||||||
user_modes['C'] = 0;
|
|
||||||
construct_umodebuf();
|
|
||||||
}
|
|
||||||
|
|
||||||
DECLARE_MODULE_AV2(umode_noctcp, _modinit, _moddeinit, NULL, NULL, umode_noctcp_hfnlist, NULL, NULL, umode_noctcp_desc);
|
|
||||||
|
|
|
@ -97,7 +97,7 @@ struct client
|
||||||
// unique whowas id associating any history to *this (TODO: replace with connid)
|
// unique whowas id associating any history to *this (TODO: replace with connid)
|
||||||
whowas::id_t wwid;
|
whowas::id_t wwid;
|
||||||
time_t tsinfo; /* TS on the nick, SVINFO on server */
|
time_t tsinfo; /* TS on the nick, SVINFO on server */
|
||||||
mode::mode mode;
|
mode::mask mode;
|
||||||
uint64_t flags; /* client flags */
|
uint64_t flags; /* client flags */
|
||||||
|
|
||||||
unsigned int snomask; /* server notice mask */
|
unsigned int snomask; /* server notice mask */
|
||||||
|
@ -327,21 +327,21 @@ struct ListClient
|
||||||
|
|
||||||
|
|
||||||
inline bool
|
inline bool
|
||||||
is(const client &client, const mode::mode &mode)
|
is(const client &client, const mode::mask &mask)
|
||||||
{
|
{
|
||||||
return is(client.mode, mode);
|
return mode::is(client.mode, mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
set(client &client, const mode::mode &mode)
|
set(client &client, const mode::mask &mask)
|
||||||
{
|
{
|
||||||
return set(client.mode, mode);
|
return mode::set(client.mode, mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
clear(client &client, const mode::mode &mode)
|
clear(client &client, const mode::mask &mask)
|
||||||
{
|
{
|
||||||
return clear(client.mode, mode);
|
return mode::clear(client.mode, mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
|
|
|
@ -27,63 +27,68 @@ namespace ircd {
|
||||||
namespace client {
|
namespace client {
|
||||||
namespace mode {
|
namespace mode {
|
||||||
|
|
||||||
enum mode : uint
|
using mask = uint64_t;
|
||||||
|
extern mode_table<mask> table;
|
||||||
|
extern char available[64];
|
||||||
|
|
||||||
|
class mode
|
||||||
|
:public mode_lease<mask, table>
|
||||||
{
|
{
|
||||||
SERVNOTICE = 0x0001, // server notices
|
void release() noexcept override;
|
||||||
WALLOP = 0x0002, // send wallops to them
|
|
||||||
OPERWALL = 0x0004, // operwalls
|
public:
|
||||||
INVISIBLE = 0x0008, // makes user invisible
|
explicit mode(const char &c);
|
||||||
CALLERID = 0x0010, // block unless caller id's
|
|
||||||
LOCOPS = 0x0020, // show locops
|
|
||||||
SERVICE = 0x0040,
|
|
||||||
DEAF = 0x0080,
|
|
||||||
NOFORWARD = 0x0100, // don't forward
|
|
||||||
REGONLYMSG = 0x0200, // only allow logged in users to msg
|
|
||||||
OPER = 0x1000, // operator
|
|
||||||
ADMIN = 0x2000, // admin on server
|
|
||||||
SSLCLIENT = 0x4000, // using SSL
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const mode DEFAULT_OPER_UMODES
|
extern mode SERVNOTICE; // server notices
|
||||||
{
|
extern mode WALLOP; // send wallops to them
|
||||||
SERVNOTICE |
|
extern mode OPERWALL; // operwalls
|
||||||
OPERWALL |
|
extern mode INVISIBLE; // makes user invisible
|
||||||
WALLOP |
|
extern mode CALLERID; // block unless caller id's
|
||||||
LOCOPS
|
extern mode LOCOPS; // show locops
|
||||||
};
|
extern mode SERVICE;
|
||||||
|
extern mode DEAF;
|
||||||
|
extern mode NOFORWARD; // don't forward
|
||||||
|
extern mode REGONLYMSG; // only allow logged in users to msg
|
||||||
|
extern mode OPER; // operator
|
||||||
|
extern mode ADMIN; // admin on server
|
||||||
|
extern mode SSLCLIENT; // using SSL
|
||||||
|
|
||||||
|
extern const mask DEFAULT_OPER_UMODES;
|
||||||
|
|
||||||
|
bool is(const mask &, const mask &);
|
||||||
|
void clear(mask &, const mask &);
|
||||||
|
void set(mask &, const mask &);
|
||||||
|
|
||||||
bool is(const mode &mask, const mode &bits);
|
|
||||||
void clear(mode &mask, const mode &bits);
|
|
||||||
void set(mode &mask, const mode &bits);
|
|
||||||
|
|
||||||
} // namespace mode
|
} // namespace mode
|
||||||
} // namespace client
|
} // namespace client
|
||||||
|
|
||||||
// Import `umode` type into ircd:: namespace
|
// Import `umode` type into ircd:: namespace
|
||||||
using umode = client::mode::mode;
|
namespace umode = client::mode;
|
||||||
|
|
||||||
} // namespace ircd
|
} // namespace ircd
|
||||||
|
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
ircd::client::mode::set(mode &mask,
|
ircd::client::mode::set(mask &cur,
|
||||||
const mode &bits)
|
const mask &bit)
|
||||||
{
|
{
|
||||||
mask |= bits;
|
cur |= bit;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
ircd::client::mode::clear(mode &mask,
|
ircd::client::mode::clear(mask &cur,
|
||||||
const mode &bits)
|
const mask &bit)
|
||||||
{
|
{
|
||||||
mask &= ~bits;
|
cur &= ~bit;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool
|
inline bool
|
||||||
ircd::client::mode::is(const mode &mask,
|
ircd::client::mode::is(const mask &cur,
|
||||||
const mode &bits)
|
const mask &bit)
|
||||||
{
|
{
|
||||||
return (mask & bits) == bits;
|
return (cur & bit) == bit;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
|
|
|
@ -33,7 +33,7 @@ class mode_lease
|
||||||
|
|
||||||
char c = '\0';
|
char c = '\0';
|
||||||
|
|
||||||
virtual void release() { table[c] = { 0 }; }
|
virtual void release() noexcept { table[c] = { 0 }; }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit operator const char &() const { return c; }
|
explicit operator const char &() const { return c; }
|
||||||
|
@ -44,7 +44,7 @@ class mode_lease
|
||||||
mode_lease() = default;
|
mode_lease() = default;
|
||||||
mode_lease(mode_lease &&) noexcept;
|
mode_lease(mode_lease &&) noexcept;
|
||||||
mode_lease(const mode_lease &) = delete;
|
mode_lease(const mode_lease &) = delete;
|
||||||
~mode_lease() noexcept;
|
virtual ~mode_lease() noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class T,
|
template<class T,
|
||||||
|
@ -54,6 +54,9 @@ mode_lease<T, table>::mode_lease(const char &c,
|
||||||
args&&... a)
|
args&&... a)
|
||||||
:c(c)
|
:c(c)
|
||||||
{
|
{
|
||||||
|
if(!c)
|
||||||
|
return;
|
||||||
|
|
||||||
if(!!table[c])
|
if(!!table[c])
|
||||||
throw mode_filled("Character [%c] is already leased", c);
|
throw mode_filled("Character [%c] is already leased", c);
|
||||||
|
|
||||||
|
@ -74,7 +77,9 @@ template<class T,
|
||||||
mode_lease<T, table>::~mode_lease()
|
mode_lease<T, table>::~mode_lease()
|
||||||
noexcept
|
noexcept
|
||||||
{
|
{
|
||||||
if(c)
|
if(!c)
|
||||||
|
return;
|
||||||
|
|
||||||
release();
|
release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -194,6 +194,33 @@ find(const mode_table<T> &table,
|
||||||
return int8_t(std::distance(begin(table), it));
|
return int8_t(std::distance(begin(table), it));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
auto
|
||||||
|
mask_table(const mode_table<T> &table)
|
||||||
|
{
|
||||||
|
using mask_t = typename mode_table<T>::mask_t;
|
||||||
|
|
||||||
|
return std::accumulate(begin(table), end(table), mask_t(0), []
|
||||||
|
(auto mask, const T &elem)
|
||||||
|
{
|
||||||
|
return mask |= static_cast<const mask_t &>(elem);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
char *
|
||||||
|
mask_table(const mode_table<T> &table,
|
||||||
|
char *const &buf)
|
||||||
|
{
|
||||||
|
char *p(buf);
|
||||||
|
for(size_t i(0); i < table.size(); ++i)
|
||||||
|
if(!!table[i])
|
||||||
|
*p++ = i;
|
||||||
|
|
||||||
|
*p = '\0';
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
auto
|
auto
|
||||||
find_slot(const mode_table<T> &table,
|
find_slot(const mode_table<T> &table,
|
||||||
|
@ -201,13 +228,7 @@ find_slot(const mode_table<T> &table,
|
||||||
{
|
{
|
||||||
using mask_t = typename mode_table<T>::mask_t;
|
using mask_t = typename mode_table<T>::mask_t;
|
||||||
|
|
||||||
mask_t mask(0);
|
const auto mask(mask_table(table));
|
||||||
std::for_each(begin(table), end(table), [&mask]
|
|
||||||
(const T &elem)
|
|
||||||
{
|
|
||||||
mask |= elem;
|
|
||||||
});
|
|
||||||
|
|
||||||
for(mask_t i(1); i; i <<= 1)
|
for(mask_t i(1); i; i <<= 1)
|
||||||
if(~mask & i)
|
if(~mask & i)
|
||||||
return i;
|
return i;
|
||||||
|
|
|
@ -45,10 +45,6 @@ void introduce_client(client::client *client_p, client::client *source_p, const
|
||||||
extern void change_nick_user_host(client::client *target_p, const char *nick, const char *user,
|
extern void change_nick_user_host(client::client *target_p, const char *nick, const char *user,
|
||||||
const char *host, int newts, const char *format, ...);
|
const char *host, int newts, const char *format, ...);
|
||||||
|
|
||||||
extern int user_modes[256];
|
|
||||||
extern unsigned int find_umode_slot(void);
|
|
||||||
extern void construct_umodebuf(void);
|
|
||||||
|
|
||||||
extern void oper_up(client::client *, struct oper_conf *);
|
extern void oper_up(client::client *, struct oper_conf *);
|
||||||
|
|
||||||
} // namespace ircd
|
} // namespace ircd
|
||||||
|
|
|
@ -62,6 +62,7 @@ extern "C" {
|
||||||
#include <RB_INC_UTILITY
|
#include <RB_INC_UTILITY
|
||||||
#include <RB_INC_FUNCTIONAL
|
#include <RB_INC_FUNCTIONAL
|
||||||
#include <RB_INC_ALGORITHM
|
#include <RB_INC_ALGORITHM
|
||||||
|
#include <RB_INC_NUMERIC
|
||||||
#include <RB_INC_MEMORY
|
#include <RB_INC_MEMORY
|
||||||
#include <RB_INC_EXCEPTION
|
#include <RB_INC_EXCEPTION
|
||||||
#include <RB_INC_SYSTEM_ERROR
|
#include <RB_INC_SYSTEM_ERROR
|
||||||
|
|
|
@ -45,6 +45,7 @@ libircd_la_SOURCES = \
|
||||||
chmode.cc \
|
chmode.cc \
|
||||||
class.cc \
|
class.cc \
|
||||||
client.cc \
|
client.cc \
|
||||||
|
client_mode.cc \
|
||||||
dns.cc \
|
dns.cc \
|
||||||
exception.cc \
|
exception.cc \
|
||||||
extban.cc \
|
extban.cc \
|
||||||
|
|
|
@ -94,7 +94,7 @@ client::client::client()
|
||||||
,from{nullptr}
|
,from{nullptr}
|
||||||
,wwid{0}
|
,wwid{0}
|
||||||
,tsinfo{0}
|
,tsinfo{0}
|
||||||
,mode{(umode)0}
|
,mode{0}
|
||||||
,flags{(enum flags)0}
|
,flags{(enum flags)0}
|
||||||
,snomask{0}
|
,snomask{0}
|
||||||
,hopcount{0}
|
,hopcount{0}
|
||||||
|
|
62
ircd/client_mode.cc
Normal file
62
ircd/client_mode.cc
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2016 Charybdis Development Team
|
||||||
|
* Copyright (C) 2016 Jason Volk <jason@zemos.net>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice is present in all copies.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
||||||
|
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||||
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||||
|
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using namespace ircd;
|
||||||
|
using client::mode::mode;
|
||||||
|
|
||||||
|
mode_table<client::mode::mask> client::mode::table;
|
||||||
|
decltype(client::mode::available) client::mode::available;
|
||||||
|
|
||||||
|
mode client::mode::SERVNOTICE { 's' };
|
||||||
|
mode client::mode::WALLOP { 'w' };
|
||||||
|
mode client::mode::OPERWALL { 'z' };
|
||||||
|
mode client::mode::INVISIBLE { 'i' };
|
||||||
|
mode client::mode::CALLERID { 'g' };
|
||||||
|
mode client::mode::LOCOPS { 'l' };
|
||||||
|
mode client::mode::SERVICE { 'S' };
|
||||||
|
mode client::mode::DEAF { 'D' };
|
||||||
|
mode client::mode::NOFORWARD { 'Q' };
|
||||||
|
mode client::mode::REGONLYMSG { 'R' };
|
||||||
|
mode client::mode::OPER { 'o' };
|
||||||
|
mode client::mode::ADMIN { 'a' };
|
||||||
|
mode client::mode::SSLCLIENT { 'Z' };
|
||||||
|
|
||||||
|
const client::mode::mask client::mode::DEFAULT_OPER_UMODES
|
||||||
|
{
|
||||||
|
SERVNOTICE |
|
||||||
|
OPERWALL |
|
||||||
|
WALLOP |
|
||||||
|
LOCOPS
|
||||||
|
};
|
||||||
|
|
||||||
|
mode::mode(const char &c)
|
||||||
|
:mode_lease{c}
|
||||||
|
{
|
||||||
|
mask_table(table, available);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
mode::release()
|
||||||
|
noexcept
|
||||||
|
{
|
||||||
|
table[char(*this)] = 0;
|
||||||
|
mask_table(table, available);
|
||||||
|
}
|
|
@ -623,8 +623,6 @@ charybdis_main(int argc, char * const argv[])
|
||||||
|
|
||||||
rb_dlinkAddAlloc(&me, &global_serv_list);
|
rb_dlinkAddAlloc(&me, &global_serv_list);
|
||||||
|
|
||||||
construct_umodebuf();
|
|
||||||
|
|
||||||
check_class();
|
check_class();
|
||||||
write_pidfile(pidFileName);
|
write_pidfile(pidFileName);
|
||||||
cache::help::load();
|
cache::help::load();
|
||||||
|
|
|
@ -295,7 +295,7 @@ conf_set_modules_path(void *data)
|
||||||
struct mode_table_
|
struct mode_table_
|
||||||
{
|
{
|
||||||
const char *name;
|
const char *name;
|
||||||
int mode;
|
umode::mask mode;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* *INDENT-OFF* */
|
/* *INDENT-OFF* */
|
||||||
|
@ -1677,7 +1677,7 @@ conf_set_general_default_umodes(void *data)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if ((flag = user_modes[(unsigned char) *pm]))
|
if ((flag = umode::table[(unsigned char) *pm]))
|
||||||
{
|
{
|
||||||
/* Proper value has probably not yet been set
|
/* Proper value has probably not yet been set
|
||||||
* so don't check oper_only_umodes -- jilles */
|
* so don't check oper_only_umodes -- jilles */
|
||||||
|
|
164
ircd/s_user.cc
164
ircd/s_user.cc
|
@ -27,81 +27,6 @@ namespace ircd {
|
||||||
static void report_and_set_user_flags(client::client *, struct ConfItem *);
|
static void report_and_set_user_flags(client::client *, struct ConfItem *);
|
||||||
void user_welcome(client::client *source_p);
|
void user_welcome(client::client *source_p);
|
||||||
|
|
||||||
char umodebuf[128];
|
|
||||||
|
|
||||||
static int orphaned_umodes = 0;
|
|
||||||
|
|
||||||
int user_modes[256] = {
|
|
||||||
/* 0x00 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x0F */
|
|
||||||
/* 0x10 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x1F */
|
|
||||||
/* 0x20 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x2F */
|
|
||||||
/* 0x30 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x3F */
|
|
||||||
0, /* @ */
|
|
||||||
0, /* A */
|
|
||||||
0, /* B */
|
|
||||||
0, /* C */
|
|
||||||
umode::DEAF, /* D */
|
|
||||||
0, /* E */
|
|
||||||
0, /* F */
|
|
||||||
0, /* G */
|
|
||||||
0, /* H */
|
|
||||||
0, /* I */
|
|
||||||
0, /* J */
|
|
||||||
0, /* K */
|
|
||||||
0, /* L */
|
|
||||||
0, /* M */
|
|
||||||
0, /* N */
|
|
||||||
0, /* O */
|
|
||||||
0, /* P */
|
|
||||||
umode::NOFORWARD, /* Q */
|
|
||||||
umode::REGONLYMSG, /* R */
|
|
||||||
umode::SERVICE, /* S */
|
|
||||||
0, /* T */
|
|
||||||
0, /* U */
|
|
||||||
0, /* V */
|
|
||||||
0, /* W */
|
|
||||||
0, /* X */
|
|
||||||
0, /* Y */
|
|
||||||
umode::SSLCLIENT, /* Z */
|
|
||||||
/* 0x5B */ 0, 0, 0, 0, 0, 0, /* 0x60 */
|
|
||||||
umode::ADMIN, /* a */
|
|
||||||
0, /* b */
|
|
||||||
0, /* c */
|
|
||||||
0, /* d */
|
|
||||||
0, /* e */
|
|
||||||
0, /* f */
|
|
||||||
umode::CALLERID, /* g */
|
|
||||||
0, /* h */
|
|
||||||
umode::INVISIBLE, /* i */
|
|
||||||
0, /* j */
|
|
||||||
0, /* k */
|
|
||||||
umode::LOCOPS, /* l */
|
|
||||||
0, /* m */
|
|
||||||
0, /* n */
|
|
||||||
umode::OPER, /* o */
|
|
||||||
0, /* p */
|
|
||||||
0, /* q */
|
|
||||||
0, /* r */
|
|
||||||
umode::SERVNOTICE, /* s */
|
|
||||||
0, /* t */
|
|
||||||
0, /* u */
|
|
||||||
0, /* v */
|
|
||||||
umode::WALLOP, /* w */
|
|
||||||
0, /* x */
|
|
||||||
0, /* y */
|
|
||||||
umode::OPERWALL, /* z */
|
|
||||||
/* 0x7B */ 0, 0, 0, 0, 0, /* 0x7F */
|
|
||||||
/* 0x80 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x9F */
|
|
||||||
/* 0x90 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x9F */
|
|
||||||
/* 0xA0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xAF */
|
|
||||||
/* 0xB0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xBF */
|
|
||||||
/* 0xC0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xCF */
|
|
||||||
/* 0xD0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xDF */
|
|
||||||
/* 0xE0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xEF */
|
|
||||||
/* 0xF0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* 0xFF */
|
|
||||||
};
|
|
||||||
/* *INDENT-ON* */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* show_lusers -
|
* show_lusers -
|
||||||
*
|
*
|
||||||
|
@ -557,7 +482,7 @@ register_local_user(client::client *client_p, client::client *source_p)
|
||||||
set_dyn_spoof(*source_p);
|
set_dyn_spoof(*source_p);
|
||||||
}
|
}
|
||||||
|
|
||||||
source_p->mode |= umode(ConfigFileEntry.default_umodes & ~ConfigFileEntry.oper_only_umodes & ~orphaned_umodes);
|
source_p->mode |= (ConfigFileEntry.default_umodes & ~ConfigFileEntry.oper_only_umodes);
|
||||||
|
|
||||||
call_hook(h_new_local_user, source_p);
|
call_hook(h_new_local_user, source_p);
|
||||||
|
|
||||||
|
@ -946,7 +871,7 @@ show_other_user_mode(client::client *source_p, client::client *target_p)
|
||||||
*m++ = '+';
|
*m++ = '+';
|
||||||
|
|
||||||
for (i = 0; i < 128; i++) /* >= 127 is extended ascii */
|
for (i = 0; i < 128; i++) /* >= 127 is extended ascii */
|
||||||
if (target_p->mode & user_modes[i])
|
if (target_p->mode & umode::table[i])
|
||||||
*m++ = (char) i;
|
*m++ = (char) i;
|
||||||
*m = '\0';
|
*m = '\0';
|
||||||
|
|
||||||
|
@ -1026,7 +951,7 @@ user_mode(client::client *client_p, client::client *source_p, int parc, const ch
|
||||||
*m++ = '+';
|
*m++ = '+';
|
||||||
|
|
||||||
for (i = 0; i < 128; i++) /* >= 127 is extended ascii */
|
for (i = 0; i < 128; i++) /* >= 127 is extended ascii */
|
||||||
if (source_p->mode & user_modes[i])
|
if (source_p->mode & umode::table[i])
|
||||||
*m++ = (char) i;
|
*m++ = (char) i;
|
||||||
|
|
||||||
*m = '\0';
|
*m = '\0';
|
||||||
|
@ -1084,7 +1009,7 @@ user_mode(client::client *client_p, client::client *source_p, int parc, const ch
|
||||||
|
|
||||||
if(my_connect(*source_p))
|
if(my_connect(*source_p))
|
||||||
{
|
{
|
||||||
clear(*source_p, umode(ConfigFileEntry.oper_only_umodes));
|
clear(*source_p, ConfigFileEntry.oper_only_umodes);
|
||||||
if (!is(*source_p, umode::SERVNOTICE) && source_p->snomask != 0)
|
if (!is(*source_p, umode::SERVNOTICE) && source_p->snomask != 0)
|
||||||
{
|
{
|
||||||
source_p->snomask = 0;
|
source_p->snomask = 0;
|
||||||
|
@ -1151,12 +1076,11 @@ user_mode(client::client *client_p, client::client *source_p, int parc, const ch
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((flag = user_modes[(unsigned char) *pm]))
|
if((flag = umode::table[(unsigned char) *pm]))
|
||||||
{
|
{
|
||||||
if(my_connect(*source_p)
|
if(my_connect(*source_p)
|
||||||
&& ((!is_oper(*source_p)
|
&& ((!is_oper(*source_p)
|
||||||
&& (ConfigFileEntry.oper_only_umodes & flag))
|
&& (ConfigFileEntry.oper_only_umodes & flag))))
|
||||||
|| (orphaned_umodes & flag)))
|
|
||||||
{
|
{
|
||||||
if (what == MODE_ADD || source_p->mode & flag)
|
if (what == MODE_ADD || source_p->mode & flag)
|
||||||
badflag = true;
|
badflag = true;
|
||||||
|
@ -1164,9 +1088,9 @@ user_mode(client::client *client_p, client::client *source_p, int parc, const ch
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(what == MODE_ADD)
|
if(what == MODE_ADD)
|
||||||
set(*source_p, umode(flag));
|
set(*source_p, flag);
|
||||||
else
|
else
|
||||||
clear(*source_p, umode(flag));
|
clear(*source_p, flag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1245,7 +1169,7 @@ send_umode(client::client *client_p, client::client *source_p, int old, char *um
|
||||||
|
|
||||||
for (i = 0; i < 128; i++)
|
for (i = 0; i < 128; i++)
|
||||||
{
|
{
|
||||||
flag = user_modes[i];
|
flag = umode::table[i];
|
||||||
|
|
||||||
if((flag & old) && !(source_p->mode & flag))
|
if((flag & old) && !(source_p->mode & flag))
|
||||||
{
|
{
|
||||||
|
@ -1322,7 +1246,13 @@ user_welcome(client::client *source_p)
|
||||||
sendto_one_numeric(source_p, RPL_YOURHOST, form_str(RPL_YOURHOST),
|
sendto_one_numeric(source_p, RPL_YOURHOST, form_str(RPL_YOURHOST),
|
||||||
get_listener_name(source_p->localClient->listener), info::version.c_str());
|
get_listener_name(source_p->localClient->listener), info::version.c_str());
|
||||||
sendto_one_numeric(source_p, RPL_CREATED, form_str(RPL_CREATED), info::compiled.c_str());
|
sendto_one_numeric(source_p, RPL_CREATED, form_str(RPL_CREATED), info::compiled.c_str());
|
||||||
sendto_one_numeric(source_p, RPL_MYINFO, form_str(RPL_MYINFO), me.name, info::version.c_str(), umodebuf, chan::mode::arity[0], chan::mode::arity[1]);
|
|
||||||
|
sendto_one_numeric(source_p, RPL_MYINFO, form_str(RPL_MYINFO),
|
||||||
|
me.name,
|
||||||
|
info::version.c_str(),
|
||||||
|
client::mode::available,
|
||||||
|
chan::mode::arity[0],
|
||||||
|
chan::mode::arity[1]);
|
||||||
|
|
||||||
supported::show(*source_p);
|
supported::show(*source_p);
|
||||||
|
|
||||||
|
@ -1355,17 +1285,15 @@ user_welcome(client::client *source_p)
|
||||||
void
|
void
|
||||||
oper_up(client::client *source_p, struct oper_conf *oper_p)
|
oper_up(client::client *source_p, struct oper_conf *oper_p)
|
||||||
{
|
{
|
||||||
using umode = client::mode::mode;
|
|
||||||
|
|
||||||
unsigned int old = source_p->mode, oldsnomask = source_p->snomask;
|
unsigned int old = source_p->mode, oldsnomask = source_p->snomask;
|
||||||
hook_data_umode_changed hdata;
|
hook_data_umode_changed hdata;
|
||||||
|
|
||||||
set_oper(*source_p);
|
set_oper(*source_p);
|
||||||
|
|
||||||
if(oper_p->umodes)
|
if(oper_p->umodes)
|
||||||
source_p->mode |= umode(oper_p->umodes);
|
source_p->mode |= oper_p->umodes;
|
||||||
else if(ConfigFileEntry.oper_umodes)
|
else if(ConfigFileEntry.oper_umodes)
|
||||||
source_p->mode |= umode(ConfigFileEntry.oper_umodes);
|
source_p->mode |= ConfigFileEntry.oper_umodes;
|
||||||
else
|
else
|
||||||
source_p->mode |= client::mode::DEFAULT_OPER_UMODES;
|
source_p->mode |= client::mode::DEFAULT_OPER_UMODES;
|
||||||
|
|
||||||
|
@ -1425,62 +1353,6 @@ oper_up(client::client *source_p, struct oper_conf *oper_p)
|
||||||
cache::motd::send_oper(*source_p);
|
cache::motd::send_oper(*source_p);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* find_umode_slot
|
|
||||||
*
|
|
||||||
* inputs - NONE
|
|
||||||
* outputs - an available umode bitmask or
|
|
||||||
* 0 if no umodes are available
|
|
||||||
* side effects - NONE
|
|
||||||
*/
|
|
||||||
unsigned int
|
|
||||||
find_umode_slot(void)
|
|
||||||
{
|
|
||||||
unsigned int all_umodes = 0, my_umode = 0, i;
|
|
||||||
|
|
||||||
for (i = 0; i < 128; i++)
|
|
||||||
all_umodes |= user_modes[i];
|
|
||||||
|
|
||||||
for (my_umode = 1; my_umode && (all_umodes & my_umode);
|
|
||||||
my_umode <<= 1);
|
|
||||||
|
|
||||||
return my_umode;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
construct_umodebuf(void)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
char *ptr = umodebuf;
|
|
||||||
static int prev_user_modes[128];
|
|
||||||
|
|
||||||
*ptr = '\0';
|
|
||||||
|
|
||||||
for (i = 0; i < 128; i++)
|
|
||||||
{
|
|
||||||
if (prev_user_modes[i] != 0 && prev_user_modes[i] != user_modes[i])
|
|
||||||
{
|
|
||||||
if (user_modes[i] == 0)
|
|
||||||
{
|
|
||||||
orphaned_umodes |= prev_user_modes[i];
|
|
||||||
sendto_realops_snomask(sno::DEBUG, L_ALL, "Umode +%c is now orphaned", i);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
orphaned_umodes &= ~prev_user_modes[i];
|
|
||||||
sendto_realops_snomask(sno::DEBUG, L_ALL, "Orphaned umode +%c is picked up by module", i);
|
|
||||||
}
|
|
||||||
user_modes[i] = prev_user_modes[i];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
prev_user_modes[i] = user_modes[i];
|
|
||||||
if (user_modes[i])
|
|
||||||
*ptr++ = (char) i;
|
|
||||||
}
|
|
||||||
|
|
||||||
*ptr++ = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
change_nick_user_host(client::client *target_p, const char *nick, const char *username,
|
change_nick_user_host(client::client *target_p, const char *nick, const char *username,
|
||||||
const char *host, int newts, const char *format, ...)
|
const char *host, int newts, const char *format, ...)
|
||||||
|
|
|
@ -1315,7 +1315,7 @@ sendto_wallops_flags(int flags, client::client *source_p, const char *pattern, .
|
||||||
{
|
{
|
||||||
client_p = (client::client *)ptr->data;
|
client_p = (client::client *)ptr->data;
|
||||||
|
|
||||||
if (is(*client_p, umode(flags)))
|
if (is(*client_p, flags))
|
||||||
_send_linebuf(client_p, &linebuf);
|
_send_linebuf(client_p, &linebuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -140,7 +140,7 @@ supported::init()
|
||||||
add("STATUSMSG", "@+");
|
add("STATUSMSG", "@+");
|
||||||
add("CALLERID", [](ostream &s)
|
add("CALLERID", [](ostream &s)
|
||||||
{
|
{
|
||||||
if(ConfigFileEntry.oper_only_umodes & user_modes['g'])
|
if(ConfigFileEntry.oper_only_umodes & umode::table['g'])
|
||||||
return;
|
return;
|
||||||
|
|
||||||
s << 'g';
|
s << 'g';
|
||||||
|
@ -162,7 +162,7 @@ supported::init()
|
||||||
|
|
||||||
add("DEAF", [](ostream &s)
|
add("DEAF", [](ostream &s)
|
||||||
{
|
{
|
||||||
if(ConfigFileEntry.oper_only_umodes & user_modes['D'])
|
if(ConfigFileEntry.oper_only_umodes & umode::table['D'])
|
||||||
return;
|
return;
|
||||||
|
|
||||||
s << 'D';
|
s << 'D';
|
||||||
|
|
|
@ -1044,7 +1044,7 @@ register_client(client::client &client, client::client *server,
|
||||||
m = &parv[4][1];
|
m = &parv[4][1];
|
||||||
while(*m)
|
while(*m)
|
||||||
{
|
{
|
||||||
flag = user_modes[(unsigned char) *m];
|
flag = umode::table[(unsigned char) *m];
|
||||||
|
|
||||||
if(flag & umode::SERVICE)
|
if(flag & umode::SERVICE)
|
||||||
{
|
{
|
||||||
|
@ -1075,7 +1075,7 @@ register_client(client::client &client, client::client *server,
|
||||||
if(!(source->mode & umode::OPER) && (flag & umode::OPER))
|
if(!(source->mode & umode::OPER) && (flag & umode::OPER))
|
||||||
Count.oper++;
|
Count.oper++;
|
||||||
|
|
||||||
source->mode |= umode(flag);
|
source->mode |= flag;
|
||||||
m++;
|
m++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -132,7 +132,7 @@ scan_umodes(struct MsgBuf *msgbuf_p, client::client &client, client::client &sou
|
||||||
what = MODE_DEL;
|
what = MODE_DEL;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if ((mode = user_modes[(unsigned char) *c]) != 0)
|
if ((mode = umode::table[(unsigned char) *c]) != 0)
|
||||||
{
|
{
|
||||||
if (what == MODE_ADD)
|
if (what == MODE_ADD)
|
||||||
allowed_umodes |= mode;
|
allowed_umodes |= mode;
|
||||||
|
@ -236,7 +236,7 @@ scan_umodes(struct MsgBuf *msgbuf_p, client::client &client, client::client &sou
|
||||||
|
|
||||||
for (i = 0; i < 128; i++)
|
for (i = 0; i < 128; i++)
|
||||||
{
|
{
|
||||||
if (is(*target_p, umode(user_modes[i])))
|
if (is(*target_p, umode::table[i]))
|
||||||
*m++ = (char) i;
|
*m++ = (char) i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue