@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2017 ircd-hybrid development team
* Copyright (c) 1997-2018 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
@@ -103,12 +103,6 @@ ms_join(struct Client *source_p, int parc, char *parv[])
if (!IsClient(source_p))
return 0;

if (parc == 2 && !strcmp(parv[1], "0"))
{
channel_do_join_0(source_p);
return 0;
}

if (parc < 4)
return 0;

@@ -258,9 +252,9 @@ set_final_mode(const struct Mode *mode, const struct Mode *oldmode)
char *pbuf = parabuf;
int what = 0, len = 0;

for (const struct mode_letter *tab = chan_modes; tab->letter; ++tab)
for (const struct chan_mode *tab = cmode_tab; tab->letter; ++tab)
{
if ((tab->mode & mode->mode) && !(tab->mode & oldmode->mode))
if (tab->mode && (tab->mode & mode->mode) && !(tab->mode & oldmode->mode))
{
if (what != 1)
{
@@ -272,9 +266,9 @@ set_final_mode(const struct Mode *mode, const struct Mode *oldmode)
}
}

for (const struct mode_letter *tab = chan_modes; tab->letter; ++tab)
for (const struct chan_mode *tab = cmode_tab; tab->letter; ++tab)
{
if ((tab->mode & oldmode->mode) && !(tab->mode & mode->mode))
if (tab->mode && (tab->mode & oldmode->mode) && !(tab->mode & mode->mode))
{
if (what != -1)
{
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2017 ircd-hybrid development team
* Copyright (c) 1997-2018 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
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2017 ircd-hybrid development team
* Copyright (c) 1997-2018 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
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2017 ircd-hybrid development team
* Copyright (c) 1997-2018 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
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2017 ircd-hybrid development team
* Copyright (c) 1997-2018 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
@@ -117,7 +117,8 @@ set_user_mode(struct Client *source_p, const int parc, char *parv[])
{
dlink_node *node;

detach_conf(source_p, CONF_OPER);
client_detach_svstag(&source_p->svstags, RPL_WHOISOPERATOR);
conf_detach(source_p, CONF_OPER);
ClrOFlag(source_p);
DelUMode(source_p, ConfigGeneral.oper_only_umodes);

@@ -131,7 +132,6 @@ set_user_mode(struct Client *source_p, const int parc, char *parv[])
case 'S': /* Only servers may set +S in a burst */
case 'W': /* Only servers may set +W in a burst */
case 'r': /* Only services may set +r */
case 'x': /* Only services may set +x */
break;

default:
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2017 ircd-hybrid development team
* Copyright (c) 1997-2018 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
@@ -183,7 +183,7 @@ set_initial_nick(struct Client *source_p, const char *nick)
hash_add_client(source_p);

/* fd_desc is long enough */
fd_note(&source_p->connection->fd, "Nick: %s", source_p->name);
fd_note(source_p->connection->fd, "Nick: %s", source_p->name);

if (!source_p->connection->registration)
register_local_user(source_p);
@@ -259,7 +259,7 @@ change_local_nick(struct Client *source_p, const char *nick)
watch_check_hash(source_p, RPL_LOGON);

/* fd_desc is long enough */
fd_note(&source_p->connection->fd, "Nick: %s", source_p->name);
fd_note(source_p->connection->fd, "Nick: %s", source_p->name);
}

/*!
@@ -344,14 +344,19 @@ uid_from_server(struct Client *source_p, int parc, char *parv[])
client_p->hopcount = atoi(parv[2]);
client_p->tsinfo = strtoumax(parv[3], NULL, 10);

strlcpy(client_p->account, parv[9], sizeof(client_p->account));
strlcpy(client_p->name, parv[1], sizeof(client_p->name));
strlcpy(client_p->id, parv[8], sizeof(client_p->id));
strlcpy(client_p->sockhost, parv[7], sizeof(client_p->sockhost));
strlcpy(client_p->info, parv[parc - 1], sizeof(client_p->info));
strlcpy(client_p->host, parv[6], sizeof(client_p->host));
strlcpy(client_p->username, parv[5], sizeof(client_p->username));

/* TBR: compatibility mode */
const int does_rhost = parc == 12;

strlcpy(client_p->realhost, parv[6 + does_rhost], sizeof(client_p->realhost));
strlcpy(client_p->sockhost, parv[7 + does_rhost], sizeof(client_p->sockhost));
strlcpy(client_p->id, parv[8 + does_rhost], sizeof(client_p->id));
strlcpy(client_p->account, parv[9 + does_rhost], sizeof(client_p->account));

hash_add_client(client_p);
hash_add_id(client_p);

@@ -393,12 +398,27 @@ uid_from_server(struct Client *source_p, int parc, char *parv[])
* - parv[ 8] = uid
* - parv[ 9] = services id (account name)
* - parv[10] = ircname (gecos)
* or with CAPAB_RHOST (parc == 12):
* - parv[ 0] = command
* - parv[ 1] = nickname
* - parv[ 2] = hop count
* - parv[ 3] = TS
* - parv[ 4] = umode
* - parv[ 5] = username
* - parv[ 6] = hostname
* - parv[ 7] = real host
* - parv[ 8] = IP address
* - parv[ 9] = uid
* - parv[10] = services id (account name)
* - parv[11] = ircname (gecos)
*/
static int
perform_uid_introduction_collides(struct Client *source_p, struct Client *target_p,
int parc, char *parv[])
{
const char *uid = parv[8];
/* TBR: compatibility mode */
const int does_rhost = parc == 12;
const char *uid = parv[8 + does_rhost];
uintmax_t newts = strtoumax(parv[3], NULL, 10);

assert(IsServer(source_p));
@@ -429,7 +449,7 @@ perform_uid_introduction_collides(struct Client *source_p, struct Client *target

/* The timestamps are different */
int sameuser = !irccmp(target_p->username, parv[5]) &&
!irccmp(target_p->sockhost, parv[7]);
!irccmp(target_p->sockhost, parv[7 + does_rhost]);

/*
* If the users are the same (loaded a client on a different server)
@@ -765,24 +785,43 @@ ms_nick(struct Client *source_p, int parc, char *parv[])
* - parv[ 8] = uid
* - parv[ 9] = services id (account name)
* - parv[10] = ircname (gecos)
* or with CAPAB_RHOST (parc == 12):
* - parv[ 0] = command
* - parv[ 1] = nickname
* - parv[ 2] = hop count
* - parv[ 3] = TS
* - parv[ 4] = umode
* - parv[ 5] = username
* - parv[ 6] = hostname
* - parv[ 7] = real host
* - parv[ 8] = IP address
* - parv[ 9] = uid
* - parv[10] = services id (account name)
* - parv[11] = ircname (gecos)
*/
static int
ms_uid(struct Client *source_p, int parc, char *parv[])
{
struct Client *target_p = NULL;
/* TBR: compatibility mode */
const int does_rhost = parc == 12;

if (check_clean_nick(source_p, parv[1]) ||
check_clean_user(source_p, parv[1], parv[5]) ||
check_clean_host(source_p, parv[1], parv[6]) ||
check_clean_uid(source_p, parv[1], parv[8]))
check_clean_uid(source_p, parv[1], parv[8 + does_rhost]))
return 0;

/* TBR: compatibility mode */
if (does_rhost && check_clean_host(source_p, parv[1], parv[7]))
return 0;

/*
* If there is an ID collision, kill our client, and kill theirs.
* This may generate 401's, but it ensures that both clients always
* go, even if the other server refuses to do the right thing.
*/
if ((target_p = hash_find_id(parv[8])))
if ((target_p = hash_find_id(parv[8 + does_rhost])))
{
sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE,
"ID collision on %s(%s <- %s)(both killed)",
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2017 ircd-hybrid development team
* Copyright (c) 1997-2018 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
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2017 ircd-hybrid development team
* Copyright (c) 1997-2018 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
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2017 ircd-hybrid development team
* Copyright (c) 1997-2018 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
@@ -38,11 +38,13 @@
#include "log.h"
#include "misc.h"
#include "server.h"
#include "server_capab.h"
#include "user.h"
#include "send.h"
#include "parse.h"
#include "memory.h"
#include "modules.h"
#include "fdlist.h"


/*! Parses server flags to be potentially set
@@ -126,13 +128,23 @@ server_send_client(struct Client *client_p, struct Client *target_p)
buf[1] = '\0';
}

sendto_one(client_p, ":%s UID %s %u %ju %s %s %s %s %s %s :%s",
target_p->servptr->id,
target_p->name, target_p->hopcount + 1,
target_p->tsinfo,
buf, target_p->username, target_p->host,
target_p->sockhost, target_p->id,
target_p->account, target_p->info);
/* TBR: compatibility mode */
if (IsCapable(client_p, CAPAB_RHOST))
sendto_one(client_p, ":%s UID %s %u %ju %s %s %s %s %s %s %s :%s",
target_p->servptr->id,
target_p->name, target_p->hopcount + 1,
target_p->tsinfo,
buf, target_p->username, target_p->host, target_p->realhost,
target_p->sockhost, target_p->id,
target_p->account, target_p->info);
else
sendto_one(client_p, ":%s UID %s %u %ju %s %s %s %s %s %s :%s",
target_p->servptr->id,
target_p->name, target_p->hopcount + 1,
target_p->tsinfo,
buf, target_p->username, target_p->host,
target_p->sockhost, target_p->id,
target_p->account, target_p->info);

if (!EmptyString(target_p->certfp))
sendto_one(client_p, ":%s CERTFP %s", target_p->id, target_p->certfp);
@@ -231,7 +243,7 @@ server_estab(struct Client *client_p)
{
sendto_one(client_p, "PASS %s TS %u %s", conf->spasswd, TS_CURRENT, me.id);

sendto_one(client_p, "CAPAB :%s", get_capabilities(NULL));
sendto_one(client_p, "CAPAB :%s", capab_get(NULL));

sendto_one(client_p, "SERVER %s 1 :%s%s",
me.name, ConfigServerHide.hidden ? "(H) " : "", me.info);
@@ -240,17 +252,6 @@ server_estab(struct Client *client_p)
sendto_one(client_p, ":%s SVINFO %u %u 0 :%ju", me.id, TS_CURRENT, TS_MIN,
CurrentTime);

/* *WARNING*
** In the following code in place of plain server's
** name we send what is returned by client_get_name
** which may add the "sockhost" after the name. It's
** *very* *important* that there is a SPACE between
** the name and sockhost (if present). The receiving
** server will start the information field from this
** first blank and thus puts the sockhost into info.
** ...a bit tricky, but you have been warned, besides
** code is more neat this way... --msa
*/
client_p->servptr = &me;

if (HasFlag(client_p, FLAGS_CLOSING))
@@ -275,7 +276,7 @@ server_estab(struct Client *client_p)
hash_add_id(client_p);

/* Doesn't duplicate client_p->serv if allocated this struct already */
make_server(client_p);
server_make(client_p);

/* Fixing eob timings.. -gnp */
client_p->connection->firsttime = CurrentTime;
@@ -284,38 +285,38 @@ 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->ssl))
{
/* 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),
get_capabilities(client_p));
client_get_name(client_p, SHOW_IP), tls_get_cipher(&client_p->connection->fd->ssl),
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),
get_capabilities(client_p));
client_get_name(client_p, MASK_IP), tls_get_cipher(&client_p->connection->fd->ssl),
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),
get_capabilities(client_p));
client_get_name(client_p, SHOW_IP), tls_get_cipher(&client_p->connection->fd->ssl),
capab_get(client_p));
}
else
{
/* Show the real host/IP to admins */
sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE,
"Link with %s established: (Capabilities: %s)",
client_get_name(client_p, SHOW_IP), get_capabilities(client_p));
client_get_name(client_p, SHOW_IP), 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: (Capabilities: %s)",
client_get_name(client_p, MASK_IP), get_capabilities(client_p));
client_get_name(client_p, MASK_IP), capab_get(client_p));
ilog(LOG_TYPE_IRCD, "Link with %s established: (Capabilities: %s)",
client_get_name(client_p, SHOW_IP), get_capabilities(client_p));
client_get_name(client_p, SHOW_IP), capab_get(client_p));
}

fd_note(&client_p->connection->fd, "Server: %s", client_p->name);
fd_note(client_p->connection->fd, "Server: %s", client_p->name);

sendto_server(client_p, 0, 0, ":%s SID %s 2 %s :%s%s",
me.id, client_p->name, client_p->id,
@@ -428,7 +429,7 @@ server_check(const char *name, struct Client *client_p)
if (server_conf == NULL)
return error;

attach_conf(client_p, server_conf);
conf_attach(client_p, server_conf);

switch (server_conf->aftype)
{
@@ -437,15 +438,15 @@ server_check(const char *name, struct Client *client_p)
const struct sockaddr_in6 *v6 = (struct sockaddr_in6 *)&server_conf->addr;

if (IN6_IS_ADDR_UNSPECIFIED(&v6->sin6_addr))
memcpy(&server_conf->addr, &client_p->connection->ip, sizeof(struct irc_ssaddr));
memcpy(&server_conf->addr, &client_p->connection->ip, sizeof(server_conf->addr));
break;
}
case AF_INET:
{
const struct sockaddr_in *v4 = (struct sockaddr_in *)&server_conf->addr;

if (v4->sin_addr.s_addr == INADDR_NONE)
memcpy(&server_conf->addr, &client_p->connection->ip, sizeof(struct irc_ssaddr));
memcpy(&server_conf->addr, &client_p->connection->ip, sizeof(server_conf->addr));
break;
}
}
@@ -648,39 +649,38 @@ static int
ms_sid(struct Client *source_p, int parc, char *parv[])
{
struct Client *target_p = NULL;
struct Client *client_p = source_p->from; /* XXX */

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

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

if (!valid_servname(parv[1]))
{
sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE,
"Link %s introduced server with bogus server name %s",
client_get_name(client_p, SHOW_IP), parv[1]);
client_get_name(source_p->from, SHOW_IP), parv[1]);
sendto_realops_flags(UMODE_SERVNOTICE, L_OPER, SEND_NOTICE,
"Link %s introduced server with bogus server name %s",
client_get_name(client_p, MASK_IP), parv[1]);
exit_client(client_p, "Bogus server name introduced");
client_get_name(source_p->from, MASK_IP), parv[1]);
exit_client(source_p->from, "Bogus server name introduced");
return 0;
}

