@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2019 ircd-hybrid development team
* Copyright (c) 1997-2020 ircd-hybrid development team
*
* 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
@@ -83,7 +83,7 @@ server_set_flags(struct Client *client_p, const char *flags)
* server is CAPAB_TBURST capable
*/
static void
server_send_tburst(struct Client *client_p, const struct Channel *chptr)
server_send_tburst(struct Client *client_p, const struct Channel *channel)
{
/*
* We may also send an empty topic here, but only if topic_time isn't 0,
@@ -98,12 +98,12 @@ server_send_tburst(struct Client *client_p, const struct Channel *chptr)
* it to their old topic they had before. Read m_tburst.c:ms_tburst
* for further information -Michael
*/
if (chptr->topic_time)
if (channel->topic_time)
sendto_one(client_p, ":%s TBURST %ju %s %ju %s :%s", me.id,
chptr->creationtime, chptr->name,
chptr->topic_time,
chptr->topic_info,
chptr->topic);
channel->creation_time, channel->name,
channel->topic_time,
channel->topic_info,
channel->topic);
}

/* sendnick_TS()
@@ -190,14 +190,14 @@ server_burst(struct Client *client_p)

DLINK_FOREACH(node, channel_get_list()->head)
{
const struct Channel *chptr = node->data;
const struct Channel *channel = node->data;

if (dlink_list_length(&chptr->members))
if (dlink_list_length(&channel->members))
{
channel_send_modes(client_p, chptr);
channel_send_modes(client_p, channel);

if (IsCapable(client_p, CAPAB_TBURST))
server_send_tburst(client_p, chptr);
server_send_tburst(client_p, channel);
}
}

@@ -214,22 +214,6 @@ server_burst(struct Client *client_p)
static void
server_estab(struct Client *client_p)
{
struct MaskItem *conf = NULL;
dlink_node *node = NULL;

if ((conf = find_conf_name(&client_p->connection->confs, client_p->name, CONF_SERVER)) == NULL)
{
/* This shouldn't happen, better tell the ops... -A1kmm */
sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE,
"Warning: lost connect{} block for %s",
client_get_name(client_p, SHOW_IP));
sendto_realops_flags(UMODE_SERVNOTICE, L_OPER, SEND_NOTICE,
"Warning: lost connect{} block for %s",
client_get_name(client_p, MASK_IP));
exit_client(client_p, "Lost connect{} block!");
return;
}

xfree(client_p->connection->password);
client_p->connection->password = NULL;

@@ -242,6 +226,8 @@ server_estab(struct Client *client_p)

if (IsUnknown(client_p))
{
const struct MaskItem *const conf = client_p->connection->confs.head->data;

sendto_one(client_p, "PASS %s TS %u %s", conf->spasswd, TS_CURRENT, me.id);

sendto_one(client_p, "CAPAB :%s", capab_get(NULL));
@@ -287,21 +273,21 @@ server_estab(struct Client *client_p)
AddFlag(client_p, FLAGS_SERVICE);

/* Show the real host/IP to admins */
if (tls_isusing(&client_p->connection->fd->ssl))
if (tls_isusing(&client_p->connection->fd->tls))
{
/* Show the real host/IP to admins */
sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE,
"Link with %s established: [TLS: %s] (Capabilities: %s)",
client_get_name(client_p, SHOW_IP), tls_get_cipher(&client_p->connection->fd->ssl),
client_get_name(client_p, SHOW_IP), tls_get_cipher(&client_p->connection->fd->tls),
capab_get(client_p));

/* Now show the masked hostname/IP to opers */
sendto_realops_flags(UMODE_SERVNOTICE, L_OPER, SEND_NOTICE,
"Link with %s established: [TLS: %s] (Capabilities: %s)",
client_get_name(client_p, MASK_IP), tls_get_cipher(&client_p->connection->fd->ssl),
client_get_name(client_p, MASK_IP), tls_get_cipher(&client_p->connection->fd->tls),
capab_get(client_p));
ilog(LOG_TYPE_IRCD, "Link with %s established: [TLS: %s] (Capabilities: %s)",
client_get_name(client_p, SHOW_IP), tls_get_cipher(&client_p->connection->fd->ssl),
client_get_name(client_p, SHOW_IP), tls_get_cipher(&client_p->connection->fd->tls),
capab_get(client_p));
}
else
@@ -338,6 +324,7 @@ server_estab(struct Client *client_p)
* up connection this other fragment at the same time, it's
* a race condition, not the normal way of operation...
*/
dlink_node *node;
DLINK_FOREACH_PREV(node, global_server_list.tail)
{
struct Client *target_p = node->data;
@@ -396,7 +383,7 @@ server_set_gecos(struct Client *client_p, const char *info)
enum
{
SERVER_CHECK_OK = 0,
SERVER_CHECK_NOCONNECT = -1,
SERVER_CHECK_CONNECT_NOT_FOUND = -1,
SERVER_CHECK_INVALID_PASSWORD = -2,
SERVER_CHECK_INVALID_HOST = -3,
SERVER_CHECK_INVALID_CERTIFICATE = -4,
@@ -406,8 +393,7 @@ static int
server_check(const char *name, struct Client *client_p)
{
dlink_node *node;
struct MaskItem *server_conf = NULL;
int error = SERVER_CHECK_NOCONNECT;
int error = SERVER_CHECK_CONNECT_NOT_FOUND;

assert(client_p);

@@ -431,16 +417,12 @@ server_check(const char *name, struct Client *client_p)
if (EmptyString(client_p->certfp) || strcasecmp(client_p->certfp, conf->certfp))
return SERVER_CHECK_INVALID_CERTIFICATE;

server_conf = conf;
conf_attach(client_p, conf);
return SERVER_CHECK_OK;
}
}

if (server_conf == NULL)
return error;

conf_attach(client_p, server_conf);

return SERVER_CHECK_OK;
return error;
}

/* mr_server()
@@ -457,19 +439,18 @@ server_check(const char *name, struct Client *client_p)
* parv[4] = string of flags starting with '+'
* parv[5] = serverinfo
*/
static int
static void
mr_server(struct Client *source_p, int parc, char *parv[])
{
const char *name = parv[1];
const char *sid = parc == 6 ? parv[3] : source_p->id; /* TBR: compatibility 'mode' */
struct Client *target_p = NULL;
const char *error = NULL;
bool warn = true;

if (EmptyString(parv[parc - 1]))
{
exit_client(source_p, "No server description supplied");
return 0;
return;
}

if (server_valid_name(name) == false)
@@ -481,7 +462,7 @@ mr_server(struct Client *source_p, int parc, char *parv[])
"Unauthorized server connection attempt from %s: Bogus server name "
"for server %s", client_get_name(source_p, MASK_IP), name);
exit_client(source_p, "Bogus server name");
return 0;
return;
}

if (valid_sid(sid) == false)
@@ -493,7 +474,19 @@ mr_server(struct Client *source_p, int parc, char *parv[])
"Link %s introduced server with bogus server ID %s",
client_get_name(source_p, MASK_IP), sid);
exit_client(source_p, "Bogus server ID introduced");
return 0;
return;
}

if (IsHandshake(source_p) && irccmp(source_p->name, name))
{
sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE,
"Link %s introduced server with mismatching server name %s",
client_get_name(source_p, SHOW_IP), name);
sendto_realops_flags(UMODE_SERVNOTICE, L_OPER, SEND_NOTICE,
"Link %s introduced server with mismatching server name %s",
client_get_name(source_p, MASK_IP), name);
exit_client(source_p, "Mismatching server name introduced");
return;
}

/*
@@ -502,7 +495,7 @@ mr_server(struct Client *source_p, int parc, char *parv[])
*/
switch (server_check(name, source_p))
{
case SERVER_CHECK_NOCONNECT:
case SERVER_CHECK_CONNECT_NOT_FOUND:
error = "No connect {} block";
warn = ConfigGeneral.warn_no_connect_block != 0;
break;
@@ -530,9 +523,10 @@ mr_server(struct Client *source_p, int parc, char *parv[])
}

exit_client(source_p, error);
return 0;
return;
}

struct Client *target_p;
if ((target_p = hash_find_server(name)))
{
/* This link is trying feed me a server that I already have
@@ -552,7 +546,7 @@ mr_server(struct Client *source_p, int parc, char *parv[])
"Attempt to re-introduce server %s from %s",
name, client_get_name(source_p, MASK_IP));
exit_client(source_p, "Server already exists");
return 0;
return;
}

if ((target_p = hash_find_id(source_p->id)))
@@ -566,7 +560,7 @@ mr_server(struct Client *source_p, int parc, char *parv[])
name, source_p->id,
client_get_name(source_p, MASK_IP));
exit_client(source_p, "Server ID already exists");
return 0;
return;
}

/* XXX If somehow there is a connect in progress and
@@ -593,7 +587,6 @@ mr_server(struct Client *source_p, int parc, char *parv[])

source_p->hopcount = atoi(parv[2]);
server_estab(source_p);
return 0;
}

/* ms_sid()
@@ -611,19 +604,17 @@ mr_server(struct Client *source_p, int parc, char *parv[])
* parv[4] = string of flags starting with '+'
* parv[5] = serverinfo
*/
static int
static void
ms_sid(struct Client *source_p, int parc, char *parv[])
{
struct Client *target_p = NULL;

/* Just to be sure -A1kmm. */
if (!IsServer(source_p))
return 0;
return;

if (EmptyString(parv[parc - 1]))
{
exit_client(source_p->from, "No server description supplied");
return 0;
return;
}

if (server_valid_name(parv[1]) == false)
@@ -635,7 +626,7 @@ ms_sid(struct Client *source_p, int parc, char *parv[])
"Link %s introduced server with bogus server name %s",
client_get_name(source_p->from, MASK_IP), parv[1]);
exit_client(source_p->from, "Bogus server name introduced");
return 0;
return;
}

if (valid_sid(parv[3]) == false)
@@ -647,10 +638,11 @@ ms_sid(struct Client *source_p, int parc, char *parv[])
"Link %s introduced server with bogus server ID %s",
client_get_name(source_p->from, MASK_IP), parv[3]);
exit_client(source_p->from, "Bogus server ID introduced");
return 0;
return;
}

/* collision on SID? */
struct Client *target_p;
if ((target_p = hash_find_id(parv[3])))
{
sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE,
@@ -660,7 +652,7 @@ ms_sid(struct Client *source_p, int parc, char *parv[])
"Link %s cancelled, server ID %s already exists",
client_get_name(source_p->from, MASK_IP), parv[3]);
exit_client(source_p->from, "Link cancelled, server ID already exists");
return 0;
return;
}

/* collision on name? */
@@ -673,7 +665,7 @@ ms_sid(struct Client *source_p, int parc, char *parv[])
"Link %s cancelled, server %s already exists",
client_get_name(source_p->from, MASK_IP), parv[1]);
exit_client(source_p->from, "Server exists");
return 0;
return;
}

