X-Git-Url: https://jfr.im/git/solanum.git/blobdiff_plain/041d07b3d08d8000d4d0c9c7df3c723f47b0d8e8..81e41406f4027dfef50dcd5ef33403661bea5995:/extensions/m_sendbans.c diff --git a/extensions/m_sendbans.c b/extensions/m_sendbans.c index f8829a08..a6e15512 100644 --- a/extensions/m_sendbans.c +++ b/extensions/m_sendbans.c @@ -31,7 +31,6 @@ #include "stdinc.h" #include "client.h" -#include "common.h" #include "ircd.h" #include "match.h" #include "numeric.h" @@ -42,11 +41,16 @@ #include "msg.h" #include "hash.h" #include "modules.h" +#include "messages.h" +#include "rb_radixtree.h" -static int mo_sendbans(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]); +static const char sendbands_desc[] = + "Adds the ability to send all permanent RESVs and XLINEs to given server"; + +static void mo_sendbans(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]); struct Message sendbans_msgtab = { - "SENDBANS", 0, 0, 0, MFLG_SLOW, + "SENDBANS", 0, 0, 0, 0, {mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_sendbans, 2}} }; @@ -55,7 +59,7 @@ mapi_clist_av1 sendbans_clist[] = { NULL }; -DECLARE_MODULE_AV1(sendbans, NULL, NULL, sendbans_clist, NULL, NULL, "$Revision$"); +DECLARE_MODULE_AV2(sendbans, NULL, NULL, sendbans_clist, NULL, NULL, NULL, NULL, sendbands_desc); static const char *expand_xline(const char *mask) { @@ -81,31 +85,33 @@ static const char *expand_xline(const char *mask) return buf; } -static int mo_sendbans(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) +static void +mo_sendbans(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) { struct ConfItem *aconf; rb_dlink_node *ptr; - int i, count; + int count; const char *target, *mask2; struct Client *server_p; + struct rb_radixtree_iteration_state state; if (!IsOperRemoteBan(source_p)) { sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "remoteban"); - return 0; + return; } if (!IsOperXline(source_p)) { sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "xline"); - return 0; + return; } if (!IsOperResv(source_p)) { sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "resv"); - return 0; + return; } target = parv[1]; @@ -122,12 +128,13 @@ static int mo_sendbans(struct Client *client_p, struct Client *source_p, int par { sendto_one_numeric(source_p, ERR_NOSUCHSERVER, form_str(ERR_NOSUCHSERVER), target); - return 0; + return; } sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, - "%s is sending resvs and xlines to %s", - get_oper_name(source_p), target); + "%s!%s@%s is sending resvs and xlines to %s", + source_p->name, source_p->username, source_p->host, + target); RB_DLINK_FOREACH(ptr, resv_conf_list.head) { @@ -137,31 +144,29 @@ static int mo_sendbans(struct Client *client_p, struct Client *source_p, int par sendto_match_servs(source_p, target, CAP_ENCAP, NOCAPS, "ENCAP %s RESV 0 %s 0 :%s", - target, aconf->name, aconf->passwd); + target, aconf->host, aconf->passwd); } - HASH_WALK(i, R_MAX, ptr, resvTable) + RB_RADIXTREE_FOREACH(aconf, &state, resv_tree) { - aconf = ptr->data; if (aconf->hold) continue; sendto_match_servs(source_p, target, CAP_ENCAP, NOCAPS, "ENCAP %s RESV 0 %s 0 :%s", - target, aconf->name, aconf->passwd); + target, aconf->host, aconf->passwd); } - HASH_WALK_END RB_DLINK_FOREACH(ptr, xline_conf_list.head) { aconf = ptr->data; if (aconf->hold) continue; - mask2 = expand_xline(aconf->name); + mask2 = expand_xline(aconf->host); if (mask2 == NULL) { sendto_one_notice(source_p, ":Skipping xline [%s]", - aconf->name); + aconf->host); continue; } sendto_match_servs(source_p, target, @@ -169,6 +174,4 @@ static int mo_sendbans(struct Client *client_p, struct Client *source_p, int par "ENCAP %s XLINE 0 %s 2 :%s", target, mask2, aconf->passwd); } - - return 0; }