if (!valid_sid(parv[3]))
{
sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE,
"Link %s introduced server with bogus server ID %s",
client_get_name(client_p, SHOW_IP), parv[3]);
client_get_name(source_p->from, SHOW_IP), parv[3]);
sendto_realops_flags(UMODE_SERVNOTICE, L_OPER, SEND_NOTICE,
"Link %s introduced server with bogus server ID %s",
client_get_name(client_p, MASK_IP), parv[3]);
exit_client(client_p, "Bogus server ID introduced");
client_get_name(source_p->from, MASK_IP), parv[3]);
exit_client(source_p->from, "Bogus server ID introduced");
return 0;
}

@@ -689,11 +689,11 @@ ms_sid(struct Client *source_p, int parc, char *parv[])
{
sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE,
"Link %s cancelled, server ID %s already exists",
client_get_name(client_p, SHOW_IP), parv[3]);
client_get_name(source_p->from, SHOW_IP), parv[3]);
sendto_realops_flags(UMODE_SERVNOTICE, L_OPER, SEND_NOTICE,
"Link %s cancelled, server ID %s already exists",
client_get_name(client_p, MASK_IP), parv[3]);
exit_client(client_p, "Link cancelled, server ID 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;
}

@@ -702,11 +702,11 @@ ms_sid(struct Client *source_p, int parc, char *parv[])
{
sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE,
"Link %s cancelled, server %s already exists",
client_get_name(client_p, SHOW_IP), parv[1]);
client_get_name(source_p->from, SHOW_IP), parv[1]);
sendto_realops_flags(UMODE_SERVNOTICE, L_OPER, SEND_NOTICE,
"Link %s cancelled, server %s already exists",
client_get_name(client_p, MASK_IP), parv[1]);
exit_client(client_p, "Server exists");
client_get_name(source_p->from, MASK_IP), parv[1]);
exit_client(source_p->from, "Server exists");
return 0;
}

@@ -715,7 +715,7 @@ ms_sid(struct Client *source_p, int parc, char *parv[])
* but only if it's not the same client! - Dianora
*/
if ((target_p = find_servconn_in_progress(parv[1])))
if (target_p != client_p)
if (target_p != source_p->from)
exit_client(target_p, "Overridden");

/*
@@ -725,7 +725,7 @@ ms_sid(struct Client *source_p, int parc, char *parv[])
dlink_node *node;
unsigned int hlined = 0;
unsigned int llined = 0;
const struct MaskItem *conf = client_p->connection->confs.head->data;
const struct MaskItem *conf = source_p->from->connection->confs.head->data;

DLINK_FOREACH(node, conf->leaf_list.head)
{
@@ -768,16 +768,16 @@ ms_sid(struct Client *source_p, int parc, char *parv[])
* .edu's
*/