/* XXX If somehow there is a connect in progress and
@@ -745,7 +737,7 @@ ms_sid(struct Client *source_p, int parc, char *parv[])
"Non-Hub link %s introduced %s.",
client_get_name(source_p->from, MASK_IP), parv[1]);
exit_client(source_p, "No matching hub_mask.");
return 0;
return;
}

/* Check for the new server being leafed behind this HUB */
@@ -759,7 +751,7 @@ ms_sid(struct Client *source_p, int parc, char *parv[])
"Link %s introduced leafed server %s.",
client_get_name(source_p->from, MASK_IP), parv[1]);
exit_client(source_p->from, "Leafed server.");
return 0;
return;
}

target_p = client_make(source_p->from);
@@ -795,7 +787,6 @@ ms_sid(struct Client *source_p, int parc, char *parv[])
sendto_realops_flags(UMODE_EXTERNAL, L_ALL, SEND_NOTICE,
"Server %s being introduced by %s",
target_p->name, source_p->name);
return 0;
}

static struct Message server_msgtab =
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2019 ircd-hybrid development team
* Copyright (c) 1997-2020 ircd-hybrid development team
*
* 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
@@ -59,10 +59,10 @@ static void remove_ban_list(struct Channel *, struct Client *, dlink_list *, cha
* incoming modes or undo the existing ones or merge them, and JOIN
* all the specified users while sending JOIN/MODEs to local clients
*/
static int
static void
ms_sjoin(struct Client *source_p, int parc, char *parv[])
{
struct Channel *chptr = NULL;
struct Channel *channel = NULL;
struct Client *target_p = NULL;
uintmax_t newts;
uintmax_t oldts;
@@ -94,14 +94,14 @@ ms_sjoin(struct Client *source_p, int parc, char *parv[])
unsigned int pargs = 0;

if (!IsServer(source_p))
return 0;
return;

if (channel_check_name(parv[2], false) == false)
{
sendto_realops_flags(UMODE_DEBUG, L_ALL, SEND_NOTICE,
"*** Too long or invalid channel name from %s(via %s): %s",
source_p->name, source_p->from->name, parv[2]);
return 0;
return;
}

pargs = 0;
@@ -120,15 +120,15 @@ ms_sjoin(struct Client *source_p, int parc, char *parv[])
++args;

if (parc < 5 + args)
return 0;
return;
break;

case 'l':
mode.limit = atoi(parv[4 + args]);
++args;

if (parc < 5 + args)
return 0;
return;
break;

default:
@@ -142,35 +142,35 @@ ms_sjoin(struct Client *source_p, int parc, char *parv[])
}
}

if ((chptr = hash_find_channel(parv[2])) == NULL)
if ((channel = hash_find_channel(parv[2])) == NULL)
{
isnew = true;
chptr = channel_make(parv[2]);
channel = channel_make(parv[2]);
}

oldts = chptr->creationtime;
oldmode = &chptr->mode;
oldts = channel->creation_time;
oldmode = &channel->mode;

if (newts == 0 && isnew == false && oldts)
{
sendto_channel_local(NULL, chptr, 0, 0, 0,
sendto_channel_local(NULL, channel, 0, 0, 0,
":%s NOTICE %s :*** Notice -- TS for %s changed from %ju to 0",
me.name, chptr->name, chptr->name, oldts);
me.name, channel->name, channel->name, oldts);
sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE,
"Server %s changing TS on %s from %ju to 0",
source_p->name, chptr->name, oldts);
source_p->name, channel->name, oldts);
}

if (isnew == true)
chptr->creationtime = tstosend = newts;
channel->creation_time = tstosend = newts;
else if (newts == 0 || oldts == 0)
chptr->creationtime = tstosend = 0;
channel->creation_time = tstosend = 0;
else if (newts == oldts)
tstosend = oldts;
else if (newts < oldts)
{
keep_our_modes = false;
chptr->creationtime = tstosend = newts;
channel->creation_time = tstosend = newts;
}
else
{
@@ -191,49 +191,49 @@ ms_sjoin(struct Client *source_p, int parc, char *parv[])
}

set_final_mode(&mode, oldmode, modebuf, parabuf);
chptr->mode = mode;
channel->mode = mode;

/* Lost the TS, other side wins, so remove modes on this side */
if (keep_our_modes == false)
{
/* Update channel name to be the correct case */
if (isnew == false)
strlcpy(chptr->name, parv[2], sizeof(chptr->name));
strlcpy(channel->name, parv[2], sizeof(channel->name));

remove_our_modes(chptr, source_p);
remove_our_modes(channel, source_p);

remove_ban_list(chptr, source_p, &chptr->banlist, 'b');
remove_ban_list(chptr, source_p, &chptr->exceptlist, 'e');
remove_ban_list(chptr, source_p, &chptr->invexlist, 'I');
remove_ban_list(channel, source_p, &channel->banlist, 'b');
remove_ban_list(channel, source_p, &channel->exceptlist, 'e');
remove_ban_list(channel, source_p, &channel->invexlist, 'I');

clear_ban_cache_list(&chptr->members_local);
clear_invite_list(&chptr->invites);
clear_ban_cache_list(&channel->members_local);
clear_invite_list(&channel->invites);

if (chptr->topic[0])
if (channel->topic[0])
{
channel_set_topic(chptr, "", "", 0, false);
sendto_channel_local(NULL, chptr, 0, 0, 0, ":%s TOPIC %s :",
channel_set_topic(channel, "", "", 0, false);
sendto_channel_local(NULL, channel, 0, 0, 0, ":%s TOPIC %s :",
(IsHidden(source_p) ||
ConfigServerHide.hide_servers) ?
me.name : source_p->name, chptr->name);
me.name : source_p->name, channel->name);
}

sendto_channel_local(NULL, chptr, 0, 0, 0,
sendto_channel_local(NULL, channel, 0, 0, 0,
":%s NOTICE %s :*** Notice -- TS for %s changed from %ju to %ju",
me.name, chptr->name, chptr->name,
me.name, channel->name, channel->name,
oldts, newts);
}

if (*modebuf)
{
/* This _SHOULD_ be to ALL_MEMBERS
* It contains only +imnpstlk, etc */
sendto_channel_local(NULL, chptr, 0, 0, 0, ":%s MODE %s %s %s",
servername, chptr->name, modebuf, parabuf);
sendto_channel_local(NULL, channel, 0, 0, 0, ":%s MODE %s %s %s",
servername, channel->name, modebuf, parabuf);
}

if (*parv[3] != '0' && keep_new_modes == true)
channel_modes(chptr, source_p, modebuf, parabuf);
channel_modes(channel, source_p, modebuf, parabuf);
else
{
modebuf[0] = '0';
@@ -242,7 +242,7 @@ ms_sjoin(struct Client *source_p, int parc, char *parv[])

buflen = snprintf(uid_buf, sizeof(uid_buf), ":%s SJOIN %ju %s %s %s:",
source_p->id, tstosend,
chptr->name, modebuf, parabuf);
channel->name, modebuf, parabuf);
uid_ptr = uid_buf + buflen;

/*
@@ -254,7 +254,7 @@ ms_sjoin(struct Client *source_p, int parc, char *parv[])
sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE,
"Long SJOIN from server: %s(via %s) (ignored)",
source_p->name, source_p->from->name);
return 0;
return;
}

char *mbuf = modebuf;
@@ -343,25 +343,25 @@ ms_sjoin(struct Client *source_p, int parc, char *parv[])

buflen = snprintf(uid_buf, sizeof(uid_buf), ":%s SJOIN %ju %s %s %s:",
source_p->id, tstosend,
chptr->name, modebuf, parabuf);
channel->name, modebuf, parabuf);
uid_ptr = uid_buf + buflen;
}

uid_ptr += sprintf(uid_ptr, "%s%s ", uid_prefix, target_p->id);

if (!IsMember(target_p, chptr))
if (!IsMember(target_p, channel))
{
add_user_to_channel(chptr, target_p, fl, have_many_uids == false);
add_user_to_channel(channel, target_p, fl, have_many_uids == false);

sendto_channel_local(NULL, chptr, 0, CAP_EXTENDED_JOIN, 0, ":%s!%s@%s JOIN %s %s :%s",
sendto_channel_local(NULL, channel, 0, CAP_EXTENDED_JOIN, 0, ":%s!%s@%s JOIN %s %s :%s",
target_p->name, target_p->username,
target_p->host, chptr->name, target_p->account, target_p->info);
sendto_channel_local(NULL, chptr, 0, 0, CAP_EXTENDED_JOIN, ":%s!%s@%s JOIN :%s",
target_p->host, channel->name, target_p->account, target_p->info);
sendto_channel_local(NULL, channel, 0, 0, CAP_EXTENDED_JOIN, ":%s!%s@%s JOIN :%s",
target_p->name, target_p->username,
target_p->host, chptr->name);
target_p->host, channel->name);

if (target_p->away[0])
sendto_channel_local(target_p, chptr, 0, CAP_AWAY_NOTIFY, 0,
sendto_channel_local(target_p, channel, 0, CAP_AWAY_NOTIFY, 0,
":%s!%s@%s AWAY :%s",
target_p->name, target_p->username,
target_p->host, target_p->away);
@@ -392,8 +392,8 @@ ms_sjoin(struct Client *source_p, int parc, char *parv[])
sptr += slen; /* ready for next */
}

sendto_channel_local(NULL, chptr, 0, 0, 0, ":%s MODE %s %s%s",
servername, chptr->name, modebuf, sendbuf);
sendto_channel_local(NULL, channel, 0, 0, 0, ":%s MODE %s %s%s",
servername, channel->name, modebuf, sendbuf);
mbuf = modebuf;
*mbuf++ = '+';

@@ -418,8 +418,8 @@ ms_sjoin(struct Client *source_p, int parc, char *parv[])
sptr += slen;
}

sendto_channel_local(NULL, chptr, 0, 0, 0, ":%s MODE %s %s%s",
servername, chptr->name, modebuf, sendbuf);
sendto_channel_local(NULL, channel, 0, 0, 0, ":%s MODE %s %s%s",
servername, channel->name, modebuf, sendbuf);

mbuf = modebuf;
*mbuf++ = '+';
@@ -445,8 +445,8 @@ ms_sjoin(struct Client *source_p, int parc, char *parv[])
sptr += slen;
}

sendto_channel_local(NULL, chptr, 0, 0, 0, ":%s MODE %s %s%s",
servername, chptr->name, modebuf, sendbuf);
sendto_channel_local(NULL, channel, 0, 0, 0, ":%s MODE %s %s%s",
servername, channel->name, modebuf, sendbuf);

mbuf = modebuf;
*mbuf++ = '+';
@@ -493,8 +493,8 @@ ms_sjoin(struct Client *source_p, int parc, char *parv[])
sptr += slen;
}

sendto_channel_local(NULL, chptr, 0, 0, 0, ":%s MODE %s %s%s",
servername, chptr->name, modebuf, sendbuf);
sendto_channel_local(NULL, channel, 0, 0, 0, ":%s MODE %s %s%s",
servername, channel->name, modebuf, sendbuf);
}

/*
@@ -504,17 +504,16 @@ ms_sjoin(struct Client *source_p, int parc, char *parv[])
* and leaving us with a channel formed just as the client parts.
* - Dianora
*/
if (dlink_list_length(&chptr->members) == 0 && isnew == true)
if (dlink_list_length(&channel->members) == 0 && isnew == true)
{
channel_free(chptr);
return 0;
channel_free(channel);
return;
}

if (*parv[4 + args] == '\0')
return 0;
return;

sendto_server(source_p, 0, 0, "%s", uid_buf);
return 0;
}

/* set_final_mode
@@ -586,11 +585,11 @@ set_final_mode(struct Mode *mode, struct Mode *oldmode, char *mbuf, char *pbuf)
* chanop modes etc., this side lost the TS.
*/
static void
remove_our_modes(struct Channel *chptr, struct Client *source_p)
remove_our_modes(struct Channel *channel, struct Client *source_p)
{
remove_a_mode(chptr, source_p, CHFL_CHANOP, 'o');
remove_a_mode(chptr, source_p, CHFL_HALFOP, 'h');
remove_a_mode(chptr, source_p, CHFL_VOICE, 'v');
remove_a_mode(channel, source_p, CHFL_CHANOP, 'o');
remove_a_mode(channel, source_p, CHFL_HALFOP, 'h');
remove_a_mode(channel, source_p, CHFL_VOICE, 'v');
}

/* remove_a_mode()
@@ -603,7 +602,7 @@ remove_our_modes(struct Channel *chptr, struct Client *source_p)
* side effects - remove ONE mode from all members of a channel
*/
static void
remove_a_mode(struct Channel *chptr, struct Client *source_p,
remove_a_mode(struct Channel *channel, struct Client *source_p,
int mask, char flag)
{
dlink_node *node = NULL;
@@ -618,16 +617,16 @@ remove_a_mode(struct Channel *chptr, struct Client *source_p,
*mbuf++ = '-';
*sp = '\0';

DLINK_FOREACH(node, chptr->members.head)
DLINK_FOREACH(node, channel->members.head)
{
struct Membership *member = node->data;
struct ChannelMember *member = node->data;

if ((member->flags & mask) == 0)
continue;

member->flags &= ~mask;

lpara[count++] = member->client_p->name;
lpara[count++] = member->client->name;

*mbuf++ = flag;

@@ -640,10 +639,10 @@ remove_a_mode(struct Channel *chptr, struct Client *source_p,
}

*mbuf = '\0';
sendto_channel_local(NULL, chptr, 0, 0, 0, ":%s MODE %s %s%s",
sendto_channel_local(NULL, channel, 0, 0, 0, ":%s MODE %s %s%s",
(IsHidden(source_p) || ConfigServerHide.hide_servers) ?
me.name : source_p->name,
chptr->name, lmodebuf, sendbuf);
channel->name, lmodebuf, sendbuf);
mbuf = lmodebuf;
*mbuf++ = '-';
count = 0;
@@ -662,10 +661,10 @@ remove_a_mode(struct Channel *chptr, struct Client *source_p,
sp += l;
}

sendto_channel_local(NULL, chptr, 0, 0, 0, ":%s MODE %s %s%s",
sendto_channel_local(NULL, channel, 0, 0, 0, ":%s MODE %s %s%s",
(IsHidden(source_p) || ConfigServerHide.hide_servers) ?
me.name : source_p->name,
chptr->name, lmodebuf, sendbuf);
channel->name, lmodebuf, sendbuf);
}
}

@@ -676,7 +675,7 @@ remove_a_mode(struct Channel *chptr, struct Client *source_p,
* side effects - given ban list is removed, modes are sent to local clients
*/
static void
remove_ban_list(struct Channel *chptr, struct Client *source_p, dlink_list *list, char c)
remove_ban_list(struct Channel *channel, struct Client *source_p, dlink_list *list, char c)
{
dlink_node *node, *node_next;
char modebuf[IRCD_BUFSIZE];
@@ -690,7 +689,7 @@ remove_ban_list(struct Channel *chptr, struct Client *source_p, dlink_list *list
return;

cur_len = mlen = snprintf(modebuf, sizeof(modebuf), ":%s MODE %s -",
source_p->name, chptr->name);
source_p->name, channel->name);
mbuf = modebuf + mlen;
pbuf = parabuf;

@@ -704,7 +703,7 @@ remove_ban_list(struct Channel *chptr, struct Client *source_p, dlink_list *list
{
/* NUL-terminate and remove trailing space */
*mbuf = *(pbuf - 1) = '\0';
sendto_channel_local(NULL, chptr, 0, 0, 0, "%s %s", modebuf, parabuf);
sendto_channel_local(NULL, channel, 0, 0, 0, "%s %s", modebuf, parabuf);

cur_len = mlen;
mbuf = modebuf + mlen;
@@ -721,7 +720,7 @@ remove_ban_list(struct Channel *chptr, struct Client *source_p, dlink_list *list
}

*mbuf = *(pbuf - 1) = '\0';
sendto_channel_local(NULL, chptr, 0, 0, 0, "%s %s", modebuf, parabuf);
sendto_channel_local(NULL, channel, 0, 0, 0, "%s %s", modebuf, parabuf);
}

static struct Message sjoin_msgtab =
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2019 ircd-hybrid development team
* Copyright (c) 1997-2020 ircd-hybrid development team
*
* 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
@@ -51,7 +51,7 @@
* - parv[1] = server name
* - parv[2] = comment
*/
static int
static void
mo_squit(struct Client *source_p, int parc, char *parv[])
{
char comment[REASONLEN + 1] = "";
@@ -61,7 +61,7 @@ mo_squit(struct Client *source_p, int parc, char *parv[])
if (parc < 2 || EmptyString(parv[1]))
{
sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, "SQUIT");
return 0;
return;
}

/* The following allows wild cards in SQUIT. */
@@ -83,19 +83,19 @@ mo_squit(struct Client *source_p, int parc, char *parv[])
if (target_p == NULL || IsMe(target_p))
{
sendto_one_numeric(source_p, &me, ERR_NOSUCHSERVER, server);
return 0;
return;
}

if (!MyConnect(target_p) && !HasOFlag(source_p, OPER_FLAG_SQUIT_REMOTE))
{
sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "squit:remote");
return 0;
return;
}

if (MyConnect(target_p) && !HasOFlag(source_p, OPER_FLAG_SQUIT))
{
sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "squit");
return 0;
return;
}

if (EmptyString(parv[2]))
@@ -126,7 +126,6 @@ mo_squit(struct Client *source_p, int parc, char *parv[])
AddFlag(target_p, FLAGS_SQUIT);

exit_client(target_p, comment);
return 0;
}

/*! \brief SQUIT command handler
@@ -141,20 +140,20 @@ mo_squit(struct Client *source_p, int parc, char *parv[])
* - parv[1] = server name
* - parv[2] = comment
*/
static int
static void
ms_squit(struct Client *source_p, int parc, char *parv[])
{
struct Client *target_p = NULL;
const char *comment = NULL;

if (parc < 2 || EmptyString(parv[1]))
return 0;
return;

if ((target_p = hash_find_server(parv[1])) == NULL)
return 0;
return;

if (!IsServer(target_p) && !IsMe(target_p))
return 0;
return;

if (IsMe(target_p))
target_p = source_p->from;
@@ -194,7 +193,6 @@ ms_squit(struct Client *source_p, int parc, char *parv[])
AddFlag(target_p, FLAGS_SQUIT);

exit_client(target_p, comment);
return 0;
}

static struct Message squit_msgtab =
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2019 ircd-hybrid development team
* Copyright (c) 1997-2020 ircd-hybrid development team
*
* 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
@@ -49,24 +49,23 @@
* - parv[2] = channel name
* - parv[3] = modes to be added or removed
*/
static int
static void
ms_tmode(struct Client *source_p, int parc, char *parv[])
{
struct Channel *chptr;
struct Channel *channel;

assert(!MyClient(source_p));

if ((chptr = hash_find_channel(parv[2])) == NULL)
if ((channel = hash_find_channel(parv[2])) == NULL)
{
sendto_one_numeric(source_p, &me, ERR_NOSUCHCHANNEL, parv[2]);
return 0;
return;
}

if (strtoumax(parv[1], NULL, 10) > chptr->creationtime)
return 0;
if (strtoumax(parv[1], NULL, 10) > channel->creation_time)
return;

channel_mode_set(source_p, chptr, NULL, parc - 3, parv + 3);
return 0;
channel_mode_set(source_p, channel, NULL, parc - 3, parv + 3);
}

static struct Message tmode_msgtab =
@@ -96,9 +96,8 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_append_compile_flags.m4 \
$(top_srcdir)/m4/ax_arg_enable_debugging.m4 \
$(top_srcdir)/m4/ax_arg_enable_efence.m4 \
$(top_srcdir)/m4/ax_arg_enable_warnings.m4 \
$(top_srcdir)/m4/ax_arg_gnutls.m4 \
$(top_srcdir)/m4/ax_arg_ioloop_mechanism.m4 \
$(top_srcdir)/m4/ax_arg_openssl.m4 \
$(top_srcdir)/m4/ax_arg_with_tls.m4 \
$(top_srcdir)/m4/ax_check_compile_flag.m4 \
$(top_srcdir)/m4/ax_define_dir.m4 \
$(top_srcdir)/m4/ax_gcc_stack_protect.m4 \
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 2014-2019 ircd-hybrid development team
* Copyright (c) 2014-2020 ircd-hybrid development team
*
* 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
@@ -50,61 +50,60 @@
* - parv[0] = command
* - parv[1] = channel name
*/
static int
static void
mo_opme(struct Client *source_p, int parc, char *parv[])
{
const char *const name = parv[1];
struct Channel *chptr = NULL;
struct Membership *member = NULL;
struct Channel *channel = NULL;
struct ChannelMember *member = NULL;
dlink_node *node = NULL;

if (EmptyString(name))
{
sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, "OPME");
return 0;
return;
}

if (!HasOFlag(source_p, OPER_FLAG_OPME))
{
sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "opme");
return 0;
return;
}

if ((chptr = hash_find_channel(name)) == NULL)
if ((channel = hash_find_channel(name)) == NULL)
{
sendto_one_numeric(source_p, &me, ERR_NOSUCHCHANNEL, name);
return 0;
return;
}

if ((member = find_channel_link(source_p, chptr)) == NULL)
if ((member = find_channel_link(source_p, channel)) == NULL)
{
sendto_one_numeric(source_p, &me, ERR_NOTONCHANNEL, chptr->name);
return 0;
sendto_one_numeric(source_p, &me, ERR_NOTONCHANNEL, channel->name);
return;
}

DLINK_FOREACH(node, chptr->members.head)
DLINK_FOREACH(node, channel->members.head)
{
if (((struct Membership *)node->data)->flags & CHFL_CHANOP)
if (((struct ChannelMember *)node->data)->flags & CHFL_CHANOP)
{
sendto_one_notice(source_p, &me, ":Cannot use OPME on %s: channel is not opless",
chptr->name);
return 0;
channel->name);
return;
}
}