/* Ok, check client_p can hub the new server, and make sure it's not a LL */
/* Ok, check source_p->from can hub the new server */
if (!hlined)
{
/* OOOPs nope can't HUB */
sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE,
"Non-Hub link %s introduced %s.",
client_get_name(client_p, SHOW_IP), parv[1]);
client_get_name(source_p->from, SHOW_IP), parv[1]);
sendto_realops_flags(UMODE_SERVNOTICE, L_OPER, SEND_NOTICE,
"Non-Hub link %s introduced %s.",
client_get_name(client_p, MASK_IP), parv[1]);
client_get_name(source_p->from, MASK_IP), parv[1]);
exit_client(source_p, "No matching hub_mask.");
return 0;
}
@@ -788,16 +788,16 @@ ms_sid(struct Client *source_p, int parc, char *parv[])
/* OOOPs nope can't HUB this leaf */
sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE,
"Link %s introduced leafed server %s.",
client_get_name(client_p, SHOW_IP), parv[1]);
client_get_name(source_p->from, SHOW_IP), parv[1]);
sendto_realops_flags(UMODE_SERVNOTICE, L_OPER, SEND_NOTICE,
"Link %s introduced leafed server %s.",
client_get_name(client_p, MASK_IP), parv[1]);
exit_client(client_p, "Leafed server.");
client_get_name(source_p->from, MASK_IP), parv[1]);
exit_client(source_p->from, "Leafed server.");
return 0;
}

target_p = client_make(client_p);
make_server(target_p);
target_p = client_make(source_p->from);
server_make(target_p);
target_p->hopcount = atoi(parv[2]);
target_p->servptr = source_p;

@@ -823,7 +823,7 @@ ms_sid(struct Client *source_p, int parc, char *parv[])
hash_add_client(target_p);
hash_add_id(target_p);

sendto_server(client_p, 0, 0, ":%s SID %s %u %s :%s%s",
sendto_server(source_p->from, 0, 0, ":%s SID %s %u %s :%s%s",
source_p->id, target_p->name, target_p->hopcount + 1,
target_p->id, IsHidden(target_p) ? "(H) " : "", target_p->info);
sendto_realops_flags(UMODE_EXTERNAL, L_ALL, SEND_NOTICE,
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2017 ircd-hybrid development team
* Copyright (c) 1997-2018 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
@@ -136,8 +136,13 @@ ms_sjoin(struct Client *source_p, int parc, char *parv[])
break;

default:
mode.mode |= ModeTable[(unsigned char)*modes].d;
{
const struct chan_mode *cmode = cmode_map[(unsigned char)*modes];

if (cmode)
mode.mode |= cmode->mode;
break;
}
}
}

@@ -558,8 +563,8 @@ set_final_mode(struct Mode *mode, struct Mode *oldmode)

*mbuf++ = '-';

for (const struct mode_letter *tab = chan_modes; tab->letter; ++tab)
if ((tab->mode & oldmode->mode) && !(tab->mode & mode->mode))
for (const struct chan_mode *tab = cmode_tab; tab->letter; ++tab)
if (tab->mode && (tab->mode & oldmode->mode) && !(tab->mode & mode->mode))
*mbuf++ = tab->letter;

if (oldmode->limit && mode->limit == 0)
@@ -578,8 +583,8 @@ set_final_mode(struct Mode *mode, struct Mode *oldmode)
else
*mbuf++ = '+';

for (const struct mode_letter *tab = chan_modes; tab->letter; ++tab)
if ((tab->mode & mode->mode) && !(tab->mode & oldmode->mode))
for (const struct chan_mode *tab = cmode_tab; tab->letter; ++tab)
if (tab->mode && (tab->mode & mode->mode) && !(tab->mode & oldmode->mode))
*mbuf++ = tab->letter;

if (mode->limit && oldmode->limit != mode->limit)
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2017 ircd-hybrid development team
* Copyright (c) 1997-2018 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
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2017 ircd-hybrid development team
* Copyright (c) 1997-2018 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
@@ -1,7 +1,7 @@
# Makefile.in generated by automake 1.15 from Makefile.am.
# Makefile.in generated by automake 1.15.1 from Makefile.am.
# @configure_input@

# Copyright (C) 1994-2014 Free Software Foundation, Inc.
# Copyright (C) 1994-2017 Free Software Foundation, Inc.

# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -90,21 +90,20 @@ build_triplet = @build@
host_triplet = @host@
subdir = modules/extra
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ac_define_dir.m4 \
$(top_srcdir)/m4/ax_append_compile_flags.m4 \
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_append_compile_flags.m4 \
$(top_srcdir)/m4/ax_append_flag.m4 \
$(top_srcdir)/m4/ax_arg_enable_assert.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_libgeoip.m4 \
$(top_srcdir)/m4/ax_arg_openssl.m4 \
$(top_srcdir)/m4/ax_check_compile_flag.m4 \
$(top_srcdir)/m4/ax_define_dir.m4 \
$(top_srcdir)/m4/ax_gcc_stack_protect.m4 \
$(top_srcdir)/m4/ax_library_net.m4 \
$(top_srcdir)/m4/ax_mempool_chunksizes.m4 \
$(top_srcdir)/m4/ax_require_defined.m4 \
$(top_srcdir)/m4/gcc_stack_protect.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltargz.m4 \
$(top_srcdir)/m4/ltdl.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 2014-2017 ircd-hybrid development team
* Copyright (c) 2014-2018 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
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 2000-2017 ircd-hybrid development team
* Copyright (c) 2000-2018 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
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2017 ircd-hybrid development team
* Copyright (c) 1997-2018 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
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2017 ircd-hybrid development team
* Copyright (c) 1997-2018 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
@@ -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-2017 ircd-hybrid development team
* Copyright (c) 2006-2018 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
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1998-2017 ircd-hybrid development team
* Copyright (c) 1998-2018 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
@@ -27,7 +27,7 @@
#include "stdinc.h"
#include "client.h"
#include "irc_string.h"
#include "server.h"
#include "server_capab.h"
#include "parse.h"
#include "modules.h"

@@ -51,7 +51,7 @@ mr_capab(struct Client *source_p, int parc, char *parv[])

for (const char *s = strtok_r(parv[1], " ", &p); s;
s = strtok_r(NULL, " ", &p))
if ((cap = find_capability(s)))
if ((cap = capab_find(s)))
SetCapable(source_p, cap);

return 0;
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 2013-2017 ircd-hybrid development team
* Copyright (c) 2013-2018 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
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2017 ircd-hybrid development team
* Copyright (c) 1997-2018 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
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2017 ircd-hybrid development team
* Copyright (c) 1997-2018 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
@@ -82,13 +82,12 @@ mo_connect(struct Client *source_p, int parc, char *parv[])
}

/*
* Try to find the name, then host, if both fail notify and bail
* Try to find the name. If it fails, notify and bail.
*/
struct MaskItem *conf;
if (!(conf = connect_find(name, NULL, match)) &&
!(conf = connect_find(NULL, name, match)))
if (!(conf = connect_find(name, match)))
{
sendto_one_notice(source_p, &me, ":Connect: Host %s not listed in configuration file", name);
sendto_one_notice(source_p, &me, ":Connect: Server %s not listed in configuration file", name);
return 0;
}