ilog(LOG_TYPE_IRCD, "%s used OPME on channel %s",
get_oper_name(source_p), chptr->name);
get_oper_name(source_p), channel->name);
sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_GLOBAL, "from %s: %s used OPME on channel %s",
me.name, get_oper_name(source_p), chptr->name);
me.name, get_oper_name(source_p), channel->name);
sendto_server(NULL, 0, 0, ":%s GLOBOPS :%s used OPME on channel %s",
me.id, get_oper_name(source_p), chptr->name);
me.id, get_oper_name(source_p), channel->name);

AddMemberFlag(member, CHFL_CHANOP);
sendto_channel_local(NULL, chptr, 0, 0, 0, ":%s MODE %s +o %s",
me.name, chptr->name, source_p->name);
sendto_server(NULL, 0, 0, ":%s TMODE %ju %s +o %s", me.id, chptr->creationtime,
chptr->name, source_p->id);
return 0;
sendto_channel_local(NULL, channel, 0, 0, 0, ":%s MODE %s +o %s",
me.name, channel->name, source_p->name);
sendto_server(NULL, 0, 0, ":%s TMODE %ju %s +o %s", me.id, channel->creation_time,
channel->name, source_p->id);
}

static struct Message opme_msgtab =
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 2000-2019 ircd-hybrid development team
* Copyright (c) 2000-2020 ircd-hybrid development team
*
* 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
@@ -112,7 +112,7 @@ add_accept(const struct split_nuh_item *nuh, struct Client *source_p)
* - parv[0] = command
* - parv[1] = comma-separated list of masks to be accepted or removed
*/
static int
static void
m_accept(struct Client *source_p, int parc, char *parv[])
{
struct split_nuh_item nuh;
@@ -126,7 +126,7 @@ m_accept(struct Client *source_p, int parc, char *parv[])
if (EmptyString(mask) || strcmp(mask, "*") == 0)
{
list_accepts(source_p);
return 0;
return;
}

for (mask = strtok_r(mask, ",", &p); mask;
@@ -158,7 +158,7 @@ m_accept(struct Client *source_p, int parc, char *parv[])
if (dlink_list_length(&source_p->connection->acceptlist) >= ConfigGeneral.max_accept)
{
sendto_one_numeric(source_p, &me, ERR_ACCEPTFULL);
return 0;
return;
}

nuh.nuhmask = mask;
@@ -181,8 +181,6 @@ m_accept(struct Client *source_p, int parc, char *parv[])
add_accept(&nuh, source_p);
}
}

return 0;
}

static struct Message accept_msgtab =
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2019 ircd-hybrid development team
* Copyright (c) 1997-2020 ircd-hybrid development team
*
* 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
@@ -69,25 +69,24 @@ do_admin(struct Client *source_p)
* - parv[0] = command
* - parv[1] = nickname/servername
*/
static int
static void
m_admin(struct Client *source_p, int parc, char *parv[])
{
static uintmax_t last_used = 0;

if ((last_used + ConfigGeneral.pace_wait_simple) > event_base->time.sec_monotonic)
{
sendto_one_numeric(source_p, &me, RPL_LOAD2HI, "ADMIN");
return 0;
return;
}

last_used = event_base->time.sec_monotonic;

if (ConfigServerHide.disable_remote_commands == 0)
if (server_hunt(source_p, ":%s ADMIN :%s", 1, parc, parv)->ret != HUNTED_ISME)
return 0;
return;

do_admin(source_p);
return 0;
}

/*! \brief ADMIN command handler
@@ -101,14 +100,13 @@ m_admin(struct Client *source_p, int parc, char *parv[])
* - parv[0] = command
* - parv[1] = nickname/servername
*/
static int
static void
ms_admin(struct Client *source_p, int parc, char *parv[])
{
if (server_hunt(source_p, ":%s ADMIN :%s", 1, parc, parv)->ret != HUNTED_ISME)
return 0;
return;

do_admin(source_p);
return 0;
}

static struct Message admin_msgtab =
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2019 ircd-hybrid development team
* Copyright (c) 1997-2020 ircd-hybrid development team
*
* 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
@@ -104,13 +104,12 @@ do_away(struct Client *source_p, const char *message)
* - parv[0] = command
* - parv[1] = away message
*/
static int
static void
m_away(struct Client *source_p, int parc, char *parv[])
{
const char *const message = parv[1];

do_away(source_p, message);
return 0;
}

static struct Message away_msgtab =
@@ -2,7 +2,7 @@
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 2004 Kevin L. Mitchell <klmitch@mit.edu>
* Copyright (c) 2006-2019 ircd-hybrid development team
* Copyright (c) 2006-2020 ircd-hybrid development team
*
* 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
@@ -380,14 +380,14 @@ subcmd_search(const char *cmd, const struct subcmd *elem)
* - parv[1] = CAP subcommand
* - parv[2] = space-separated list of capabilities
*/
static int
static void
m_cap(struct Client *source_p, int parc, char *parv[])
{
const char *subcmd = NULL, *caplist = NULL;
struct subcmd *cmd = NULL;

if (EmptyString(parv[1])) /* A subcommand is required */
return 0;
return;

subcmd = parv[1];

@@ -400,13 +400,12 @@ m_cap(struct Client *source_p, int parc, char *parv[])
sizeof(struct subcmd), (bqcmp)subcmd_search)))
{
sendto_one_numeric(source_p, &me, ERR_INVALIDCAPCMD, subcmd);
return 0;
return;
}

/* Then execute it... */
if (cmd->proc)
(cmd->proc)(source_p, caplist);
return 0;
}

static struct Message cap_msgtab =
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1998-2019 ircd-hybrid development team
* Copyright (c) 1998-2020 ircd-hybrid development team
*
* 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
@@ -43,7 +43,7 @@
* - parv[0] = command
* - parv[1] = space-separated list of capabilities
*/
static int
static void
mr_capab(struct Client *source_p, int parc, char *parv[])
{
unsigned int cap = 0;
@@ -53,8 +53,6 @@ mr_capab(struct Client *source_p, int parc, char *parv[])
s = strtok_r(NULL, " ", &p))
if ((cap = capab_find(s)))
SetCapable(source_p, cap);

return 0;
}

static struct Message capab_msgtab =
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 2013-2019 ircd-hybrid development team
* Copyright (c) 2013-2020 ircd-hybrid development team
*
* 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
@@ -44,18 +44,17 @@
* - parv[0] = command
* - parv[1] = certificate fingerprint
*/
static int
static void
ms_certfp(struct Client *source_p, int parc, char *parv[])
{
if (!IsClient(source_p))
return 0;
return;

xfree(source_p->certfp);
source_p->certfp = xstrdup(parv[1]);

sendto_server(source_p, 0, 0, ":%s CERTFP %s",
source_p->id, source_p->certfp);
return 0;
}

static struct Message certfp_msgtab =
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2019 ircd-hybrid development team
* Copyright (c) 1997-2020 ircd-hybrid development team
*
* 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
@@ -44,7 +44,7 @@
* \note Valid arguments for this command are:
* - parv[0] = command
*/
static int
static void
mo_close(struct Client *source_p, int parc, char *parv[])
{
dlink_node *node, *node_next;
@@ -53,7 +53,7 @@ mo_close(struct Client *source_p, int parc, char *parv[])
if (!HasOFlag(source_p, OPER_FLAG_CLOSE))
{
sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "close");
return 0;
return;
}

DLINK_FOREACH_SAFE(node, node_next, unknown_list.head)
@@ -72,7 +72,6 @@ mo_close(struct Client *source_p, int parc, char *parv[])
}

sendto_one_numeric(source_p, &me, RPL_CLOSEEND, closed);
return 0;
}

static struct Message close_msgtab =
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2019 ircd-hybrid development team
* Copyright (c) 1997-2020 ircd-hybrid development team
*
* 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
@@ -51,33 +51,33 @@
* - parv[2] = unused/ignored
* - parv[3] = nickname/servername
*/
static int
static void
mo_connect(struct Client *source_p, int parc, char *parv[])
{
const char *const name = parv[1];

if (EmptyString(name))
{
sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, "CONNECT");
return 0;
return;
}

if (parc > 3)
{
if (!HasOFlag(source_p, OPER_FLAG_CONNECT_REMOTE))
{
sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "connect:remote");
return 0;
return;
}

if (server_hunt(source_p, ":%s CONNECT %s %s :%s", 3, parc, parv)->ret != HUNTED_ISME)
return 0;
return;
}

if (!HasOFlag(source_p, OPER_FLAG_CONNECT))
{
sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "connect");
return 0;
return;
}

/*
@@ -87,22 +87,22 @@ mo_connect(struct Client *source_p, int parc, char *parv[])
if ((conf = connect_find(name, match)) == NULL)
{
sendto_one_notice(source_p, &me, ":Connect: Server %s not listed in configuration file", name);
return 0;
return;
}

const struct Client *target_p;
if ((target_p = hash_find_server(conf->name)))
{
sendto_one_notice(source_p, &me, ":Connect: Server %s already exists from %s",
target_p->name, target_p->from->name);
return 0;
return;
}

if (find_servconn_in_progress(conf->name))
{
sendto_one_notice(source_p, &me, ":Connect: a connection to %s is already in progress",
conf->name);
return 0;
return;
}

ilog(LOG_TYPE_IRCD, "CONNECT %s %u from %s",
@@ -129,7 +129,6 @@ mo_connect(struct Client *source_p, int parc, char *parv[])
* Client is either connecting with all the data it needs or has been
* destroyed
*/
return 0;
}

/*! \brief CONNECT command handler
@@ -145,19 +144,19 @@ mo_connect(struct Client *source_p, int parc, char *parv[])
* - parv[2] = unused/ignored
* - parv[3] = nickname/servername
*/
static int
static void
ms_connect(struct Client *source_p, int parc, char *parv[])
{
const char *const name = parv[1];

if (parc < 4 || EmptyString(parv[3]))
{
sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, "CONNECT");
return 0;
return;
}

if (server_hunt(source_p, ":%s CONNECT %s %s :%s", 3, parc, parv)->ret != HUNTED_ISME)
return 0;
return;

/*
* Try to find the name. If it fails, notify and bail.
@@ -166,22 +165,22 @@ ms_connect(struct Client *source_p, int parc, char *parv[])
if ((conf = connect_find(name, match)) == NULL)
{
sendto_one_notice(source_p, &me, ":Connect: Server %s not listed in configuration file", name);
return 0;
return;
}

const struct Client *target_p;
if ((target_p = hash_find_server(conf->name)))
{
sendto_one_notice(source_p, &me, ":Connect: Server %s already exists from %s",
target_p->name, target_p->from->name);
return 0;
return;
}

if (find_servconn_in_progress(conf->name))
{
sendto_one_notice(source_p, &me, ":Connect: a connection to %s is already in progress",
conf->name);
return 0;
return;
}

/*
@@ -210,7 +209,6 @@ ms_connect(struct Client *source_p, int parc, char *parv[])
* Client is either connecting with all the data it needs or has been
* destroyed
*/
return 0;
}

static struct Message connect_msgtab =
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2019 ircd-hybrid development team
* Copyright (c) 1997-2020 ircd-hybrid development team
*
* 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
@@ -180,19 +180,19 @@ dline_handle(struct Client *source_p, const struct aline_ctx *aline)
* side effects - D line is added
*
*/
static int
static void
mo_dline(struct Client *source_p, int parc, char *parv[])
{
struct aline_ctx aline = { .add = true, .simple_mask = false };

if (!HasOFlag(source_p, OPER_FLAG_DLINE))
{
sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "dline");
return 0;
return;
}

if (parse_aline("DLINE", source_p, parc, parv, &aline) == false)
return 0;
return;

if (aline.server)
{
@@ -201,14 +201,13 @@ mo_dline(struct Client *source_p, int parc, char *parv[])

/* Allow ON to apply local dline as well if it matches */
if (match(aline.server, me.name))
return 0;
return;
}
else
cluster_distribute(source_p, "DLINE", CAPAB_DLN, CLUSTER_DLINE,
"%ju %s :%s", aline.duration, aline.host, aline.reason);

dline_handle(source_p, &aline);
return 0;
}

/*! \brief DLINE command handler
@@ -225,7 +224,7 @@ mo_dline(struct Client *source_p, int parc, char *parv[])
* - parv[3] = IP address
* - parv[4] = reason
*/
static int
static void
ms_dline(struct Client *source_p, int parc, char *parv[])
{
struct aline_ctx aline =
@@ -239,20 +238,18 @@ ms_dline(struct Client *source_p, int parc, char *parv[])
};

if (parc != 5 || EmptyString(parv[parc - 1]))
return 0;
return;

sendto_match_servs(source_p, aline.server, CAPAB_DLN, "DLINE %s %ju %s :%s",
aline.server, aline.duration, aline.host, aline.reason);

if (match(aline.server, me.name))
return 0;
return;

if (HasFlag(source_p, FLAGS_SERVICE) ||
shared_find(SHARED_DLINE, source_p->servptr->name,
source_p->username, source_p->host))
dline_handle(source_p, &aline);

return 0;
}

static struct Message dline_msgtab =
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 2003-2019 ircd-hybrid development team
* Copyright (c) 2003-2020 ircd-hybrid development team
*
* 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
@@ -40,7 +40,7 @@
* output - none
* side effects - propagates subcommand to locally connected servers
*/
static int
static void
ms_encap(struct Client *source_p, int parc, char *parv[])
{
char buffer[IRCD_BUFSIZE] = "", *ptr = buffer;
@@ -56,7 +56,7 @@ ms_encap(struct Client *source_p, int parc, char *parv[])

/* Drop the whole command if this parameter would be truncated */
if ((cur_len + len) >= sizeof(buffer))
return 0;
return;

snprintf(ptr, sizeof(buffer) - cur_len, "%s ", parv[i]);
cur_len += len;
@@ -73,10 +73,10 @@ ms_encap(struct Client *source_p, int parc, char *parv[])
"ENCAP %s", buffer);

if (match(parv[1], me.name))
return 0;
return;

if ((mptr = find_command(parv[2])) == NULL)
return 0;
return;

#ifdef NOT_USED_YET
paramcount = mptr->parameters;
@@ -89,7 +89,6 @@ ms_encap(struct Client *source_p, int parc, char *parv[])

if ((unsigned int)parc >= mptr->args_min)
mptr->handlers[ENCAP_HANDLER](source_p, parc, parv);
return 0;
}

static struct Message encap_msgtab =
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 2000-2019 ircd-hybrid development team
* Copyright (c) 2000-2020 ircd-hybrid development team
*
* 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
@@ -43,7 +43,7 @@
* \note Valid arguments for this command are:
* - parv[0] = command
*/
static int
static void
ms_eob(struct Client *source_p, int parc, char *parv[])
{
assert(IsServer(source_p));
@@ -55,8 +55,6 @@ ms_eob(struct Client *source_p, int parc, char *parv[])

AddFlag(source_p, FLAGS_EOB);
sendto_server(source_p, 0, 0, ":%s EOB", source_p->id);

return 0;
}

static struct Message eob_msgtab =
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 2004-2019 ircd-hybrid development team
* Copyright (c) 2004-2020 ircd-hybrid development team
*
* 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
@@ -107,12 +107,12 @@ do_etrace(struct Client *source_p, const char *name)
* - parv[1] = nick name to trace
* - parv[2] = nick or server name to forward the etrace to
*/
static int
static void
mo_etrace(struct Client *source_p, int parc, char *parv[])
{
if (parc > 2)
if (server_hunt(source_p, ":%s ETRACE %s :%s", 2, parc, parv)->ret != HUNTED_ISME)
return 0;
return;

const struct server_hunt *hunt = server_hunt(source_p, ":%s ETRACE :%s", 1, parc, parv);
switch (hunt->ret)
@@ -127,8 +127,6 @@ mo_etrace(struct Client *source_p, int parc, char *parv[])
default:
break;
}

return 0;
}

static struct Message etrace_msgtab =
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 2011-2019 ircd-hybrid development team
* Copyright (c) 2011-2020 ircd-hybrid development team
*
* 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
@@ -46,27 +46,26 @@
* - parv[0] = command
* - parv[1] = message text
*/
static int
static void
mo_globops(struct Client *source_p, int parc, char *parv[])
{
const char *const message = parv[1];

if (!HasOFlag(source_p, OPER_FLAG_GLOBOPS))
{
sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "globops");
return 0;
return;
}

if (EmptyString(message))
{
sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, "GLOBOPS");
return 0;
return;
}

sendto_server(source_p, 0, 0, ":%s GLOBOPS :%s", source_p->id, message);
sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_GLOBAL, "from %s: %s",
source_p->name, message);
return 0;
}

/*! \brief GLOBOPS command handler
@@ -80,18 +79,17 @@ mo_globops(struct Client *source_p, int parc, char *parv[])
* - parv[0] = command
* - parv[1] = message text
*/
static int
static void
ms_globops(struct Client *source_p, int parc, char *parv[])
{
const char *const message = parv[1];

if (EmptyString(message))
return 0;
return;

sendto_server(source_p, 0, 0, ":%s GLOBOPS :%s", source_p->id, message);
sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_GLOBAL, "from %s: %s",
source_p->name, message);
return 0;
}

static struct Message globops_msgtab =
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2019 ircd-hybrid development team
* Copyright (c) 1997-2020 ircd-hybrid development team
*
* 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
@@ -45,7 +45,7 @@
* \note Valid arguments for this command are:
* - parv[0] = command
*/
static int
static void
mo_hash(struct Client *source_p, int parc, char *parv[])
{
unsigned int i = 0;
@@ -117,7 +117,6 @@ mo_hash(struct Client *source_p, int parc, char *parv[])

sendto_one_notice(source_p, &me, ":Id: entries: %u buckets: %u "
"max chain: %u", count, buckets, max_chain);
return 0;
}

static struct Message hash_msgtab =
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1999-2019 ircd-hybrid development team
* Copyright (c) 1999-2020 ircd-hybrid development team
*
* 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
@@ -121,21 +121,20 @@ do_help(struct Client *source_p, char *topic)
* - parv[0] = command
* - parv[1] = help topic
*/
static int
static void
m_help(struct Client *source_p, int parc, char *parv[])
{
static uintmax_t last_used = 0;

if ((last_used + ConfigGeneral.pace_wait_simple) > event_base->time.sec_monotonic)
{
sendto_one_numeric(source_p, &me, RPL_LOAD2HI, "HELP");
return 0;
return;
}

last_used = event_base->time.sec_monotonic;

do_help(source_p, parv[1]);
return 0;
}

/*! \brief HELP command handler
@@ -149,11 +148,10 @@ m_help(struct Client *source_p, int parc, char *parv[])
* - parv[0] = command
* - parv[1] = help topic
*/
static int
static void
mo_help(struct Client *source_p, int parc, char *parv[])
{
do_help(source_p, parv[1]);
return 0;
}

static struct Message help_msgtab =
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2019 ircd-hybrid development team
* Copyright (c) 1997-2020 ircd-hybrid development team
*
* 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
@@ -551,7 +551,7 @@ static const char *infotext[] =
"ircd-hybrid --",
"Based on the original code written by Jarkko Oikarinen",
"Copyright (c) 1988-1991 University of Oulu, Computing Center",
"Copyright (c) 1997-2019 ircd-hybrid development team",
"Copyright (c) 1997-2020 ircd-hybrid development team",
"",
"This program is free software; you can redistribute it and/or",
"modify it under the terms of the GNU General Public License as",
@@ -764,25 +764,24 @@ send_info_text(struct Client *source_p)
* - parv[0] = command
* - parv[1] = nickname/servername
*/
static int
static void
m_info(struct Client *source_p, int parc, char *parv[])
{
static uintmax_t last_used = 0;

if ((last_used + ConfigGeneral.pace_wait) > event_base->time.sec_monotonic)
{
sendto_one_numeric(source_p, &me, RPL_LOAD2HI, "INFO");
return 0;
return;
}

last_used = event_base->time.sec_monotonic;

if (ConfigServerHide.disable_remote_commands == 0)
if (server_hunt(source_p, ":%s INFO :%s", 1, parc, parv)->ret != HUNTED_ISME)
return 0;
return;

send_info_text(source_p);
return 0;
}

/*! \brief INFO command handler
@@ -796,14 +795,13 @@ m_info(struct Client *source_p, int parc, char *parv[])
* - parv[0] = command
* - parv[1] = nickname/servername
*/
static int
static void
ms_info(struct Client *source_p, int parc, char *parv[])
{
if (server_hunt(source_p, ":%s INFO :%s", 1, parc, parv)->ret != HUNTED_ISME)
return 0;
return;

send_info_text(source_p);
return 0;
}

static struct Message info_msgtab =
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2019 ircd-hybrid development team
* Copyright (c) 1997-2020 ircd-hybrid development team
*
* 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
@@ -52,7 +52,7 @@
* - parv[1] = user to invite
* - parv[2] = channel name
*/
static int
static void
m_invite(struct Client *source_p, int parc, char *parv[])
{
if (parc < 2)
@@ -61,101 +61,100 @@ m_invite(struct Client *source_p, int parc, char *parv[])

DLINK_FOREACH(node, source_p->connection->invited.head)
sendto_one_numeric(source_p, &me, RPL_INVITELIST,
((const struct Invite *)node->data)->chptr->name);
((const struct Invite *)node->data)->channel->name);