@@ -113,7 +112,7 @@ mo_connect(struct Client *source_p, int parc, char *parv[])
* At this point we should be calling connect_server with a valid
* connect{} block and a valid port in the connect{} block
*/
if (serv_connect(conf, source_p))
if (server_connect(conf, source_p))
{
if (!ConfigServerHide.hide_server_ips && HasUMode(source_p, UMODE_ADMIN))
sendto_one_notice(source_p, &me, ":*** Connecting to %s[%s].%u",
@@ -162,13 +161,12 @@ ms_connect(struct Client *source_p, int parc, char *parv[])
return 0;

/*
* Try to find the name, then host, if both fail notify and bail
* Try to find the name. If it fails, notify and bail.
*/
struct MaskItem *conf;
if (!(conf = connect_find(name, NULL, match)) &&
!(conf = connect_find(NULL, name, match)))
if (!(conf = connect_find(name, match)))
{
sendto_one_notice(source_p, &me, ":Connect: Host %s not listed in configuration file", name);
sendto_one_notice(source_p, &me, ":Connect: Server %s not listed in configuration file", name);
return 0;
}

@@ -201,7 +199,7 @@ ms_connect(struct Client *source_p, int parc, char *parv[])
* At this point we should be calling connect_server with a valid
* connect{} block and a valid port in the connect{} block
*/
if (serv_connect(conf, source_p))
if (server_connect(conf, source_p))
sendto_one_notice(source_p, &me, ":*** Connecting to %s.%u",
conf->name, conf->port);
else
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2017 ircd-hybrid development team
* Copyright (c) 1997-2018 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
@@ -37,7 +37,7 @@
#include "log.h"
#include "misc.h"
#include "send.h"
#include "server.h"
#include "server_capab.h"
#include "parse.h"
#include "modules.h"
#include "memory.h"
@@ -321,14 +321,14 @@ static void
module_init(void)
{
mod_add_cmd(&dline_msgtab);
add_capability("DLN", CAPAB_DLN);
capab_add("DLN", CAPAB_DLN);
}

static void
module_exit(void)
{
mod_del_cmd(&dline_msgtab);
delete_capability("DLN");
capab_del("DLN");
}

struct module module_entry =
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 2003-2017 ircd-hybrid development team
* Copyright (c) 2003-2018 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
@@ -27,7 +27,7 @@
#include "stdinc.h"
#include "client.h"
#include "parse.h"
#include "server.h"
#include "server_capab.h"
#include "send.h"
#include "modules.h"
#include "irc_string.h"
@@ -52,8 +52,9 @@ ms_encap(struct Client *source_p, int parc, char *parv[])

for (i = 1; i < (unsigned int)parc - 1; ++i)
{
len = strlen(parv[i]) + 1;
len = strlen(parv[i]) + 1; /* +1 for the space */

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

@@ -107,14 +108,14 @@ static void
module_init(void)
{
mod_add_cmd(&encap_msgtab);
add_capability("ENCAP", CAPAB_ENCAP);
capab_add("ENCAP", CAPAB_ENCAP);
}

static void
module_exit(void)
{
mod_del_cmd(&encap_msgtab);
delete_capability("ENCAP");
capab_del("ENCAP");
}

struct module module_entry =
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 2000-2017 ircd-hybrid development team
* Copyright (c) 2000-2018 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
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 2004-2017 ircd-hybrid development team
* Copyright (c) 2004-2018 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
@@ -66,49 +66,28 @@ report_this_status(struct Client *source_p, const struct Client *target_p)
* do_etrace()
*/
static void
do_etrace(struct Client *source_p, const char *arg)
do_etrace(struct Client *source_p, const char *name)
{
const char *tname = NULL;
unsigned int wilds = 0, do_all = 0;
int doall = 0;
dlink_node *node;

sendto_realops_flags(UMODE_SPY, L_ALL, SEND_NOTICE,
"ETRACE requested by %s (%s@%s) [%s]",
source_p->name, source_p->username,
source_p->host, source_p->servptr->name);

if (EmptyString(arg))
{
do_all = 1;
tname = "*";
}
else
{
tname = arg;
wilds = has_wildcards(tname);

if (!match(tname, me.name))
do_all = 1;
else if (!MyClient(source_p) && !strcmp(tname, me.id))
do_all = 1;
}

if (!wilds && !do_all)
{
const struct Client *target_p = find_person(source_p, tname);

if (target_p && MyConnect(target_p))
report_this_status(source_p, target_p);

sendto_one_numeric(source_p, &me, RPL_ETRACEEND, me.name);
return;
}
if (EmptyString(name))
doall = 1;
else if (!match(name, me.name))
doall = 1;
else if (!MyClient(source_p) && !strcmp(name, me.id))
doall = 1;

DLINK_FOREACH(node, local_client_list.head)
{
const struct Client *target_p = node->data;

if (!wilds || !match(tname, target_p->name))
if (doall || match(name, target_p->name) == 0)
report_this_status(source_p, target_p);
}

@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 2011-2017 ircd-hybrid development team
* Copyright (c) 2011-2018 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
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2017 ircd-hybrid development team
* Copyright (c) 1997-2018 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
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1999-2017 ircd-hybrid development team
* Copyright (c) 1999-2018 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
@@ -92,7 +92,7 @@ do_help(struct Client *source_p, char *topic)
return;
}

char path[sizeof(HPATH) + strlen(topic) + 1]; /* +1 for / */
char path[sizeof(HPATH) + IRCD_BUFSIZE + 1]; /* +1 for / */
snprintf(path, sizeof(path), "%s/%s", HPATH, topic);

if (stat(path, &sb) < 0)
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2017 ircd-hybrid development team
* Copyright (c) 1997-2018 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
@@ -148,18 +148,6 @@ static const struct InfoStruct info_table[] =
&ConfigServerInfo.max_topic_length,
"Maximum topic length"
},
{
"libgeoip_ipv4_database_file",
OUTPUT_STRING,
&ConfigServerInfo.libgeoip_ipv4_database_file,
"Path to the libGeoIP IPv4 database file"
},
{
"libgeoip_ipv6_database_file",
OUTPUT_STRING,
&ConfigServerInfo.libgeoip_ipv6_database_file,
"Path to the libGeoIP IPv6 database file"
},
{
"use_logging",
OUTPUT_BOOLEAN_YN,
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2017 ircd-hybrid development team
* Copyright (c) 1997-2018 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
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2017 ircd-hybrid development team
* Copyright (c) 1997-2018 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
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2017 ircd-hybrid development team
* Copyright (c) 1997-2018 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
@@ -37,7 +37,7 @@
#include "log.h"
#include "misc.h"
#include "send.h"
#include "server.h"
#include "server_capab.h"
#include "parse.h"
#include "modules.h"
#include "memory.h"
@@ -289,14 +289,14 @@ static void
module_init(void)
{
mod_add_cmd(&kline_msgtab);
add_capability("KLN", CAPAB_KLN);
capab_add("KLN", CAPAB_KLN);
}

static void
module_exit(void)
{
mod_del_cmd(&kline_msgtab);
delete_capability("KLN");
capab_del("KLN");
}

struct module module_entry =
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1998-2017 ircd-hybrid development team
* Copyright (c) 1998-2018 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
@@ -37,7 +37,7 @@
#include "conf.h"
#include "parse.h"
#include "modules.h"
#include "server.h"
#include "server_capab.h"
#include "user.h"
#include "isupport.h"

@@ -146,15 +146,15 @@ static void
module_init(void)
{
mod_add_cmd(&knock_msgtab);
add_capability("KNOCK", CAPAB_KNOCK);
capab_add("KNOCK", CAPAB_KNOCK);
isupport_add("KNOCK", NULL, -1);
}

static void
module_exit(void)
{
mod_del_cmd(&knock_msgtab);
delete_capability("KNOCK");
capab_del("KNOCK");
isupport_delete("KNOCK");
}

@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2017 ircd-hybrid development team
* Copyright (c) 1997-2018 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
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2017 ircd-hybrid development team
* Copyright (c) 1997-2018 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 @@ do_list(struct Client *source_p, char *arg)
return;
}

struct ListTask *lt = xcalloc(sizeof(struct ListTask));
struct ListTask *lt = xcalloc(sizeof(*lt));
lt->users_max = UINT_MAX;
lt->created_max = UINT_MAX;
lt->topicts_max = UINT_MAX;
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2017 ircd-hybrid development team
* Copyright (c) 1997-2018 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
@@ -33,7 +33,7 @@
#include "conf.h"
#include "conf_cluster.h"
#include "conf_shared.h"
#include "server.h"
#include "server_capab.h"
#include "parse.h"
#include "modules.h"

@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2017 ircd-hybrid development team
* Copyright (c) 1997-2018 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
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 2001-2017 ircd-hybrid development team
* Copyright (c) 2001-2018 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
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 2000-2017 ircd-hybrid development team
* Copyright (c) 2000-2018 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
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2017 ircd-hybrid development team
* Copyright (c) 1997-2018 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
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2017 ircd-hybrid development team
* Copyright (c) 1997-2018 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
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2017 ircd-hybrid development team
* Copyright (c) 1997-2018 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
@@ -72,7 +72,7 @@ oper_up(struct Client *source_p)

if (!EmptyString(conf->whois))
{
client_attach_svstag(source_p, RPL_WHOISOPERATOR, "+", conf->whois);
client_attach_svstag(&source_p->svstags, RPL_WHOISOPERATOR, "+", conf->whois);
sendto_server(source_p, 0, 0, ":%s SVSTAG %s %ju %u + :%s",
me.id, source_p->id, source_p->tsinfo,
RPL_WHOISOPERATOR, conf->whois);
@@ -166,7 +166,7 @@ m_oper(struct Client *source_p, int parc, char *parv[])

if (match_conf_password(password, conf))
{
if (attach_conf(source_p, conf))
if (conf_attach(source_p, conf))
{
sendto_one_notice(source_p, &me, ":Can't attach conf!");
failed_oper_notice(source_p, opername, "can't attach conf!");
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2017 ircd-hybrid development team
* Copyright (c) 1997-2018 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
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2017 ircd-hybrid development team
* Copyright (c) 1997-2018 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
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2017 ircd-hybrid development team
* Copyright (c) 1997-2018 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
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 2001-2017 ircd-hybrid development team
* Copyright (c) 2001-2018 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
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2017 ircd-hybrid development team
* Copyright (c) 1997-2018 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
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2017 ircd-hybrid development team
* Copyright (c) 1997-2018 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
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 2001-2017 ircd-hybrid development team
* Copyright (c) 2001-2018 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
@@ -29,7 +29,7 @@
#include "ircd.h"
#include "irc_string.h"
#include "numeric.h"
#include "server.h"
#include "server_capab.h"
#include "send.h"
#include "parse.h"
#include "modules.h"
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2017 ircd-hybrid development team
* Copyright (c) 1997-2018 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 @@ quote_autoconn(struct Client *source_p, const char *arg, int newval)
{
if (!EmptyString(arg))
{
struct MaskItem *conf = connect_find(arg, NULL, irccmp);
struct MaskItem *conf = connect_find(arg, irccmp);

if (conf)
{
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2017 ircd-hybrid development team
* Copyright (c) 1997-2018 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,6 +43,7 @@
#include "fdlist.h"
#include "misc.h"
#include "server.h"
#include "server_capab.h"
#include "event.h"
#include "parse.h"
#include "modules.h"
@@ -74,7 +75,7 @@ report_shared(struct Client *source_p)
};

dlink_node *node;
char buf[sizeof(flag_table) / sizeof(struct shared_types) + 1]; /* +1 for 'c' */
char buf[sizeof(flag_table) / sizeof(flag_table[0]) + 1]; /* +1 for 'c' */

DLINK_FOREACH(node, shared_get_list()->head)
{
@@ -117,7 +118,7 @@ report_cluster(struct Client *source_p)
};

dlink_node *node;
char buf[sizeof(flag_table) / sizeof(struct cluster_types) + 1]; /* +1 for 'C' */
char buf[sizeof(flag_table) / sizeof(flag_table[0]) + 1]; /* +1 for 'C' */

DLINK_FOREACH(node, cluster_get_list()->head)
{
@@ -569,6 +570,19 @@ stats_events(struct Client *source_p, int parc, char *parv[])
}
}

static void
stats_fdlist(struct Client *source_p, int parc, char *parv[])
{
for (int fd = 0; fd <= highest_fd; ++fd)
{
const fde_t *F = &fd_table[fd];

if (F->flags.open)
sendto_one_numeric(source_p, &me, RPL_STATSDEBUG | SND_EXPLICIT,
"F :fd %-5d desc '%s'", F->fd, F->desc);
}
}

static void
stats_hubleaf(struct Client *source_p, int parc, char *parv[])
{
@@ -911,72 +925,62 @@ static void
stats_tstats(struct Client *source_p, int parc, char *parv[])
{
dlink_node *node;
struct ServerStatistics tmp;
struct ServerStatistics *sp = &tmp;

memcpy(sp, &ServerStats, sizeof(struct ServerStatistics));
struct ServerStatistics sp;

/*
* must use the += operator. is_sv is not the number of currently
* active server connections. Note the incrementation in
* s_bsd.c:close_connection.
*/
sp->is_sv += dlink_list_length(&local_server_list);
memcpy(&sp, &ServerStats, sizeof(sp));

DLINK_FOREACH(node, local_server_list.head)
{
const struct Client *target_p = node->data;

sp->is_sbs += target_p->connection->send.bytes;
sp->is_sbr += target_p->connection->recv.bytes;
sp->is_sti += CurrentTime - target_p->connection->firsttime;
sp.is_sbs += target_p->connection->send.bytes;
sp.is_sbr += target_p->connection->recv.bytes;
sp.is_sti += CurrentTime - target_p->connection->firsttime;
sp.is_sv++;
}

sp->is_cl += dlink_list_length(&local_client_list);

DLINK_FOREACH(node, local_client_list.head)
{
const struct Client *target_p = node->data;

sp->is_cbs += target_p->connection->send.bytes;
sp->is_cbr += target_p->connection->recv.bytes;
sp->is_cti += CurrentTime - target_p->connection->firsttime;
sp.is_cbs += target_p->connection->send.bytes;
sp.is_cbr += target_p->connection->recv.bytes;
sp.is_cti += CurrentTime - target_p->connection->firsttime;
sp.is_cl++;
}

sp->is_ni += dlink_list_length(&unknown_list);

sendto_one_numeric(source_p, &me, RPL_STATSDEBUG | SND_EXPLICIT,
"t :accepts %u refused %u",
sp->is_ac, sp->is_ref);
sp.is_ac, sp.is_ref);
sendto_one_numeric(source_p, &me, RPL_STATSDEBUG | SND_EXPLICIT,
"t :unknown commands %u prefixes %u",
sp->is_unco, sp->is_unpf);
sp.is_unco, sp.is_unpf);
sendto_one_numeric(source_p, &me, RPL_STATSDEBUG | SND_EXPLICIT,
"t :nick collisions %u unknown closes %u",
sp->is_kill, sp->is_ni);
sp.is_kill, sp.is_ni);
sendto_one_numeric(source_p, &me, RPL_STATSDEBUG | SND_EXPLICIT,
"t :wrong direction %u empty %u",
sp->is_wrdi, sp->is_empt);
sp.is_wrdi, sp.is_empt);
sendto_one_numeric(source_p, &me, RPL_STATSDEBUG | SND_EXPLICIT,
"t :numerics seen %u",
sp->is_num);
sp.is_num);
sendto_one_numeric(source_p, &me, RPL_STATSDEBUG | SND_EXPLICIT,
"t :auth successes %u fails %u",
sp->is_asuc, sp->is_abad);
sp.is_asuc, sp.is_abad);
sendto_one_numeric(source_p, &me, RPL_STATSDEBUG | SND_EXPLICIT,
"t :Client Server");
sendto_one_numeric(source_p, &me, RPL_STATSDEBUG | SND_EXPLICIT,
"t :connected %u %u",
sp->is_cl, sp->is_sv);
sp.is_cl, sp.is_sv);
sendto_one_numeric(source_p, &me, RPL_STATSDEBUG | SND_EXPLICIT,
"t :bytes sent %ju %ju",
sp->is_cbs, sp->is_sbs);
sp.is_cbs, sp.is_sbs);
sendto_one_numeric(source_p, &me, RPL_STATSDEBUG | SND_EXPLICIT,
"t :bytes received %ju %ju",
sp->is_cbr, sp->is_sbr);
sp.is_cbr, sp.is_sbr);
sendto_one_numeric(source_p, &me, RPL_STATSDEBUG | SND_EXPLICIT,
"t :time connected %ju %ju",
sp->is_cti, sp->is_sti);
sp.is_cti, sp.is_sti);
}