sendto_one_numeric(source_p, &me, RPL_ENDOFINVITELIST);
return 0;
return;
}

if (parc < 3 || EmptyString(parv[2]))
{
sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, "INVITE");
return 0;
return;
}

struct Client *target_p;
if ((target_p = find_person(source_p, parv[1])) == NULL)
{
sendto_one_numeric(source_p, &me, ERR_NOSUCHNICK, parv[1]);
return 0;
return;
}

struct Channel *chptr;
if ((chptr = hash_find_channel(parv[2])) == NULL)
struct Channel *channel;
if ((channel = hash_find_channel(parv[2])) == NULL)
{
sendto_one_numeric(source_p, &me, ERR_NOSUCHCHANNEL, parv[2]);
return 0;
return;
}

struct Membership *member;
if ((member = find_channel_link(source_p, chptr)) == NULL)
struct ChannelMember *member;
if ((member = find_channel_link(source_p, channel)) == NULL)
{
sendto_one_numeric(source_p, &me, ERR_NOTONCHANNEL, chptr->name);
return 0;
sendto_one_numeric(source_p, &me, ERR_NOTONCHANNEL, channel->name);
return;
}

if (!has_member_flags(member, CHFL_CHANOP | CHFL_HALFOP))
{
sendto_one_numeric(source_p, &me, ERR_CHANOPRIVSNEEDED, chptr->name);
return 0;
sendto_one_numeric(source_p, &me, ERR_CHANOPRIVSNEEDED, channel->name);
return;
}

if (IsMember(target_p, chptr))
if (IsMember(target_p, channel))
{
sendto_one_numeric(source_p, &me, ERR_USERONCHANNEL, target_p->name, chptr->name);
return 0;
sendto_one_numeric(source_p, &me, ERR_USERONCHANNEL, target_p->name, channel->name);
return;
}

if ((source_p->connection->invite.last_attempt + ConfigChannel.invite_client_time) < event_base->time.sec_monotonic)
source_p->connection->invite.count = 0;

if (source_p->connection->invite.count > ConfigChannel.invite_client_count)
{
sendto_one_numeric(source_p, &me, ERR_TOOMANYINVITE, chptr->name, "user");
return 0;
sendto_one_numeric(source_p, &me, ERR_TOOMANYINVITE, channel->name, "user");
return;
}

if ((chptr->last_invite + ConfigChannel.invite_delay_channel) > event_base->time.sec_monotonic)
if ((channel->last_invite_time + ConfigChannel.invite_delay_channel) > event_base->time.sec_monotonic)
{
sendto_one_numeric(source_p, &me, ERR_TOOMANYINVITE, chptr->name, "channel");
return 0;
sendto_one_numeric(source_p, &me, ERR_TOOMANYINVITE, channel->name, "channel");
return;
}

source_p->connection->invite.last_attempt = event_base->time.sec_monotonic;
source_p->connection->invite.count++;

sendto_one_numeric(source_p, &me, RPL_INVITING, target_p->name, chptr->name);
sendto_one_numeric(source_p, &me, RPL_INVITING, target_p->name, channel->name);

if (target_p->away[0])
sendto_one_numeric(source_p, &me, RPL_AWAY, target_p->name, target_p->away);

chptr->last_invite = event_base->time.sec_monotonic;
channel->last_invite_time = event_base->time.sec_monotonic;

if (MyConnect(target_p))
{
sendto_one(target_p, ":%s!%s@%s INVITE %s :%s",
source_p->name, source_p->username,
source_p->host,
target_p->name, chptr->name);
target_p->name, channel->name);

if (HasCMode(chptr, MODE_INVITEONLY))
add_invite(chptr, target_p); /* Add the invite if channel is +i */
if (HasCMode(channel, MODE_INVITEONLY))
add_invite(channel, target_p); /* Add the invite if channel is +i */
}

if (HasCMode(chptr, MODE_INVITEONLY))
if (HasCMode(channel, MODE_INVITEONLY))
{
sendto_channel_local(NULL, chptr, CHFL_CHANOP | CHFL_HALFOP, 0, CAP_INVITE_NOTIFY,
sendto_channel_local(NULL, channel, CHFL_CHANOP | CHFL_HALFOP, 0, CAP_INVITE_NOTIFY,
":%s NOTICE %%%s :%s is inviting %s to %s.",
me.name, chptr->name, source_p->name, target_p->name, chptr->name);
sendto_channel_local(NULL, chptr, CHFL_CHANOP | CHFL_HALFOP, CAP_INVITE_NOTIFY, 0,
me.name, channel->name, source_p->name, target_p->name, channel->name);
sendto_channel_local(NULL, channel, CHFL_CHANOP | CHFL_HALFOP, CAP_INVITE_NOTIFY, 0,
":%s!%s@%s INVITE %s %s", source_p->name, source_p->username,
source_p->host, target_p->name, chptr->name);
source_p->host, target_p->name, channel->name);
}

sendto_server(source_p, 0, 0, ":%s INVITE %s %s %ju",
source_p->id, target_p->id,
chptr->name, chptr->creationtime);
return 0;
channel->name, channel->creation_time);
}

/*! \brief INVITE command handler
@@ -171,54 +170,53 @@ m_invite(struct Client *source_p, int parc, char *parv[])
* - parv[2] = channel name
* - parv[3] = channel timestamp
*/
static int
static void
ms_invite(struct Client *source_p, int parc, char *parv[])
{
if (parc < 3 || EmptyString(parv[2]))
return 0;
return;

struct Client *target_p;
if ((target_p = find_person(source_p, parv[1])) == NULL)
return 0;
return;

struct Channel *chptr;
if ((chptr = hash_find_channel(parv[2])) == NULL)
return 0;
struct Channel *channel;
if ((channel = hash_find_channel(parv[2])) == NULL)
return;

if (IsMember(target_p, chptr))
return 0;
if (IsMember(target_p, channel))
return;

if (parc > 3 && IsDigit(*parv[3]))
if (strtoumax(parv[3], NULL, 10) > chptr->creationtime)
return 0;
if (strtoumax(parv[3], NULL, 10) > channel->creation_time)
return;

chptr->last_invite = event_base->time.sec_monotonic;
channel->last_invite_time = event_base->time.sec_monotonic;

if (MyConnect(target_p))
{
sendto_one(target_p, ":%s!%s@%s INVITE %s :%s",
source_p->name, source_p->username,
source_p->host,
target_p->name, chptr->name);
target_p->name, channel->name);

if (HasCMode(chptr, MODE_INVITEONLY))
add_invite(chptr, target_p); /* Add the invite if channel is +i */
if (HasCMode(channel, MODE_INVITEONLY))
add_invite(channel, target_p); /* Add the invite if channel is +i */
}

if (HasCMode(chptr, MODE_INVITEONLY))
if (HasCMode(channel, MODE_INVITEONLY))
{
sendto_channel_local(NULL, chptr, CHFL_CHANOP | CHFL_HALFOP, 0, CAP_INVITE_NOTIFY,
sendto_channel_local(NULL, channel, CHFL_CHANOP | CHFL_HALFOP, 0, CAP_INVITE_NOTIFY,
":%s NOTICE %%%s :%s is inviting %s to %s.",
me.name, chptr->name, source_p->name, target_p->name, chptr->name);
sendto_channel_local(NULL, chptr, CHFL_CHANOP | CHFL_HALFOP, CAP_INVITE_NOTIFY, 0,
me.name, channel->name, source_p->name, target_p->name, channel->name);
sendto_channel_local(NULL, channel, CHFL_CHANOP | CHFL_HALFOP, CAP_INVITE_NOTIFY, 0,
":%s!%s@%s INVITE %s %s", source_p->name, source_p->username,
source_p->host, target_p->name, chptr->name);
source_p->host, target_p->name, channel->name);
}

sendto_server(source_p, 0, 0, ":%s INVITE %s %s %ju",
source_p->id, target_p->id,
chptr->name, chptr->creationtime);
return 0;
channel->name, channel->creation_time);
}


@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2019 ircd-hybrid development team
* Copyright (c) 1997-2020 ircd-hybrid development team
*
* 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
@@ -45,7 +45,7 @@
* - parv[0] = command
* - parv[1] = space-separated list of nicknames
*/
static int
static void
m_ison(struct Client *source_p, int parc, char *parv[])
{
char *p = NULL;
@@ -79,7 +79,6 @@ m_ison(struct Client *source_p, int parc, char *parv[])
*(current_insert_point - cut) = '\0';

sendto_one(source_p, "%s", buf);
return 0;
}

static struct Message ison_msgtab =
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2019 ircd-hybrid development team
* Copyright (c) 1997-2020 ircd-hybrid development team
*
* 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
@@ -192,19 +192,19 @@ kline_handle(struct Client *source_p, const struct aline_ctx *aline)
* output -
* side effects - k line is added
*/
static int
static void
mo_kline(struct Client *source_p, int parc, char *parv[])
{
struct aline_ctx aline = { .add = true, .simple_mask = false };

if (!HasOFlag(source_p, OPER_FLAG_KLINE))
{
sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "kline");
return 0;
return;
}

if (parse_aline("KLINE", source_p, parc, parv, &aline) == false)
return 0;
return;

if (aline.server)
{
@@ -214,14 +214,13 @@ mo_kline(struct Client *source_p, int parc, char *parv[])

/* Allow ON to apply local kline as well if it matches */
if (match(aline.server, me.name))
return 0;
return;
}
else
cluster_distribute(source_p, "KLINE", CAPAB_KLN, CLUSTER_KLINE, "%ju %s %s :%s",
aline.duration, aline.user, aline.host, aline.reason);

kline_handle(source_p, &aline);
return 0;
}

/*! \brief KLINE command handler
@@ -239,7 +238,7 @@ mo_kline(struct Client *source_p, int parc, char *parv[])
* - parv[4] = host mask
* - parv[5] = reason
*/
static int
static void
ms_kline(struct Client *source_p, int parc, char *parv[])
{
struct aline_ctx aline =
@@ -254,20 +253,18 @@ ms_kline(struct Client *source_p, int parc, char *parv[])
};

if (parc != 6 || EmptyString(parv[parc - 1]))
return 0;
return;

sendto_match_servs(source_p, aline.server, CAPAB_KLN, "KLINE %s %ju %s %s :%s", aline.server,
aline.duration, aline.user, aline.host, aline.reason);

if (match(aline.server, me.name))
return 0;
return;

if (HasFlag(source_p, FLAGS_SERVICE) ||
shared_find(SHARED_KLINE, source_p->servptr->name,
source_p->username, source_p->host))
kline_handle(source_p, &aline);

return 0;
}

static struct Message kline_msgtab =
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1998-2019 ircd-hybrid development team
* Copyright (c) 1998-2020 ircd-hybrid development team
*
* 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
@@ -53,82 +53,81 @@
* - parv[0] = command
* - parv[1] = channel name
*/
static int
static void
m_knock(struct Client *source_p, int parc, char *parv[])
{
const char *const name = parv[1];

if (EmptyString(name))
{
sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, "KNOCK");
return 0;
return;
}

struct Channel *chptr;
if ((chptr = hash_find_channel(name)) == NULL)
struct Channel *channel;
if ((channel = hash_find_channel(name)) == NULL)
{
sendto_one_numeric(source_p, &me, ERR_NOSUCHCHANNEL, name);
return 0;
return;
}

/* Normal channel, just be sure they aren't on it. */
if (IsMember(source_p, chptr))
if (IsMember(source_p, channel))
{
sendto_one_numeric(source_p, &me, ERR_KNOCKONCHAN, chptr->name);
return 0;
sendto_one_numeric(source_p, &me, ERR_KNOCKONCHAN, channel->name);
return;
}

if (!((chptr->mode.mode & MODE_INVITEONLY) || chptr->mode.key[0] ||
(chptr->mode.limit && dlink_list_length(&chptr->members) >=
chptr->mode.limit)))
if (!((channel->mode.mode & MODE_INVITEONLY) || channel->mode.key[0] ||
(channel->mode.limit && dlink_list_length(&channel->members) >=
channel->mode.limit)))
{
sendto_one_numeric(source_p, &me, ERR_CHANOPEN, chptr->name);
return 0;
sendto_one_numeric(source_p, &me, ERR_CHANOPEN, channel->name);
return;
}

if (MyClient(source_p))
{
/*
* Don't allow a knock if the user is banned, or the channel is private.
*/
if (PrivateChannel(chptr) || is_banned(chptr, source_p) == true)
if (PrivateChannel(channel) || is_banned(channel, source_p) == true)
{
sendto_one_numeric(source_p, &me, ERR_CANNOTSENDTOCHAN, chptr->name);
return 0;
sendto_one_numeric(source_p, &me, ERR_CANNOTSENDTOCHAN, channel->name);
return;
}

if ((source_p->connection->knock.last_attempt + ConfigChannel.knock_client_time) < event_base->time.sec_monotonic)
source_p->connection->knock.count = 0;

if (source_p->connection->knock.count > ConfigChannel.knock_client_count)
{
sendto_one_numeric(source_p, &me, ERR_TOOMANYKNOCK, chptr->name, "user");
return 0;
sendto_one_numeric(source_p, &me, ERR_TOOMANYKNOCK, channel->name, "user");
return;
}

if ((chptr->last_knock + ConfigChannel.knock_delay_channel) > event_base->time.sec_monotonic)
if ((channel->last_knock_time + ConfigChannel.knock_delay_channel) > event_base->time.sec_monotonic)
{
sendto_one_numeric(source_p, &me, ERR_TOOMANYKNOCK, chptr->name, "channel");
return 0;
sendto_one_numeric(source_p, &me, ERR_TOOMANYKNOCK, channel->name, "channel");
return;
}

source_p->connection->knock.last_attempt = event_base->time.sec_monotonic;
source_p->connection->knock.count++;

sendto_one_numeric(source_p, &me, RPL_KNOCKDLVR, chptr->name);
sendto_one_numeric(source_p, &me, RPL_KNOCKDLVR, channel->name);
}

chptr->last_knock = event_base->time.sec_monotonic;
sendto_channel_local(NULL, chptr, CHFL_CHANOP | CHFL_HALFOP, 0, 0,
channel->last_knock_time = event_base->time.sec_monotonic;
sendto_channel_local(NULL, channel, CHFL_CHANOP | CHFL_HALFOP, 0, 0,
":%s NOTICE %%%s :KNOCK: %s (%s [%s@%s] has asked for an invite)",
me.name, chptr->name, chptr->name,
me.name, channel->name, channel->name,
source_p->name,
source_p->username,
source_p->host);

sendto_server(source_p, CAPAB_KNOCK, 0, ":%s KNOCK %s",
source_p->id, chptr->name);
return 0;
source_p->id, channel->name);
}

static struct Message knock_msgtab =
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2019 ircd-hybrid development team
* Copyright (c) 1997-2020 ircd-hybrid development team
*
* 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
@@ -98,11 +98,10 @@ do_links(struct Client *source_p, int parc, char *parv[])
}
}

static int
static void
mo_links(struct Client *source_p, int parc, char *parv[])
{
do_links(source_p, parc, parv);
return 0;
}

/*! \brief LINKS command handler
@@ -120,21 +119,20 @@ mo_links(struct Client *source_p, int parc, char *parv[])
* - parv[1] = server to query
* - parv[2] = servername mask
*/
static int
static void
m_links(struct Client *source_p, int parc, char *parv[])
{
static uintmax_t last_used = 0;

if ((last_used + ConfigGeneral.pace_wait) > event_base->time.sec_monotonic)
{
sendto_one_numeric(source_p, &me, RPL_LOAD2HI, "LINKS");
return 0;
return;
}

last_used = event_base->time.sec_monotonic;

do_links(source_p, parc, parv);
return 0;
}

static struct Message links_msgtab =
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2019 ircd-hybrid development team
* Copyright (c) 1997-2020 ircd-hybrid development team
*
* 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
@@ -175,11 +175,10 @@ do_list(struct Client *source_p, char *arg)
* - parv[0] = command
* - parv[1] = channel name/list options
*/
static int
static void
m_list(struct Client *source_p, int parc, char *parv[])
{
do_list(source_p, parv[1]);
return 0;
}

static struct Message list_msgtab =
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2019 ircd-hybrid development team
* Copyright (c) 1997-2020 ircd-hybrid development team
*
* 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
@@ -49,27 +49,26 @@
* - parv[0] = command
* - parv[1] = message text
*/
static int
static void
mo_locops(struct Client *source_p, int parc, char *parv[])
{
const char *const message = parv[1];

if (!HasOFlag(source_p, OPER_FLAG_LOCOPS))
{
sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "locops");
return 0;
return;
}

if (EmptyString(message))
{
sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, "LOCOPS");
return 0;
return;
}

sendto_realops_flags(UMODE_LOCOPS, L_ALL, SEND_LOCOPS, "from %s: %s",
source_p->name, message);
cluster_distribute(source_p, "LOCOPS", 0, CLUSTER_LOCOPS, message);
return 0;
}

/*! \brief LOCOPS command handler
@@ -84,25 +83,24 @@ mo_locops(struct Client *source_p, int parc, char *parv[])
* - parv[1] = target server
* - parv[2] = message text
*/
static int
static void
ms_locops(struct Client *source_p, int parc, char *parv[])
{
const char *const targets = parv[1];
const char *const message = parv[2];

if (parc != 3 || EmptyString(message))
return 0;
return;

sendto_match_servs(source_p, targets, CAPAB_CLUSTER, "LOCOPS %s :%s",
targets, message);

if (match(targets, me.name))
return 0;
return;

if (shared_find(SHARED_LOCOPS, source_p->servptr->name, "*", "*"))
sendto_realops_flags(UMODE_LOCOPS, L_ALL, SEND_LOCOPS, "from %s: %s",
source_p->name, message);
return 0;
}

static struct Message locops_msgtab =
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2019 ircd-hybrid development team
* Copyright (c) 1997-2020 ircd-hybrid development team
*
* 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
@@ -48,25 +48,24 @@
* - parv[1] = ignored
* - parv[2] = nickname/servername
*/
static int
static void
m_lusers(struct Client *source_p, int parc, char *parv[])
{
static uintmax_t last_used = 0;

if ((last_used + ConfigGeneral.pace_wait_simple) > event_base->time.sec_monotonic)
{
sendto_one_numeric(source_p, &me, RPL_LOAD2HI, "LUSERS");
return 0;
return;
}

last_used = event_base->time.sec_monotonic;

if (ConfigServerHide.disable_remote_commands == 0)
if (server_hunt(source_p, ":%s LUSERS %s :%s", 2, parc, parv)->ret != HUNTED_ISME)
return 0;
return;

show_lusers(source_p);
return 0;
}

/*! \brief LUSERS command handler
@@ -81,14 +80,13 @@ m_lusers(struct Client *source_p, int parc, char *parv[])
* - parv[1] = ignored
* - parv[2] = nickname/servername
*/
static int
static void
ms_lusers(struct Client *source_p, int parc, char *parv[])
{
if (server_hunt(source_p, ":%s LUSERS %s :%s", 2, parc, parv)->ret != HUNTED_ISME)
return 0;
return;

show_lusers(source_p);
return 0;
}

static struct Message lusers_msgtab =
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 2001-2019 ircd-hybrid development team
* Copyright (c) 2001-2020 ircd-hybrid development team
*
* 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
@@ -143,25 +143,27 @@ do_map(struct Client *source_p)
* \note Valid arguments for this command are:
* - parv[0] = command
*/
static int
static void
m_map(struct Client *source_p, int parc, char *parv[])
{
static uintmax_t last_used = 0;

if (ConfigServerHide.flatten_links)
return m_not_oper(source_p, parc, parv);
{
m_not_oper(source_p, parc, parv);
return;
}

if ((last_used + ConfigGeneral.pace_wait) > event_base->time.sec_monotonic)
{
sendto_one_numeric(source_p, &me, RPL_LOAD2HI, "MAP");
return 0;
return;
}

last_used = event_base->time.sec_monotonic;

do_map(source_p);
sendto_one_numeric(source_p, &me, RPL_MAPEND);
return 0;
}

/*! \brief MAP command handler
@@ -174,12 +176,11 @@ m_map(struct Client *source_p, int parc, char *parv[])
* \note Valid arguments for this command are:
* - parv[0] = command
*/
static int
static void
mo_map(struct Client *source_p, int parc, char *parv[])
{
do_map(source_p);
sendto_one_numeric(source_p, &me, RPL_MAPEND);
return 0;
}

static struct Message map_msgtab =
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 2000-2019 ircd-hybrid development team
* Copyright (c) 2000-2020 ircd-hybrid development team
*
* 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
@@ -197,11 +197,11 @@ struct ModuleStruct

static const struct ModuleStruct module_cmd_table[] =
{
{ "LOAD", module_load, true },
{ "UNLOAD", module_unload, true },
{ "RELOAD", module_reload, true },
{ "LIST", module_list, false },
{ NULL, NULL, false }
{ .cmd = "LOAD", .handler = module_load, .arg_required = true },
{ .cmd = "UNLOAD", .handler = module_unload, .arg_required = true },
{ .cmd = "RELOAD", .handler = module_reload, .arg_required = true },
{ .cmd = "LIST", .handler = module_list },
{ .cmd = NULL }
};