static void
@@ -1083,7 +1087,7 @@ stats_servlinks(struct Client *source_p, int parc, char *parv[])
target_p->connection->recv.bytes >> 10,
(unsigned int)(CurrentTime - target_p->connection->firsttime),
(CurrentTime > target_p->connection->since) ? (unsigned int)(CurrentTime - target_p->connection->since) : 0,
HasUMode(source_p, UMODE_OPER) ? get_capabilities(target_p) : "TS");
HasUMode(source_p, UMODE_OPER) ? capab_get(target_p) : "TS");
}

sendB >>= 10;
@@ -1182,7 +1186,7 @@ stats_L_list(struct Client *source_p, const char *name, int doall, int wilds,
target_p->connection->recv.bytes >> 10,
(unsigned int)(CurrentTime - target_p->connection->firsttime),
(CurrentTime > target_p->connection->since) ? (unsigned int)(CurrentTime - target_p->connection->since) : 0,
IsServer(target_p) ? get_capabilities(target_p) : "-");
IsServer(target_p) ? capab_get(target_p) : "-");
}
}

@@ -1238,8 +1242,8 @@ static const struct StatsStruct stats_tab[] =
{ 'D', stats_deny, UMODE_OPER },
{ 'e', stats_exempt, UMODE_OPER },
{ 'E', stats_events, UMODE_ADMIN },
{ 'f', fd_dump, UMODE_ADMIN },
{ 'F', fd_dump, UMODE_ADMIN },
{ 'f', stats_fdlist, UMODE_ADMIN },
{ 'F', stats_fdlist, UMODE_ADMIN },
{ 'h', stats_hubleaf, UMODE_OPER },
{ 'H', stats_hubleaf, UMODE_OPER },
{ 'i', stats_auth, 0 },
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2017 ircd-hybrid development team
* Copyright (c) 1997-2018 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
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 2016-2017 ircd-hybrid development team
* Copyright (c) 2016-2018 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,14 +45,12 @@
* - parv[0] = command
* - parv[1] = nickname
* - parv[2] = TS
* - parv[3] = +|-
* - parv[4] = host name
* - parv[3] = host name
*/
static int
ms_svshost(struct Client *source_p, int parc, char *parv[])
{
struct Client *target_p = NULL;
int what = MODE_ADD;

if (!HasFlag(source_p, FLAGS_SERVICE))
return 0;
@@ -64,30 +62,19 @@ ms_svshost(struct Client *source_p, int parc, char *parv[])
if (ts && (ts != target_p->tsinfo))
return 0;

switch (*parv[3])
{
case '+':
what = MODE_ADD;
break;
case '-':
what = MODE_DEL;
break;
default: return 0;
}
if (valid_hostname(parv[3]))
user_set_hostmask(target_p, parv[3]);

if (valid_hostname(parv[4]))
user_set_hostmask(target_p, parv[4], what);

sendto_server(source_p, 0, 0, ":%s SVSHOST %s %ju %s %s",
sendto_server(source_p, 0, 0, ":%s SVSHOST %s %ju %s",
source_p->id,
target_p->id, target_p->tsinfo, parv[3], parv[4]);
target_p->id, target_p->tsinfo, parv[3]);
return 0;
}

static struct Message svshost_msgtab =
{
.cmd = "SVSHOST",
.args_min = 5,
.args_min = 4,
.args_max = MAXPARA,
.handlers[UNREGISTERED_HANDLER] = m_ignore,
.handlers[CLIENT_HANDLER] = m_ignore,
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 2014-2017 ircd-hybrid development team
* Copyright (c) 2014-2018 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
@@ -2,7 +2,7 @@
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1999 Bahamut development team.
* Copyright (c) 2013-2017 ircd-hybrid development team
* Copyright (c) 2013-2018 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
@@ -2,7 +2,7 @@
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1999 Bahamut development team.
* Copyright (c) 2011-2017 ircd-hybrid development team
* Copyright (c) 2011-2018 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
@@ -99,7 +99,7 @@ ms_svsmode(struct Client *source_p, int parc, char *parv[])

case 'x':
if (!EmptyString(extarg) && valid_hostname(extarg))
user_set_hostmask(target_p, extarg, what);
user_set_hostmask(target_p, extarg);
break;

case 'o':
@@ -110,9 +110,10 @@ ms_svsmode(struct Client *source_p, int parc, char *parv[])

if (MyConnect(target_p))
{
dlink_node *node = NULL;
dlink_node *node;

detach_conf(target_p, CONF_OPER);
client_detach_svstag(&target_p->svstags, RPL_WHOISOPERATOR);
conf_detach(target_p, CONF_OPER);
ClrOFlag(target_p);
DelUMode(target_p, ConfigGeneral.oper_only_umodes);

@@ -2,7 +2,7 @@
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1999 Bahamut development team.
* Copyright (c) 2011-2017 ircd-hybrid development team
* Copyright (c) 2011-2018 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
@@ -145,7 +145,7 @@ ms_svsnick(struct Client *source_p, int parc, char *parv[])

watch_check_hash(target_p, RPL_LOGON);

fd_note(&target_p->connection->fd, "Nick: %s", target_p->name);
fd_note(target_p->connection->fd, "Nick: %s", target_p->name);
return 0;
}

@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 2014-2017 ircd-hybrid development team
* Copyright (c) 2014-2018 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
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 2015-2017 ircd-hybrid development team
* Copyright (c) 2015-2018 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
@@ -66,7 +66,7 @@ ms_svstag(struct Client *source_p, int parc, char *parv[])
if (!strncmp(parv[3], "-", 1))
{
/* XXX: possibly allow to remove certain tags by numeric */
client_clear_svstags(target_p);
client_clear_svstags(&target_p->svstags);
sendto_server(source_p, 0, 0, ":%s SVSTAG %s %ju %s",
source_p->id,
target_p->id, target_p->tsinfo, parv[3]);
@@ -76,7 +76,7 @@ ms_svstag(struct Client *source_p, int parc, char *parv[])
if (parc < 6 || EmptyString(parv[5]))
return 0;

client_attach_svstag(target_p, strtoul(parv[3], NULL, 10),
client_attach_svstag(&target_p->svstags, strtoul(parv[3], NULL, 10),
parv[4], parv[5]);

sendto_server(source_p, 0, 0, ":%s SVSTAG %s %ju %s %s :%s",
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 2002-2017 ircd-hybrid development team
* Copyright (c) 2002-2018 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
@@ -30,7 +30,7 @@
#include "send.h"
#include "modules.h"
#include "hash.h"
#include "server.h"
#include "server_capab.h"
#include "conf.h"
#include "parse.h"

@@ -134,14 +134,14 @@ static void
module_init(void)
{
mod_add_cmd(&tburst_msgtab);
add_capability("TBURST", CAPAB_TBURST);
capab_add("TBURST", CAPAB_TBURST);
}

static void
module_exit(void)
{
mod_del_cmd(&tburst_msgtab);
delete_capability("TBURST");
capab_del("TBURST");
}

struct module module_entry =
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2017 ircd-hybrid development team
* Copyright (c) 1997-2018 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
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2017 ircd-hybrid development team
* Copyright (c) 1997-2018 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
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2017 ircd-hybrid development team
* Copyright (c) 1997-2018 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,12 +121,12 @@ report_this_status(struct Client *source_p, const struct Client *target_p)
}

static void
do_trace(struct Client *source_p, const char *arg)
do_trace(struct Client *source_p, const char *name)
{
int doall = 0;
int wilds = 0, dow = 0;
dlink_node *node;
const char *name;
const dlink_node *node;
const dlink_list *tab[] = { &local_client_list,
&local_server_list, &unknown_list, NULL };

assert(HasUMode(source_p, UMODE_OPER));

@@ -135,76 +135,33 @@ do_trace(struct Client *source_p, const char *arg)
source_p->name, source_p->username,
source_p->host, source_p->servptr->name);

if (EmptyString(arg))
name = me.name;
else
name = arg;

if (!match(name, me.name))
if (EmptyString(name))
doall = 1;
else if (!match(name, me.name))
doall = 1;
else if (!MyClient(source_p) && !strcmp(name, me.id))
{
doall = 1;
name = me.name;
}

wilds = EmptyString(arg) || has_wildcards(name);
dow = wilds || doall;

if (!dow) /* lets also do this for opers tracing nicks */
{
const struct Client *target_p = find_person(source_p, name);
if (target_p)
report_this_status(source_p, target_p);

sendto_one_numeric(source_p, &me, RPL_TRACEEND, me.name);
return;
}

/* report all direct connections */
DLINK_FOREACH(node, local_client_list.head)
{
const struct Client *target_p = node->data;

if (!doall && wilds && match(name, target_p->name))
continue;
if (!dow && irccmp(name, target_p->name))
continue;

report_this_status(source_p, target_p);
}

DLINK_FOREACH(node, local_server_list.head)
for (const dlink_list **list = tab; *list; ++list)
{
const struct Client *target_p = node->data;

if (!doall && wilds && match(name, target_p->name))
continue;
if (!dow && irccmp(name, target_p->name))
continue;

report_this_status(source_p, target_p);
}

/* This section is to report the unknowns */
DLINK_FOREACH(node, unknown_list.head)
{
const struct Client *target_p = node->data;

if (!doall && wilds && match(name, target_p->name))
continue;
if (!dow && irccmp(name, target_p->name))
continue;
DLINK_FOREACH(node, (*list)->head)
{
const struct Client *target_p = node->data;

report_this_status(source_p, target_p);
if (doall || match(name, target_p->name) == 0)
report_this_status(source_p, target_p);
}
}

DLINK_FOREACH(node, class_get_list()->head)
if (doall)
{
const struct ClassItem *class = node->data;
DLINK_FOREACH(node, class_get_list()->head)
{
const struct ClassItem *class = node->data;

if (class->ref_count)
sendto_one_numeric(source_p, &me, RPL_TRACECLASS, class->name, class->ref_count);
if (class->ref_count)
sendto_one_numeric(source_p, &me, RPL_TRACECLASS, class->name, class->ref_count);
}
}

sendto_one_numeric(source_p, &me, RPL_TRACEEND, me.name);
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2017 ircd-hybrid development team
* Copyright (c) 1997-2018 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
@@ -37,7 +37,7 @@
#include "log.h"
#include "misc.h"
#include "send.h"
#include "server.h"
#include "server_capab.h"
#include "parse.h"
#include "modules.h"
#include "memory.h"
@@ -199,14 +199,14 @@ static void
module_init(void)
{
mod_add_cmd(&undline_msgtab);
add_capability("UNDLN", CAPAB_UNDLN);
capab_add("UNDLN", CAPAB_UNDLN);
}

static void
module_exit(void)
{
mod_del_cmd(&undline_msgtab);
delete_capability("UNDLN");
capab_del("UNDLN");
}

struct module module_entry =
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2017 ircd-hybrid development team
* Copyright (c) 1997-2018 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
@@ -37,7 +37,7 @@
#include "log.h"
#include "misc.h"
#include "send.h"
#include "server.h"
#include "server_capab.h"
#include "parse.h"
#include "modules.h"
#include "memory.h"
@@ -205,14 +205,14 @@ static void
module_init(void)
{
mod_add_cmd(&unkline_msgtab);
add_capability("UNKLN", CAPAB_UNKLN);
capab_add("UNKLN", CAPAB_UNKLN);
}

static void
module_exit(void)
{
mod_del_cmd(&unkline_msgtab);
delete_capability("UNKLN");
capab_del("UNKLN");
}

struct module module_entry =
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 2001-2017 ircd-hybrid development team
* Copyright (c) 2001-2018 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
@@ -36,7 +36,7 @@
#include "numeric.h"
#include "log.h"
#include "send.h"
#include "server.h"
#include "server_capab.h"
#include "parse.h"
#include "modules.h"
#include "memory.h"
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 2003-2017 ircd-hybrid development team
* Copyright (c) 2003-2018 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
@@ -36,7 +36,7 @@
#include "numeric.h"
#include "log.h"
#include "send.h"
#include "server.h"
#include "server_capab.h"
#include "parse.h"
#include "modules.h"
#include "memory.h"
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2017 ircd-hybrid development team
* Copyright (c) 1997-2018 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
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2017 ircd-hybrid development team
* Copyright (c) 1997-2018 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,7 +49,7 @@ static int
m_userhost(struct Client *source_p, int parc, char *parv[])
{
char buf[IRCD_BUFSIZE];
char response[NICKLEN * 2 + USERLEN + HOSTLEN + 30];
char response[NICKLEN + USERLEN + HOSTLEN + 6]; /* +6 for "*=+@ \0" */
char *t = NULL, *p = NULL, *nick = NULL;
int i = 0;
int cur_len;
@@ -70,7 +70,7 @@ m_userhost(struct Client *source_p, int parc, char *parv[])
* lookup (USERHOST) to figure out what the clients' local IP
* is. Useful for things like NAT, and dynamic dial-up users.
*/
if (MyConnect(target_p) && (target_p == source_p))
if (target_p == source_p)
{
rl = snprintf(response, sizeof(response), "%s%s=%c%s@%s ",
target_p->name,
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2017 ircd-hybrid development team
* Copyright (c) 1997-2018 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
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2017 ircd-hybrid development team
* Copyright (c) 1997-2018 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
@@ -2,7 +2,7 @@
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997 Jukka Santala (Donwulff)
* Copyright (c) 2000-2017 ircd-hybrid development team
* Copyright (c) 2000-2018 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
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 2012-2017 ircd-hybrid development team
* Copyright (c) 2012-2018 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
@@ -114,7 +114,15 @@ mr_webirc(struct Client *source_p, int parc, char *parv[])
freeaddrinfo(res);

strlcpy(source_p->sockhost, addr, sizeof(source_p->sockhost));

if (source_p->sockhost[0] == ':')
{
memmove(source_p->sockhost + 1, source_p->sockhost, sizeof(source_p->sockhost) - 1);
source_p->sockhost[0] = '0';
}

strlcpy(source_p->host, host, sizeof(source_p->host));
strlcpy(source_p->realhost, host, sizeof(source_p->realhost));

/* Check dlines now, k-lines will be checked on registration */
if ((conf = find_dline_conf(&source_p->connection->ip,
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2017 ircd-hybrid development team
* Copyright (c) 1997-2018 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
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2017 ircd-hybrid development team
* Copyright (c) 1997-2018 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
@@ -186,7 +186,7 @@ whois_person(struct Client *source_p, struct Client *target_p)

if (HasUMode(source_p, UMODE_OPER) || source_p == target_p)
sendto_one_numeric(source_p, &me, RPL_WHOISACTUALLY, target_p->name,
target_p->username, target_p->host,
target_p->username, target_p->realhost,
target_p->sockhost);

if (HasUMode(target_p, UMODE_SSL))
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2017 ircd-hybrid development team
* Copyright (c) 1997-2018 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
@@ -66,7 +66,7 @@ do_whowas(struct Client *source_p, const int parc, char *parv[])

if (HasUMode(source_p, UMODE_OPER))
sendto_one_numeric(source_p, &me, RPL_WHOISACTUALLY, whowas->name,
whowas->username, whowas->hostname,
whowas->username, whowas->realhost,
whowas->sockhost);

if (strcmp(whowas->account, "*"))
@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 2003-2017 ircd-hybrid development team
* Copyright (c) 2003-2018 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
@@ -37,7 +37,7 @@
#include "log.h"
#include "misc.h"
#include "send.h"
#include "server.h"
#include "server_capab.h"
#include "parse.h"
#include "modules.h"
#include "memory.h"
@@ -41,7 +41,6 @@ ircd_SOURCES = auth.c \
log.c \
match.c \
memory.c \
mempool.c \
misc.c \
modules.c \
motd.c \
@@ -62,6 +61,7 @@ ircd_SOURCES = auth.c \
s_bsd.c \
send.c \
server.c \
server_capab.c \
user.c \
userhost.c \
version.c \
@@ -1,7 +1,7 @@
# Makefile.in generated by automake 1.15 from Makefile.am.
# Makefile.in generated by automake 1.15.1 from Makefile.am.
# @configure_input@

# Copyright (C) 1994-2014 Free Software Foundation, Inc.
# Copyright (C) 1994-2017 Free Software Foundation, Inc.

# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -91,21 +91,20 @@ host_triplet = @host@
bin_PROGRAMS = ircd$(EXEEXT)
subdir = src
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ac_define_dir.m4 \
$(top_srcdir)/m4/ax_append_compile_flags.m4 \
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_append_compile_flags.m4 \
$(top_srcdir)/m4/ax_append_flag.m4 \
$(top_srcdir)/m4/ax_arg_enable_assert.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_libgeoip.m4 \
$(top_srcdir)/m4/ax_arg_openssl.m4 \
$(top_srcdir)/m4/ax_check_compile_flag.m4 \
$(top_srcdir)/m4/ax_define_dir.m4 \
$(top_srcdir)/m4/ax_gcc_stack_protect.m4 \
$(top_srcdir)/m4/ax_library_net.m4 \
$(top_srcdir)/m4/ax_mempool_chunksizes.m4 \
$(top_srcdir)/m4/ax_require_defined.m4 \
$(top_srcdir)/m4/gcc_stack_protect.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltargz.m4 \
$(top_srcdir)/m4/ltdl.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
@@ -130,14 +129,14 @@ am_ircd_OBJECTS = auth.$(OBJEXT) channel.$(OBJEXT) \
ipcache.$(OBJEXT) irc_string.$(OBJEXT) ircd.$(OBJEXT) \
ircd_signal.$(OBJEXT) isupport.$(OBJEXT) list.$(OBJEXT) \
listener.$(OBJEXT) log.$(OBJEXT) match.$(OBJEXT) \
memory.$(OBJEXT) mempool.$(OBJEXT) misc.$(OBJEXT) \
modules.$(OBJEXT) motd.$(OBJEXT) numeric.$(OBJEXT) \
packet.$(OBJEXT) parse.$(OBJEXT) s_bsd_epoll.$(OBJEXT) \
s_bsd_poll.$(OBJEXT) s_bsd_devpoll.$(OBJEXT) \
s_bsd_kqueue.$(OBJEXT) tls_gnutls.$(OBJEXT) tls_none.$(OBJEXT) \
tls_openssl.$(OBJEXT) res.$(OBJEXT) reslib.$(OBJEXT) \
restart.$(OBJEXT) rng_mt.$(OBJEXT) s_bsd.$(OBJEXT) \
send.$(OBJEXT) server.$(OBJEXT) user.$(OBJEXT) \
memory.$(OBJEXT) misc.$(OBJEXT) modules.$(OBJEXT) \
motd.$(OBJEXT) numeric.$(OBJEXT) packet.$(OBJEXT) \
parse.$(OBJEXT) s_bsd_epoll.$(OBJEXT) s_bsd_poll.$(OBJEXT) \
s_bsd_devpoll.$(OBJEXT) s_bsd_kqueue.$(OBJEXT) \
tls_gnutls.$(OBJEXT) tls_none.$(OBJEXT) tls_openssl.$(OBJEXT) \
res.$(OBJEXT) reslib.$(OBJEXT) restart.$(OBJEXT) \
rng_mt.$(OBJEXT) s_bsd.$(OBJEXT) send.$(OBJEXT) \
server.$(OBJEXT) server_capab.$(OBJEXT) user.$(OBJEXT) \
userhost.$(OBJEXT) version.$(OBJEXT) watch.$(OBJEXT) \
whowas.$(OBJEXT)
ircd_OBJECTS = $(am_ircd_OBJECTS)
@@ -411,7 +410,6 @@ ircd_SOURCES = auth.c \
log.c \
match.c \
memory.c \
mempool.c \
misc.c \
modules.c \
motd.c \
@@ -432,6 +430,7 @@ ircd_SOURCES = auth.c \
s_bsd.c \
send.c \
server.c \
server_capab.c \
user.c \
userhost.c \
version.c \
@@ -566,7 +565,6 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/log.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/match.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/memory.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mempool.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/misc.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/modules.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/motd.Po@am__quote@
@@ -584,6 +582,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/s_bsd_poll.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/send.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/server.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/server_capab.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tls_gnutls.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tls_none.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tls_openssl.Po@am__quote@

Large diffs are not rendered by default.

@@ -1,7 +1,7 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2017 ircd-hybrid development team
* Copyright (c) 1997-2018 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,26 +40,11 @@
#include "send.h"
#include "event.h"
#include "memory.h"
#include "mempool.h"
#include "misc.h"


dlink_list channel_list;
mp_pool_t *ban_pool; /*! \todo ban_pool shouldn't be a global var */

static mp_pool_t *member_pool, *channel_pool, *invite_pool;


/*! \brief Initializes the channel blockheap, adds known channel CAPAB
*/
void
channel_init(void)
{
invite_pool = mp_pool_new(sizeof(struct Invite), MP_CHUNK_SIZE_INVITE);
channel_pool = mp_pool_new(sizeof(struct Channel), MP_CHUNK_SIZE_CHANNEL);
ban_pool = mp_pool_new(sizeof(struct Ban), MP_CHUNK_SIZE_BAN);
member_pool = mp_pool_new(sizeof(struct Membership), MP_CHUNK_SIZE_MEMBER);
}

/*! \brief Adds a user to a channel by adding another link to the
* channels member chain.
@@ -105,7 +90,7 @@ add_user_to_channel(struct Channel *chptr, struct Client *client_p,
chptr->last_join_time = CurrentTime;
}

struct Membership *member = mp_pool_get(member_pool);
struct Membership *member = xcalloc(sizeof(*member));
member->client_p = client_p;
member->chptr = chptr;
member->flags = flags;
@@ -135,7 +120,7 @@ remove_user_from_channel(struct Membership *member)

dlinkDelete(&member->usernode, &client_p->channel);

mp_pool_release(member);
xfree(member);

if (chptr->members.head == NULL)
channel_free(chptr);
@@ -306,7 +291,7 @@ void
remove_ban(struct Ban *ban, dlink_list *list)
{
dlinkDelete(&ban->node, list);
mp_pool_release(ban);
xfree(ban);
}

/* channel_free_mask_list()
@@ -335,7 +320,7 @@ channel_make(const char *name)
{
assert(!EmptyString(name));

struct Channel *chptr = mp_pool_get(channel_pool);
struct Channel *chptr = xcalloc(sizeof(*chptr));
/* Doesn't hurt to set it here */
chptr->creationtime = CurrentTime;
chptr->last_join_time = CurrentTime;
@@ -367,7 +352,7 @@ channel_free(struct Channel *chptr)
dlinkDelete(&chptr->node, &channel_list);
hash_del_channel(chptr);

mp_pool_release(chptr);
xfree(chptr);
}

/*!
@@ -503,7 +488,7 @@ add_invite(struct Channel *chptr, struct Client *client_p)
if (invite)
del_invite(invite);

invite = mp_pool_get(invite_pool);
invite = xcalloc(sizeof(*invite));
invite->client_p = client_p;
invite->chptr = chptr;
invite->when = CurrentTime;
@@ -531,7 +516,7 @@ del_invite(struct Invite *invite)
dlinkDelete(&invite->chan_node, &invite->chptr->invites);

/* Release memory pointed to by 'invite' */
mp_pool_release(invite);
xfree(invite);
}

/*! \brief Removes and frees all Invite blocks from a list
@@ -817,12 +802,8 @@ can_send(struct Channel *chptr, struct Client *client_p,
void
check_spambot_warning(struct Client *client_p, const char *name)
{
int t_delta = 0;
int decrement_count = 0;

if ((GlobalSetOptions.spam_num &&
(client_p->connection->join_leave_count >=
GlobalSetOptions.spam_num)))
if (GlobalSetOptions.spam_num &&
(client_p->connection->join_leave_count >= GlobalSetOptions.spam_num))
{
if (client_p->connection->oper_warn_count_down > 0)
client_p->connection->oper_warn_count_down--;
@@ -847,11 +828,10 @@ check_spambot_warning(struct Client *client_p, const char *name)
}
else
{
if ((t_delta = (CurrentTime - client_p->connection->last_leave_time)) >
JOIN_LEAVE_COUNT_EXPIRE_TIME)
int t_delta = CurrentTime - client_p->connection->last_leave_time;
if (t_delta > JOIN_LEAVE_COUNT_EXPIRE_TIME)
{
decrement_count = (t_delta / JOIN_LEAVE_COUNT_EXPIRE_TIME);

int decrement_count = (t_delta / JOIN_LEAVE_COUNT_EXPIRE_TIME);
if (decrement_count > client_p->connection->join_leave_count)
client_p->connection->join_leave_count = 0;
else
@@ -891,80 +871,16 @@ channel_set_topic(struct Channel *chptr, const char *topic,
chptr->topic_time = topicts;
}

/* do_join_0()
*
* inputs - pointer to client doing join 0
* output - NONE
* side effects - Use has decided to join 0. This is legacy
* from the days when channels were numbers not names. *sigh*
* There is a bunch of evilness necessary here due to
* anti spambot code.
*/
void
channel_do_join_0(struct Client *client_p)
{
if (client_p->channel.head)
if (MyConnect(client_p) && !HasUMode(client_p, UMODE_OPER))
check_spambot_warning(client_p, NULL);

while (client_p->channel.head)
{
struct Membership *member = client_p->channel.head->data;

sendto_server(client_p, 0, 0, ":%s PART %s",
client_p->id, member->chptr->name);
sendto_channel_local(NULL, member->chptr, 0, 0, 0, ":%s!%s@%s PART %s",
client_p->name, client_p->username,
client_p->host, member->chptr->name);

remove_user_from_channel(member);
}
}

static char *
channel_find_last0(struct Client *client_p, char *chanlist)
{
int join0 = 0;

for (char *p = chanlist; *p; ++p) /* Find last "JOIN 0" */
{
if (*p == '0' && (*(p + 1) == ',' || *(p + 1) == '\0'))
{
if (*(p + 1) == ',')
++p;

chanlist = p + 1;
join0 = 1;
}
else
{
while (*p != ',' && *p != '\0') /* Skip past channel name */
++p;

if (*p == '\0') /* Hit the end */
break;
}
}

if (join0)
channel_do_join_0(client_p);

return chanlist;
}

void
channel_do_join(struct Client *client_p, char *channel, char *key_list)
channel_do_join(struct Client *client_p, char *chan_list, char *key_list)
{
char *p = NULL;
char *chan_list = NULL;
const struct ResvItem *resv = NULL;
const struct ClassItem *const class = get_class_ptr(&client_p->connection->confs);
unsigned int flags = 0;

assert(IsClient(client_p));

chan_list = channel_find_last0(client_p, channel);

for (const char *name = strtok_r(chan_list, ",", &p); name;
name = strtok_r(NULL, ",", &p))
{