/*! \brief MODULE command handler
@@ -216,7 +216,7 @@ static const struct ModuleStruct module_cmd_table[] =
* - parv[1] = MODULE subcommand [LOAD, UNLOAD, RELOAD, LIST]
* - parv[2] = module name
*/
static int
static void
mo_module(struct Client *source_p, int parc, char *parv[])
{
const char *const subcmd = parv[1];
@@ -225,13 +225,13 @@ mo_module(struct Client *source_p, int parc, char *parv[])
if (!HasOFlag(source_p, OPER_FLAG_MODULE))
{
sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "module");
return 0;
return;
}

if (EmptyString(subcmd))
{
sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, "MODULE");
return 0;
return;
}

for (const struct ModuleStruct *tab = module_cmd_table; tab->handler; ++tab)
@@ -242,17 +242,16 @@ mo_module(struct Client *source_p, int parc, char *parv[])
if (tab->arg_required == true && EmptyString(module))
{
sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, "MODULE");
return 0;
return;
}

tab->handler(source_p, module);
return 0;
return;
}

sendto_one_notice(source_p, &me, ":%s is not a valid option. "
"Choose from LOAD, UNLOAD, RELOAD, LIST",
subcmd);
return 0;
}

static struct Message module_msgtab =
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2019 ircd-hybrid development team
* Copyright (c) 1997-2020 ircd-hybrid development team
*
* 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
@@ -63,25 +63,24 @@ do_motd(struct Client *source_p)
* - parv[0] = command
* - parv[1] = nickname/servername
*/
static int
static void
m_motd(struct Client *source_p, int parc, char *parv[])
{
static uintmax_t last_used = 0;

if ((last_used + ConfigGeneral.pace_wait) > event_base->time.sec_monotonic)
{
sendto_one_numeric(source_p, &me, RPL_LOAD2HI, "MOTD");
return 0;
return;
}

last_used = event_base->time.sec_monotonic;

if (ConfigServerHide.disable_remote_commands == 0)
if (server_hunt(source_p, ":%s MOTD :%s", 1, parc, parv)->ret != HUNTED_ISME)
return 0;
return;

do_motd(source_p);
return 0;
}

/*! \brief MOTD command handler
@@ -95,14 +94,13 @@ m_motd(struct Client *source_p, int parc, char *parv[])
* - parv[0] = command
* - parv[1] = nickname/servername
*/
static int
static void
ms_motd(struct Client *source_p, int parc, char *parv[])
{
if (server_hunt(source_p, ":%s MOTD :%s", 1, parc, parv)->ret != HUNTED_ISME)
return 0;
return;

do_motd(source_p);
return 0;
}

static struct Message motd_msgtab =
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2019 ircd-hybrid development team
* Copyright (c) 1997-2020 ircd-hybrid development team
*
* 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
@@ -48,23 +48,21 @@
* - parv[0] = command
* - parv[1] = channel name
*/
static int
static void
m_names(struct Client *source_p, int parc, char *parv[])
{
const char *const para = parc > 1 ? parv[1] : NULL;
const char *const name = parv[1];

if (!EmptyString(para))
if (!EmptyString(name))
{
struct Channel *chptr = hash_find_channel(para);
if (chptr)
channel_member_names(source_p, chptr, true);
struct Channel *channel = hash_find_channel(name);
if (channel)
channel_member_names(source_p, channel, true);
else
sendto_one_numeric(source_p, &me, RPL_ENDOFNAMES, para);
sendto_one_numeric(source_p, &me, RPL_ENDOFNAMES, name);
}
else
sendto_one_numeric(source_p, &me, RPL_ENDOFNAMES, "*");

return 0;
}

static struct Message names_msgtab =
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2019 ircd-hybrid development team
* Copyright (c) 1997-2020 ircd-hybrid development team
*
* 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
@@ -123,7 +123,7 @@ failed_oper_notice(struct Client *source_p, const char *name,
* - parv[1] = oper name
* - parv[2] = oper password
*/
static int
static void
m_oper(struct Client *source_p, int parc, char *parv[])
{
const char *const opername = parv[1];
@@ -132,7 +132,7 @@ m_oper(struct Client *source_p, int parc, char *parv[])
if (EmptyString(password))
{
sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, "OPER");
return 0;
return;
}

struct MaskItem *conf;
@@ -142,14 +142,14 @@ m_oper(struct Client *source_p, int parc, char *parv[])

conf = operator_find(NULL, opername);
failed_oper_notice(source_p, opername, conf ? "host mismatch" : "no operator {} block");
return 0;
return;
}

if (IsConfSSL(conf) && !HasUMode(source_p, UMODE_SSL))
if (IsConfTLS(conf) && !HasUMode(source_p, UMODE_SECURE))
{
sendto_one_numeric(source_p, &me, ERR_NOOPERHOST);
failed_oper_notice(source_p, opername, "requires SSL/TLS");
return 0;
failed_oper_notice(source_p, opername, "requires TLS");
return;
}

if (!EmptyString(conf->certfp))
@@ -158,7 +158,7 @@ m_oper(struct Client *source_p, int parc, char *parv[])
{
sendto_one_numeric(source_p, &me, ERR_NOOPERHOST);
failed_oper_notice(source_p, opername, "client certificate fingerprint mismatch");
return 0;
return;
}
}

@@ -168,7 +168,7 @@ m_oper(struct Client *source_p, int parc, char *parv[])
{
sendto_one_notice(source_p, &me, ":Can't attach conf!");
failed_oper_notice(source_p, opername, "can't attach conf!");
return 0;
return;
}

oper_up(source_p, conf);
@@ -178,8 +178,6 @@ m_oper(struct Client *source_p, int parc, char *parv[])
sendto_one_numeric(source_p, &me, ERR_PASSWDMISMATCH);
failed_oper_notice(source_p, opername, "password mismatch");
}

return 0;
}

/*! \brief OPER command handler
@@ -194,11 +192,10 @@ m_oper(struct Client *source_p, int parc, char *parv[])
* - parv[1] = oper name
* - parv[2] = oper password
*/
static int
static void
mo_oper(struct Client *source_p, int parc, char *parv[])
{
sendto_one_numeric(source_p, &me, RPL_YOUREOPER);
return 0;
}

static struct Message oper_msgtab =
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2019 ircd-hybrid development team
* Copyright (c) 1997-2020 ircd-hybrid development team
*
* 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
@@ -51,15 +51,15 @@
* - parv[3] = TS protocol version (will be deprecated in some future release)
* - parv[4] = server ID (SID) (will be deprecated in some future release)
*/
static int
static void
mr_pass(struct Client *source_p, int parc, char *parv[])
{
assert(MyConnect(source_p));

if (EmptyString(parv[1]))
{
sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, "PASS");
return 0;
return;
}

xfree(source_p->connection->password);
@@ -69,8 +69,6 @@ mr_pass(struct Client *source_p, int parc, char *parv[])
if (parc > 4)
if (atoi(parv[3]) >= 6 && valid_sid(parv[4]))
strlcpy(source_p->id, parv[4], sizeof(source_p->id));

return 0;
}

static struct Message pass_msgtab =
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2019 ircd-hybrid development team
* Copyright (c) 1997-2020 ircd-hybrid development team
*
* 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
@@ -49,23 +49,23 @@
* - parv[1] = origin
* - parv[2] = destination
*/
static int
static void
m_ping(struct Client *source_p, int parc, char *parv[])
{
struct Client *target_p = NULL;

if (parc < 2 || EmptyString(parv[1]))
{
sendto_one_numeric(source_p, &me, ERR_NOORIGIN);
return 0;
return;
}

const char *const destination = parv[2]; /* Will get NULL or pointer (parc >= 2!!) */
if (ConfigServerHide.disable_remote_commands && !HasUMode(source_p, UMODE_OPER))
{
sendto_one(source_p, ":%s PONG %s :%s", me.name,
(destination) ? destination : me.name, parv[1]);
return 0;
return;
}

if (EmptyString(destination) || ((target_p = hash_find_server(destination)) && IsMe(target_p)))
@@ -76,8 +76,6 @@ m_ping(struct Client *source_p, int parc, char *parv[])
ID_or_name(target_p, target_p));
else
sendto_one_numeric(source_p, &me, ERR_NOSUCHSERVER, destination);

return 0;
}

/*! \brief PING command handler
@@ -92,15 +90,15 @@ m_ping(struct Client *source_p, int parc, char *parv[])
* - parv[1] = origin
* - parv[2] = destination
*/
static int
static void
ms_ping(struct Client *source_p, int parc, char *parv[])
{
struct Client *target_p = NULL;

if (parc < 2 || EmptyString(parv[1]))
{
sendto_one_numeric(source_p, &me, ERR_NOORIGIN);
return 0;
return;
}

const char *const destination = parv[2]; /* Will get NULL or pointer (parc >= 2!!) */
@@ -116,8 +114,6 @@ ms_ping(struct Client *source_p, int parc, char *parv[])
}
else if (!IsDigit(*destination))
sendto_one_numeric(source_p, &me, ERR_NOSUCHSERVER, destination);

return 0;
}

static struct Message ping_msgtab =
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2019 ircd-hybrid development team
* Copyright (c) 1997-2020 ircd-hybrid development team
*
* 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
@@ -50,13 +50,13 @@
* - parv[1] = origin
* - parv[2] = destination
*/
static int
static void
ms_pong(struct Client *source_p, int parc, char *parv[])
{
if (parc < 2 || EmptyString(parv[1]))
{
sendto_one_numeric(source_p, &me, ERR_NOORIGIN);
return 0;
return;
}

const char *const destination = parv[2];
@@ -74,8 +74,6 @@ ms_pong(struct Client *source_p, int parc, char *parv[])
else if (!IsDigit(*destination))
sendto_one_numeric(source_p, &me, ERR_NOSUCHSERVER, destination);
}

return 0;
}

/*! \brief PONG command handler
@@ -89,7 +87,7 @@ ms_pong(struct Client *source_p, int parc, char *parv[])
* - parv[0] = command
* - parv[1] = origin/ping cookie
*/
static int
static void
mr_pong(struct Client *source_p, int parc, char *parv[])
{
assert(MyConnect(source_p));
@@ -114,8 +112,6 @@ mr_pong(struct Client *source_p, int parc, char *parv[])
}
else
sendto_one_numeric(source_p, &me, ERR_NOORIGIN);

return 0;
}

static struct Message pong_msgtab =
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 2001-2019 ircd-hybrid development team
* Copyright (c) 2001-2020 ircd-hybrid development team
*
* 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
@@ -42,14 +42,13 @@
* \note Valid arguments for this command are:
* - parv[0] = command
*/
static int
static void
mr_dumb_proxy(struct Client *source_p, int parc, char *parv[])
{
sendto_realops_flags(UMODE_REJ, L_ALL, SEND_NOTICE,
"HTTP Proxy disconnected: [%s@%s]",
source_p->username, source_p->host);
exit_client(source_p, "Client Exit");
return 0;
}

static struct Message post_msgtab =