@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/

@@ -58,11 +58,9 @@ remove_kline_match(const char *host, const char *user)

if ((t = parse_netmask(host, &iphost, NULL)) != HM_HOST)
{
#ifdef IPV6
if (t == HM_IPV6)
aftype = AF_INET6;
else
#endif
aftype = AF_INET;
piphost = &iphost;
}
@@ -223,7 +221,7 @@ ms_unkline(struct Client *source_p, int parc, char *parv[])

static struct Message unkline_msgtab =
{
"UNKLINE", 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
"UNKLINE", NULL, 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
{ m_unregistered, m_not_oper, ms_unkline, me_unkline, mo_unkline, m_ignore }
};

@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/

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

static struct Message unresv_msgtab =
{
"UNRESV", 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
"UNRESV", NULL, 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
{ m_ignore, m_not_oper, ms_unresv, m_ignore, mo_unresv, m_ignore }
};

@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/

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

static struct Message unxline_msgtab =
{
"UNXLINE", 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
"UNXLINE", NULL, 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
{ m_unregistered, m_not_oper, ms_unxline, m_ignore, mo_unxline, m_ignore }
};

@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/

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

static struct Message user_msgtab =
{
"USER", 0, 0, 5, MAXPARA, MFLG_SLOW, 0,
"USER", NULL, 0, 0, 5, MAXPARA, MFLG_SLOW, 0,
{ mr_user, m_registered, m_ignore, m_ignore, m_registered, m_ignore }
};

@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/

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

static struct Message userhost_msgtab =
{
"USERHOST", 0, 0, 2, 1, MFLG_SLOW, 0,
"USERHOST", NULL, 0, 0, 2, 1, MFLG_SLOW, 0,
{ m_unregistered, m_userhost, m_userhost, m_ignore, m_userhost, m_ignore }
};

@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/

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

static struct Message version_msgtab =
{
"VERSION", 0, 0, 0, MAXPARA, MFLG_SLOW, 0,
"VERSION", NULL, 0, 0, 0, MAXPARA, MFLG_SLOW, 0,
{ m_unregistered, m_version, ms_version, m_ignore, ms_version, m_ignore }
};

@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/

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

static struct Message wallops_msgtab =
{
"WALLOPS", 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
"WALLOPS", NULL, 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
{ m_unregistered, m_not_oper, ms_wallops, m_ignore, mo_wallops, m_ignore }
};

@@ -16,7 +16,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/

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

static struct Message watch_msgtab =
{
"WATCH", 0, 0, 0, 1, MFLG_SLOW, 0,
"WATCH", NULL, 0, 0, 0, 1, MFLG_SLOW, 0,
{ m_unregistered, m_watch, m_ignore, m_ignore, m_watch, m_ignore }
};

@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/

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

if (!valid_hostname(parv[3]))
{
sendto_one_notice(source_p, &me, ":CGI:IRC: Invalid hostname");
sendto_one_notice(source_p, &me, ":WEBIRC: Invalid hostname");
return 0;
}

@@ -74,19 +74,19 @@ mr_webirc(struct Client *source_p, int parc, char *parv[])

if (!IsConfWebIRC(conf))
{
sendto_one_notice(source_p, &me, ":Not a CGI:IRC auth block");
sendto_one_notice(source_p, &me, ":Not a WEBIRC auth {} block");
return 0;
}

if (EmptyString(conf->passwd))
{
sendto_one_notice(source_p, &me, ":CGI:IRC auth blocks must have a password");
sendto_one_notice(source_p, &me, ":WEBIRC auth {} blocks must have a password");
return 0;
}

if (!match_conf_password(parv[1], conf))
{
sendto_one_notice(source_p, &me, ":CGI:IRC password incorrect");
sendto_one_notice(source_p, &me, ":WEBIRC password incorrect");
return 0;
}

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

if (getaddrinfo(parv[4], NULL, &hints, &res))
{
sendto_one_notice(source_p, &me, ":Invalid CGI:IRC IP %s", parv[4]);
sendto_one_notice(source_p, &me, ":Invalid WEBIRC IP %s", parv[4]);
return 0;
}

@@ -125,14 +125,14 @@ mr_webirc(struct Client *source_p, int parc, char *parv[])
}

AddUMode(source_p, UMODE_WEBIRC);
sendto_one_notice(source_p, &me, ":CGI:IRC host/IP set to %s %s",
sendto_one_notice(source_p, &me, ":WEBIRC host/IP set to %s %s",
parv[3], parv[4]);
return 0;
}

static struct Message webirc_msgtab =
{
"WEBIRC", 0, 0, 5, MAXPARA, MFLG_SLOW, 0,
"WEBIRC", NULL, 0, 0, 5, MAXPARA, MFLG_SLOW, 0,
{ mr_webirc, m_registered, m_ignore, m_ignore, m_registered, m_ignore }
};

@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/

@@ -40,6 +40,9 @@
#include "modules.h"


#define WHO_MAXREPLIES 500


/* do_who()
*
* inputs - pointer to client requesting who
@@ -122,7 +125,10 @@ who_common_channel(struct Client *source_p, struct Channel *chptr, char *mask,
if (*maxmatches > 0)
{
if (--(*maxmatches) == 0)
{
sendto_one_numeric(source_p, &me, ERR_WHOLIMEXCEED, WHO_MAXREPLIES, "WHO");
return;
}
}
}
}
@@ -140,10 +146,8 @@ who_common_channel(struct Client *source_p, struct Channel *chptr, char *mask,
static void
who_global(struct Client *source_p, char *mask, int server_oper)
{
struct Channel *chptr;
struct Client *target_p;
dlink_node *lp = NULL, *gcptr = NULL;
unsigned int maxmatches = 500;
dlink_node *ptr = NULL;
unsigned int maxmatches = WHO_MAXREPLIES;
static time_t last_used = 0;

if (!HasUMode(source_p, UMODE_OPER))
@@ -158,16 +162,16 @@ who_global(struct Client *source_p, char *mask, int server_oper)
}

/* First, list all matching invisible clients on common channels */
DLINK_FOREACH(lp, source_p->channel.head)
DLINK_FOREACH(ptr, source_p->channel.head)
{
chptr = ((struct Membership *)lp->data)->chptr;
struct Channel *chptr = ((struct Membership *)ptr->data)->chptr;
who_common_channel(source_p, chptr, mask, server_oper, &maxmatches);
}

/* Second, list all matching visible clients */
DLINK_FOREACH(gcptr, global_client_list.head)
DLINK_FOREACH(ptr, global_client_list.head)
{
target_p = gcptr->data;
struct Client *target_p = ptr->data;

if (!IsClient(target_p))
continue;
@@ -193,7 +197,10 @@ who_global(struct Client *source_p, char *mask, int server_oper)
if (maxmatches > 0)
{
if (--maxmatches == 0)
{
sendto_one_numeric(source_p, &me, ERR_WHOLIMEXCEED, WHO_MAXREPLIES, "WHO");
return;
}
}
}
}
@@ -212,7 +219,7 @@ who_global(struct Client *source_p, char *mask, int server_oper)
*/
static void
do_who_on_channel(struct Client *source_p, struct Channel *chptr,
const char *chname, int member, int server_oper)
int member, int server_oper)
{
dlink_node *ptr = NULL;

@@ -227,7 +234,7 @@ do_who_on_channel(struct Client *source_p, struct Channel *chptr,
if (!HasUMode(target_p, UMODE_OPER) ||
(HasUMode(target_p, UMODE_HIDDEN) && !HasUMode(source_p, UMODE_OPER)))
continue;
do_who(source_p, target_p, chname, get_member_status(ms, !!HasCap(source_p, CAP_MULTI_PREFIX)));
do_who(source_p, target_p, chptr->chname, get_member_status(ms, !!HasCap(source_p, CAP_MULTI_PREFIX)));
}
}
}
@@ -271,9 +278,9 @@ m_who(struct Client *source_p, int parc, char *parv[])
if ((chptr = hash_find_channel(mask)))
{
if (IsMember(source_p, chptr) || HasUMode(source_p, UMODE_ADMIN))
do_who_on_channel(source_p, chptr, chptr->chname, 1, server_oper);
do_who_on_channel(source_p, chptr, 1, server_oper);
else if (!SecretChannel(chptr))
do_who_on_channel(source_p, chptr, chptr->chname, 0, server_oper);
do_who_on_channel(source_p, chptr, 0, server_oper);
}

sendto_one_numeric(source_p, &me, RPL_ENDOFWHO, mask);
@@ -307,8 +314,7 @@ m_who(struct Client *source_p, int parc, char *parv[])
if ((ptr = source_p->channel.head))
{
chptr = ((struct Membership *)ptr->data)->chptr;
do_who_on_channel(source_p, chptr, chptr->chname, 1,
server_oper);
do_who_on_channel(source_p, chptr, 1, server_oper);
}

sendto_one_numeric(source_p, &me, RPL_ENDOFWHO, "*");
@@ -328,7 +334,7 @@ m_who(struct Client *source_p, int parc, char *parv[])

static struct Message who_msgtab =
{
"WHO", 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
"WHO", NULL, 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
{ m_unregistered, m_who, m_ignore, m_ignore, m_who, m_ignore }
};

@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/

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

static struct Message whois_msgtab =
{
"WHOIS", 0, 0, 0, MAXPARA, MFLG_SLOW, 0,
"WHOIS", NULL, 0, 0, 0, MAXPARA, MFLG_SLOW, 0,
{ m_unregistered, m_whois, mo_whois, m_ignore, mo_whois, m_ignore }
};

@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/

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

static struct Message whowas_msgtab =
{
"WHOWAS", 0, 0, 0, MAXPARA, MFLG_SLOW, 0,
"WHOWAS", NULL, 0, 0, 0, MAXPARA, MFLG_SLOW, 0,
{ m_unregistered, m_whowas, ms_whowas, m_ignore, ms_whowas, m_ignore }
};

@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/

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

static struct Message xline_msgtab =
{
"XLINE", 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
"XLINE", NULL, 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
{ m_unregistered, m_not_oper, ms_xline, me_xline, mo_xline, m_ignore }
};

@@ -16,6 +16,7 @@ ircd_SOURCES = auth.c \
conf.c \
conf_class.c \
conf_db.c \
conf_pseudo.c \
conf_parser.y \
conf_lexer.l \
dbuf.c \
@@ -110,16 +110,16 @@ am__installdirs = "$(DESTDIR)$(bindir)"
PROGRAMS = $(bin_PROGRAMS)
am_ircd_OBJECTS = auth.$(OBJEXT) channel.$(OBJEXT) \
channel_mode.$(OBJEXT) client.$(OBJEXT) conf.$(OBJEXT) \
conf_class.$(OBJEXT) conf_db.$(OBJEXT) conf_parser.$(OBJEXT) \
conf_lexer.$(OBJEXT) dbuf.$(OBJEXT) event.$(OBJEXT) \
fdlist.$(OBJEXT) getopt.$(OBJEXT) gline.$(OBJEXT) \
hash.$(OBJEXT) hostmask.$(OBJEXT) ipcache.$(OBJEXT) \
irc_string.$(OBJEXT) ircd.$(OBJEXT) ircd_signal.$(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) \
conf_class.$(OBJEXT) conf_db.$(OBJEXT) conf_pseudo.$(OBJEXT) \
conf_parser.$(OBJEXT) conf_lexer.$(OBJEXT) dbuf.$(OBJEXT) \
event.$(OBJEXT) fdlist.$(OBJEXT) getopt.$(OBJEXT) \
gline.$(OBJEXT) hash.$(OBJEXT) hostmask.$(OBJEXT) \
ipcache.$(OBJEXT) irc_string.$(OBJEXT) ircd.$(OBJEXT) \
ircd_signal.$(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) res.$(OBJEXT) \
reslib.$(OBJEXT) restart.$(OBJEXT) resv.$(OBJEXT) \
rng_mt.$(OBJEXT) rsa.$(OBJEXT) s_bsd.$(OBJEXT) send.$(OBJEXT) \
@@ -368,6 +368,7 @@ ircd_SOURCES = auth.c \
conf.c \
conf_class.c \
conf_db.c \
conf_pseudo.c \
conf_parser.y \
conf_lexer.l \
dbuf.c \
@@ -517,6 +518,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/conf_db.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/conf_lexer.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/conf_parser.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/conf_pseudo.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dbuf.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/event.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fdlist.Po@am__quote@
@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/

@@ -80,8 +80,8 @@ enum
#define sendheader(c, i) sendto_one_notice((c), &me, HeaderMessages[(i)])

static dlink_list auth_pending_list;
static PF read_auth_reply;
static CNCB auth_connect_callback;
static void read_auth_reply(fde_t *, void *);
static void auth_connect_callback(fde_t *, int, void *);


/*
@@ -143,21 +143,17 @@ release_auth_client(struct AuthRequest *auth)
* of success of failure
*/
static void
auth_dns_callback(void *vptr, const struct irc_ssaddr *addr, const char *name)
auth_dns_callback(void *vptr, const struct irc_ssaddr *addr, const char *name, size_t namelength)
{
struct AuthRequest *auth = vptr;

ClearDNSPending(auth);

if (name)
if (!EmptyString(name))
{
const struct sockaddr_in *v4, *v4dns;
#ifdef IPV6
const struct sockaddr_in6 *v6, *v6dns;
#endif
int good = 1;

#ifdef IPV6
if (auth->client->localClient->ip.ss.ss_family == AF_INET6)
{
v6 = (const struct sockaddr_in6 *)&auth->client->localClient->ip;
@@ -166,30 +162,30 @@ auth_dns_callback(void *vptr, const struct irc_ssaddr *addr, const char *name)
if (memcmp(&v6->sin6_addr, &v6dns->sin6_addr, sizeof(struct in6_addr)) != 0)
{
sendheader(auth->client, REPORT_IP_MISMATCH);
good = 0;
release_auth_client(auth);
return;
}
}
else
#endif
{
v4 = (const struct sockaddr_in *)&auth->client->localClient->ip;
v4dns = (const struct sockaddr_in *)addr;

if (v4->sin_addr.s_addr != v4dns->sin_addr.s_addr)
{
sendheader(auth->client, REPORT_IP_MISMATCH);
good = 0;
release_auth_client(auth);
return;
}
}

if (good && strlen(name) <= HOSTLEN)
if (namelength > HOSTLEN)
sendheader(auth->client, REPORT_HOST_TOOLONG);
else
{
strlcpy(auth->client->host, name,
sizeof(auth->client->host));
strlcpy(auth->client->host, name, sizeof(auth->client->host));
sendheader(auth->client, REPORT_FIN_DNS);
}
else if (strlen(name) > HOSTLEN)
sendheader(auth->client, REPORT_HOST_TOOLONG);
}
else
sendheader(auth->client, REPORT_FAIL_DNS);
@@ -227,11 +223,7 @@ start_auth_query(struct AuthRequest *auth)
{
struct irc_ssaddr localaddr;
socklen_t locallen = sizeof(struct irc_ssaddr);
#ifdef IPV6
struct sockaddr_in6 *v6;
#else
struct sockaddr_in *v4;
#endif

/* open a socket of the same type as the client socket */
if (comm_open(&auth->fd, auth->client->localClient->ip.ss.ss_family,
@@ -258,15 +250,9 @@ start_auth_query(struct AuthRequest *auth)
getsockname(auth->client->localClient->fd.fd, (struct sockaddr*)&localaddr,
&locallen);

#ifdef IPV6
remove_ipv6_mapping(&localaddr);
v6 = (struct sockaddr_in6 *)&localaddr;
v6->sin6_port = htons(0);
#else
localaddr.ss_len = locallen;
v4 = (struct sockaddr_in *)&localaddr;
v4->sin_port = htons(0);
#endif
localaddr.ss_port = htons(0);

comm_connect_tcp(&auth->fd, auth->client->sockhost, RFC1413_PORT,
@@ -365,11 +351,7 @@ auth_connect_callback(fde_t *fd, int error, void *data)
socklen_t ulen = sizeof(struct irc_ssaddr);
socklen_t tlen = sizeof(struct irc_ssaddr);
uint16_t uport, tport;
#ifdef IPV6
struct sockaddr_in6 *v6;
#else
struct sockaddr_in *v4;
#endif

if (error != COMM_OK)
{
@@ -386,21 +368,12 @@ auth_connect_callback(fde_t *fd, int error, void *data)
return;
}

#ifdef IPV6
v6 = (struct sockaddr_in6 *)&us;
uport = ntohs(v6->sin6_port);
v6 = (struct sockaddr_in6 *)&them;
tport = ntohs(v6->sin6_port);
remove_ipv6_mapping(&us);
remove_ipv6_mapping(&them);
#else
v4 = (struct sockaddr_in *)&us;
uport = ntohs(v4->sin_port);
v4 = (struct sockaddr_in *)&them;
tport = ntohs(v4->sin_port);
us.ss_len = ulen;
them.ss_len = tlen;
#endif

snprintf(authbuf, sizeof(authbuf), "%u, %u\r\n", tport, uport);

@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/

@@ -590,13 +590,11 @@ find_bmask(const struct Client *who, const dlink_list *const list)
if (match_ipv4(&who->localClient->ip, &bp->addr, bp->bits))
return 1;
break;
#ifdef IPV6
case HM_IPV6:
if (who->localClient->aftype == AF_INET6)
if (match_ipv6(&who->localClient->ip, &bp->addr, bp->bits))
return 1;
break;
#endif
default:
assert(0);
}
@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/

@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/

@@ -138,18 +138,18 @@ free_client(struct Client *client_p)
assert(dlink_list_length(&client_p->localClient->watches) == 0);
assert(IsClosing(client_p) && IsDead(client_p));

MyFree(client_p->localClient->response);
MyFree(client_p->localClient->auth_oper);
MyFree(client_p->localClient->challenge_response);
MyFree(client_p->localClient->challenge_operator);
client_p->localClient->challenge_response = NULL;
client_p->localClient->challenge_operator = NULL;

/*
* clean up extra sockets from P-lines which have been discarded.
*/
if (client_p->localClient->listener)
{
assert(0 < client_p->localClient->listener->ref_count);
if (0 == --client_p->localClient->listener->ref_count &&
!client_p->localClient->listener->active)
free_listener(client_p->localClient->listener);
listener_release(client_p->localClient->listener);
client_p->localClient->listener = NULL;
}

dbuf_clear(&client_p->localClient->buf_recvq);
@@ -279,7 +279,7 @@ check_unknowns_list(void)
*/

static void
check_pings(void *notused)
check_pings(void *unused)
{
check_pings_list(&local_client_list);
check_pings_list(&local_server_list);
@@ -709,8 +709,11 @@ exit_client(struct Client *source_p, const char *comment)

SetClosing(source_p);

if (IsIpHash(source_p))
if (HasFlag(source_p, FLAGS_IPHASH))
{
DelFlag(source_p, FLAGS_IPHASH);
ipcache_remove_address(&source_p->localClient->ip);
}

delete_auth(&source_p->localClient->auth);

@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/

@@ -28,6 +28,7 @@
#include "list.h"
#include "ircd_defs.h"
#include "conf.h"
#include "conf_pseudo.h"
#include "server.h"
#include "resv.h"
#include "channel.h"
@@ -92,7 +93,7 @@ static int find_user_host(struct Client *, char *, char *, char *, unsigned int)
* if successful save hp in the conf item it was called with
*/
static void
conf_dns_callback(void *vptr, const struct irc_ssaddr *addr, const char *name)
conf_dns_callback(void *vptr, const struct irc_ssaddr *addr, const char *name, size_t namelength)
{
struct MaskItem *conf = vptr;

@@ -116,7 +117,11 @@ conf_dns_lookup(struct MaskItem *conf)
if (!conf->dns_pending)
{
conf->dns_pending = 1;
gethost_byname(conf_dns_callback, conf, conf->host);

if (conf->aftype == AF_INET)
gethost_byname_type(conf_dns_callback, conf, conf->host, T_A);
else
gethost_byname_type(conf_dns_callback, conf, conf->host, T_AAAA);
}
}

@@ -141,9 +146,8 @@ conf_free(struct MaskItem *conf)
dlink_node *ptr = NULL, *ptr_next = NULL;
dlink_list *list = NULL;

if (conf->node.next)
if ((list = map_to_list(conf->type)))
dlinkDelete(&conf->node, list);
if ((list = map_to_list(conf->type)))
dlinkFindDelete(list, conf);

MyFree(conf->name);

@@ -291,15 +295,15 @@ verify_access(struct Client *client_p)
conf = find_address_conf(client_p->host, client_p->username,
&client_p->localClient->ip,
client_p->localClient->aftype,
client_p->localClient->passwd);
client_p->localClient->password);
}
else
{
strlcpy(non_ident + 1, client_p->username, sizeof(non_ident) - 1);
conf = find_address_conf(client_p->host,non_ident,
&client_p->localClient->ip,
client_p->localClient->aftype,
client_p->localClient->passwd);
client_p->localClient->password);
}

if (conf)
@@ -359,7 +363,7 @@ attach_iline(struct Client *client_p, struct MaskItem *conf)

ip_found = ipcache_find_or_add_address(&client_p->localClient->ip);
ip_found->count++;
SetIpHash(client_p);
AddFlag(client_p, FLAGS_IPHASH);

count_user_host(client_p->username, client_p->host,
&global, &local, &ident);
@@ -712,14 +716,12 @@ find_exact_name_conf(enum maskitem_type type, const struct Client *who, const ch
if (!conf->class->max_total || conf->class->ref_count < conf->class->max_total)
return conf;
break;
#ifdef IPV6
case HM_IPV6:
if (who->localClient->aftype == AF_INET6)
if (match_ipv6(&who->localClient->ip, &conf->addr, conf->bits))
if (!conf->class->max_total || conf->class->ref_count < conf->class->max_total)
return conf;
break;
#endif
default:
assert(0);
}
@@ -774,14 +776,8 @@ rehash(int sig)

/* don't close listeners until we know we can go ahead with the rehash */

/* Check to see if we magically got(or lost) IPv6 support */
check_can_use_v6();

read_conf_files(0);

if (ConfigServerInfo.description)
strlcpy(me.info, ConfigServerInfo.description, sizeof(me.info));

load_conf_modules();
check_conf_klines();

@@ -806,6 +802,20 @@ set_default_conf(void)
assert(class_default == class_get_list()->tail->data);

#ifdef HAVE_LIBCRYPTO
#if OPENSSL_VERSION_NUMBER >= 0x1000005FL && !defined(OPENSSL_NO_ECDH)
{
EC_KEY *key = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);

if (key)
{
SSL_CTX_set_tmp_ecdh(ConfigServerInfo.server_ctx, key);
EC_KEY_free(key);
}
}

SSL_CTX_set_options(ConfigServerInfo.server_ctx, SSL_OP_SINGLE_ECDH_USE);
#endif

ConfigServerInfo.message_digest_algorithm = EVP_sha256();
ConfigServerInfo.rsa_private_key = NULL;
ConfigServerInfo.rsa_private_key_file = NULL;
@@ -859,7 +869,6 @@ set_default_conf(void)

ConfigGeneral.away_count = 2;
ConfigGeneral.away_time = 10;
ConfigGeneral.service_name = xstrdup(SERVICE_NAME_DEFAULT);
ConfigGeneral.max_watch = WATCHSIZE_DEFAULT;
ConfigGeneral.cycle_on_host_change = 1;
ConfigGeneral.glines = 0;
@@ -923,9 +932,6 @@ validate_conf(void)
if (ConfigServerInfo.network_desc == NULL)
ConfigServerInfo.network_desc = xstrdup(NETWORK_DESC_DEFAULT);

if (ConfigGeneral.service_name == NULL)
ConfigGeneral.service_name = xstrdup(SERVICE_NAME_DEFAULT);

ConfigGeneral.max_watch = IRCD_MAX(ConfigGeneral.max_watch, WATCHSIZE_MIN);
}

@@ -1034,7 +1040,7 @@ conf_connect_allowed(struct irc_ssaddr *addr, int aftype)
* This is an event started off in ircd.c
*/
void
cleanup_tklines(void *notused)
cleanup_tklines(void *unused)
{
hostmask_expire_temporary();
expire_tklines(&xconf_items);
@@ -1246,7 +1252,6 @@ static void
clear_out_old_conf(void)
{
dlink_node *ptr = NULL, *next_ptr = NULL;
struct MaskItem *conf;
dlink_list *free_items [] = {
&server_items, &oconf_items,
&uconf_items, &xconf_items,
@@ -1263,9 +1268,10 @@ clear_out_old_conf(void)
{
DLINK_FOREACH_SAFE(ptr, next_ptr, (*iterator)->head)
{
conf = ptr->data;
struct MaskItem *conf = ptr->data;

dlinkDelete(&conf->node, map_to_list(conf->type));
conf->active = 0;
dlinkDelete(&conf->node, *iterator);

/* XXX This is less than pretty */
if (conf->type == CONF_SERVER || conf->type == CONF_OPER)
@@ -1296,6 +1302,8 @@ clear_out_old_conf(void)
/* clean out module paths */
mod_clear_paths();

pseudo_clear();

/* clean out ConfigServerInfo */
MyFree(ConfigServerInfo.description);
ConfigServerInfo.description = NULL;
@@ -1324,10 +1332,6 @@ clear_out_old_conf(void)

/* clean out listeners */
close_listeners();

/* clean out general */
MyFree(ConfigGeneral.service_name);
ConfigGeneral.service_name = NULL;
}

/* conf_add_class_to_conf()
@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/

@@ -264,7 +264,6 @@ cidr_limit_reached(int over_rule, struct irc_ssaddr *ip, struct ClassItem *class
mask_addr(&cidr->mask, class->cidr_bitlen_ipv4);
dlinkAdd(cidr, &cidr->node, &class->list_ipv4);
}
#ifdef IPV6
else if (class->cidr_bitlen_ipv6 > 0)
{
DLINK_FOREACH(ptr, class->list_ipv6.head)
@@ -287,7 +286,7 @@ cidr_limit_reached(int over_rule, struct irc_ssaddr *ip, struct ClassItem *class
mask_addr(&cidr->mask, class->cidr_bitlen_ipv6);
dlinkAdd(cidr, &cidr->node, &class->list_ipv6);
}
#endif

return 0;
}

@@ -331,7 +330,6 @@ remove_from_cidr_check(struct irc_ssaddr *ip, struct ClassItem *aclass)
}
}
}
#ifdef IPV6
else if (aclass->cidr_bitlen_ipv6 > 0)
{
DLINK_FOREACH_SAFE(ptr, next_ptr, aclass->list_ipv6.head)
@@ -351,7 +349,6 @@ remove_from_cidr_check(struct irc_ssaddr *ip, struct ClassItem *aclass)
}
}
}
#endif
}

void
@@ -16,7 +16,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/

Large diffs are not rendered by default.

@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/

@@ -146,6 +146,7 @@ cidr_bitlen_ipv4 { return CIDR_BITLEN_IPV4; }
cidr_bitlen_ipv6 { return CIDR_BITLEN_IPV6; }
class { return CLASS; }
cluster { return T_CLUSTER; }
command { return T_COMMAND; }
connect { return CONNECT; }
connectfreq { return CONNECTFREQ; }
cycle_on_host_change { return CYCLE_ON_HOST_CHANGE; }
@@ -272,6 +273,8 @@ path { return PATH; }
ping_cookie { return PING_COOKIE; }
ping_time { return PING_TIME; }
port { return PORT; }
prepend { return T_PREPEND; }
pseudo { return T_PSEUDO; }
quarantine { return RESV; }
random_idle { return RANDOM_IDLE; }
reason { return REASON; }
@@ -293,7 +296,6 @@ server { return T_SERVER; }
serverhide { return SERVERHIDE; }
serverinfo { return SERVERINFO; }
service { return T_SERVICE; }
services_name { return T_SERVICES_NAME; }
servnotice { return T_SERVNOTICE; }
set { return T_SET; }
shared { return T_SHARED; }
@@ -320,6 +322,7 @@ stats_k_oper_only { return STATS_K_OPER_ONLY; }
stats_o_oper_only { return STATS_O_OPER_ONLY; }
stats_P_oper_only { return STATS_P_OPER_ONLY; }
stats_u_oper_only { return STATS_U_OPER_ONLY; }
target { return T_TARGET; }
throttle_count { return THROTTLE_COUNT; }
throttle_time { return THROTTLE_TIME; }
tkline_expire_notices { return TKLINE_EXPIRE_NOTICES; }

Large diffs are not rendered by default.

@@ -214,65 +214,68 @@ extern int yydebug;
T_BOTS = 424,
T_CALLERID = 425,
T_CCONN = 426,
T_CLUSTER = 427,
T_DEAF = 428,
T_DEBUG = 429,
T_DLINE = 430,
T_EXTERNAL = 431,
T_FARCONNECT = 432,
T_FILE = 433,
T_FULL = 434,
T_GLOBOPS = 435,
T_INVISIBLE = 436,
T_IPV4 = 437,
T_IPV6 = 438,
T_LOCOPS = 439,
T_LOG = 440,
T_MAX_CLIENTS = 441,
T_NCHANGE = 442,
T_NONONREG = 443,
T_RECVQ = 444,
T_REJ = 445,
T_RESTART = 446,
T_SERVER = 447,
T_SERVICE = 448,
T_SERVICES_NAME = 449,
T_SERVNOTICE = 450,
T_SET = 451,
T_SHARED = 452,
T_SIZE = 453,
T_SKILL = 454,
T_SOFTCALLERID = 455,
T_SPY = 456,
T_SSL = 457,
T_SSL_CIPHER_LIST = 458,
T_UMODES = 459,
T_UNAUTH = 460,
T_UNDLINE = 461,
T_UNLIMITED = 462,
T_UNRESV = 463,
T_UNXLINE = 464,
T_WALLOP = 465,
T_WALLOPS = 466,
T_WEBIRC = 467,
TBOOL = 468,
THROTTLE_COUNT = 469,
THROTTLE_TIME = 470,
TKLINE_EXPIRE_NOTICES = 471,
TMASKED = 472,
TRUE_NO_OPER_FLOOD = 473,
TS_MAX_DELTA = 474,
TS_WARN_DELTA = 475,
TWODOTS = 476,
TYPE = 477,
UNKLINE = 478,
USE_EGD = 479,
USE_LOGGING = 480,
USER = 481,
VHOST = 482,
VHOST6 = 483,
WARN_NO_CONNECT_BLOCK = 484,
XLINE = 485
T_COMMAND = 427,
T_CLUSTER = 428,
T_DEAF = 429,
T_DEBUG = 430,
T_DLINE = 431,
T_EXTERNAL = 432,
T_FARCONNECT = 433,
T_FILE = 434,
T_FULL = 435,
T_GLOBOPS = 436,
T_INVISIBLE = 437,
T_IPV4 = 438,
T_IPV6 = 439,
T_LOCOPS = 440,
T_LOG = 441,
T_MAX_CLIENTS = 442,
T_NCHANGE = 443,
T_NONONREG = 444,
T_PREPEND = 445,
T_PSEUDO = 446,
T_RECVQ = 447,
T_REJ = 448,
T_RESTART = 449,
T_SERVER = 450,
T_SERVICE = 451,
T_SERVNOTICE = 452,
T_SET = 453,
T_SHARED = 454,
T_SIZE = 455,
T_SKILL = 456,
T_SOFTCALLERID = 457,
T_SPY = 458,
T_SSL = 459,
T_SSL_CIPHER_LIST = 460,
T_TARGET = 461,
T_UMODES = 462,
T_UNAUTH = 463,
T_UNDLINE = 464,
T_UNLIMITED = 465,
T_UNRESV = 466,
T_UNXLINE = 467,
T_WALLOP = 468,
T_WALLOPS = 469,
T_WEBIRC = 470,
TBOOL = 471,
THROTTLE_COUNT = 472,
THROTTLE_TIME = 473,
TKLINE_EXPIRE_NOTICES = 474,
TMASKED = 475,
TRUE_NO_OPER_FLOOD = 476,
TS_MAX_DELTA = 477,
TS_WARN_DELTA = 478,
TWODOTS = 479,
TYPE = 480,
UNKLINE = 481,
USE_EGD = 482,
USE_LOGGING = 483,
USER = 484,
VHOST = 485,
VHOST6 = 486,
WARN_NO_CONNECT_BLOCK = 487,
XLINE = 488
};
#endif
/* Tokens. */
@@ -445,77 +448,80 @@ extern int yydebug;
#define T_BOTS 424
#define T_CALLERID 425
#define T_CCONN 426
#define T_CLUSTER 427
#define T_DEAF 428
#define T_DEBUG 429
#define T_DLINE 430
#define T_EXTERNAL 431
#define T_FARCONNECT 432
#define T_FILE 433
#define T_FULL 434
#define T_GLOBOPS 435
#define T_INVISIBLE 436
#define T_IPV4 437
#define T_IPV6 438
#define T_LOCOPS 439
#define T_LOG 440
#define T_MAX_CLIENTS 441
#define T_NCHANGE 442
#define T_NONONREG 443
#define T_RECVQ 444
#define T_REJ 445
#define T_RESTART 446
#define T_SERVER 447
#define T_SERVICE 448
#define T_SERVICES_NAME 449
#define T_SERVNOTICE 450
#define T_SET 451
#define T_SHARED 452
#define T_SIZE 453
#define T_SKILL 454
#define T_SOFTCALLERID 455
#define T_SPY 456
#define T_SSL 457
#define T_SSL_CIPHER_LIST 458
#define T_UMODES 459
#define T_UNAUTH 460
#define T_UNDLINE 461
#define T_UNLIMITED 462
#define T_UNRESV 463
#define T_UNXLINE 464
#define T_WALLOP 465
#define T_WALLOPS 466
#define T_WEBIRC 467
#define TBOOL 468
#define THROTTLE_COUNT 469
#define THROTTLE_TIME 470
#define TKLINE_EXPIRE_NOTICES 471
#define TMASKED 472
#define TRUE_NO_OPER_FLOOD 473
#define TS_MAX_DELTA 474
#define TS_WARN_DELTA 475
#define TWODOTS 476
#define TYPE 477
#define UNKLINE 478
#define USE_EGD 479
#define USE_LOGGING 480
#define USER 481
#define VHOST 482
#define VHOST6 483
#define WARN_NO_CONNECT_BLOCK 484
#define XLINE 485
#define T_COMMAND 427
#define T_CLUSTER 428
#define T_DEAF 429
#define T_DEBUG 430
#define T_DLINE 431
#define T_EXTERNAL 432
#define T_FARCONNECT 433
#define T_FILE 434
#define T_FULL 435
#define T_GLOBOPS 436
#define T_INVISIBLE 437
#define T_IPV4 438
#define T_IPV6 439
#define T_LOCOPS 440
#define T_LOG 441
#define T_MAX_CLIENTS 442
#define T_NCHANGE 443
#define T_NONONREG 444
#define T_PREPEND 445
#define T_PSEUDO 446
#define T_RECVQ 447
#define T_REJ 448
#define T_RESTART 449
#define T_SERVER 450
#define T_SERVICE 451
#define T_SERVNOTICE 452
#define T_SET 453
#define T_SHARED 454
#define T_SIZE 455
#define T_SKILL 456
#define T_SOFTCALLERID 457
#define T_SPY 458
#define T_SSL 459
#define T_SSL_CIPHER_LIST 460
#define T_TARGET 461
#define T_UMODES 462
#define T_UNAUTH 463
#define T_UNDLINE 464
#define T_UNLIMITED 465
#define T_UNRESV 466
#define T_UNXLINE 467
#define T_WALLOP 468
#define T_WALLOPS 469
#define T_WEBIRC 470
#define TBOOL 471
#define THROTTLE_COUNT 472
#define THROTTLE_TIME 473
#define TKLINE_EXPIRE_NOTICES 474
#define TMASKED 475
#define TRUE_NO_OPER_FLOOD 476
#define TS_MAX_DELTA 477
#define TS_WARN_DELTA 478
#define TWODOTS 479
#define TYPE 480
#define UNKLINE 481
#define USE_EGD 482
#define USE_LOGGING 483
#define USER 484
#define VHOST 485
#define VHOST6 486
#define WARN_NO_CONNECT_BLOCK 487
#define XLINE 488

/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE YYSTYPE;
union YYSTYPE
{
#line 147 "conf_parser.y" /* yacc.c:1909 */
#line 152 "conf_parser.y" /* yacc.c:1909 */

int number;
char *string;

#line 519 "conf_parser.h" /* yacc.c:1909 */
#line 525 "conf_parser.h" /* yacc.c:1909 */
};
# define YYSTYPE_IS_TRIVIAL 1
# define YYSTYPE_IS_DECLARED 1
@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/

@@ -37,6 +37,7 @@
#include "list.h"
#include "conf.h"
#include "conf_class.h"
#include "conf_pseudo.h"
#include "event.h"
#include "log.h"
#include "client.h" /* for UMODE_ALL only */
@@ -76,6 +77,7 @@ static struct
{
char buf[IRCD_BUFSIZE];
} name,
nick,
user,
host,
addr,
@@ -85,7 +87,10 @@ static struct
cert,
rpass,
spass,
class;
class,
target,
prepend,
command;

struct
{
@@ -310,6 +315,7 @@ reset_block_state(void)
%token T_BOTS
%token T_CALLERID
%token T_CCONN
%token T_COMMAND
%token T_CLUSTER
%token T_DEAF
%token T_DEBUG
@@ -327,12 +333,13 @@ reset_block_state(void)
%token T_MAX_CLIENTS
%token T_NCHANGE
%token T_NONONREG
%token T_PREPEND
%token T_PSEUDO
%token T_RECVQ
%token T_REJ
%token T_RESTART
%token T_SERVER
%token T_SERVICE
%token T_SERVICES_NAME
%token T_SERVNOTICE
%token T_SET
%token T_SHARED
@@ -342,6 +349,7 @@ reset_block_state(void)
%token T_SPY
%token T_SSL
%token T_SSL_CIPHER_LIST
%token T_TARGET
%token T_UMODES
%token T_UNAUTH
%token T_UNDLINE
@@ -403,6 +411,7 @@ conf_item: admin_entry
| gecos_entry
| modules_entry
| motd_entry
| pseudo_entry
| error ';'
| error '}'
;
@@ -475,7 +484,7 @@ serverinfo_item: serverinfo_name |
serverinfo_ssl_certificate_file: SSL_CERTIFICATE_FILE '=' QSTRING ';'
{
#ifdef HAVE_LIBCRYPTO
if (conf_parser_ctx.pass == 2 && ConfigServerInfo.server_ctx)
if (conf_parser_ctx.pass == 2)
{
if (!ConfigServerInfo.rsa_private_key_file)
{
@@ -575,7 +584,7 @@ serverinfo_rsa_private_key_file: RSA_PRIVATE_KEY_FILE '=' QSTRING ';'
serverinfo_ssl_dh_param_file: SSL_DH_PARAM_FILE '=' QSTRING ';'
{
#ifdef HAVE_LIBCRYPTO
if (conf_parser_ctx.pass == 2 && ConfigServerInfo.server_ctx)
if (conf_parser_ctx.pass == 2)
{
BIO *file = BIO_new_file(yylval.string, "r");

@@ -604,15 +613,15 @@ serverinfo_ssl_dh_param_file: SSL_DH_PARAM_FILE '=' QSTRING ';'
serverinfo_ssl_cipher_list: T_SSL_CIPHER_LIST '=' QSTRING ';'
{
#ifdef HAVE_LIBCRYPTO
if (conf_parser_ctx.pass == 2 && ConfigServerInfo.server_ctx)
if (conf_parser_ctx.pass == 2)
SSL_CTX_set_cipher_list(ConfigServerInfo.server_ctx, yylval.string);
#endif
};

serverinfo_ssl_message_digest_algorithm: SSL_MESSAGE_DIGEST_ALGORITHM '=' QSTRING ';'
{
#ifdef HAVE_LIBCRYPTO
if (conf_parser_ctx.pass == 2 && ConfigServerInfo.server_ctx)
if (conf_parser_ctx.pass == 2)
{
if ((ConfigServerInfo.message_digest_algorithm = EVP_get_digestbyname(yylval.string)) == NULL)
{
@@ -630,7 +639,7 @@ serverinfo_ssl_dh_elliptic_curve: SSL_DH_ELLIPTIC_CURVE '=' QSTRING ';'
int nid = 0;
EC_KEY *key = NULL;

if (conf_parser_ctx.pass == 2 && ConfigServerInfo.server_ctx)
if (conf_parser_ctx.pass == 2)
{
if ((nid = OBJ_sn2nid(yylval.string)) == 0)
{
@@ -687,6 +696,7 @@ serverinfo_description: DESCRIPTION '=' QSTRING ';'
{
MyFree(ConfigServerInfo.description);
ConfigServerInfo.description = xstrdup(yylval.string);
strlcpy(me.info, ConfigServerInfo.description, sizeof(me.info));
}
};

@@ -743,7 +753,6 @@ serverinfo_vhost: VHOST '=' QSTRING ';'

serverinfo_vhost6: VHOST6 '=' QSTRING ';'
{
#ifdef IPV6
if (conf_parser_ctx.pass == 2 && *yylval.string != '*')
{
struct addrinfo hints, *res;
@@ -768,7 +777,6 @@ serverinfo_vhost6: VHOST6 '=' QSTRING ';'
ConfigServerInfo.specific_ipv6_vhost = 1;
}
}
#endif
};

serverinfo_max_clients: T_MAX_CLIENTS '=' NUMBER ';'
@@ -920,6 +928,69 @@ motd_file: T_FILE '=' QSTRING ';'
strlcpy(block_state.file.buf, yylval.string, sizeof(block_state.file.buf));
};

/***************************************************************************
* pseudo section
***************************************************************************/
pseudo_entry: T_PSEUDO
{
if (conf_parser_ctx.pass == 2)
reset_block_state();
} '{' pseudo_items '}' ';'
{
if (conf_parser_ctx.pass != 2)
break;

if (!block_state.command.buf[0] ||
!block_state.name.buf[0] ||
!block_state.nick.buf[0] ||
!block_state.host.buf[0])
break;

pseudo_register(block_state.name.buf, block_state.nick.buf, block_state.host.buf,
block_state.prepend.buf, block_state.command.buf);
};

pseudo_items: pseudo_items pseudo_item | pseudo_item;
pseudo_item: pseudo_command | pseudo_prepend | pseudo_name | pseudo_target | error ';' ;

pseudo_command: T_COMMAND '=' QSTRING ';'
{
if (conf_parser_ctx.pass == 2)
strlcpy(block_state.command.buf, yylval.string, sizeof(block_state.command.buf));
};

pseudo_name: NAME '=' QSTRING ';'
{
if (conf_parser_ctx.pass == 2)
strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
};

pseudo_prepend: T_PREPEND '=' QSTRING ';'
{
if (conf_parser_ctx.pass == 2)
strlcpy(block_state.prepend.buf, yylval.string, sizeof(block_state.prepend.buf));
};

pseudo_target: T_TARGET '=' QSTRING ';'
{
if (conf_parser_ctx.pass == 2)
{
struct split_nuh_item nuh;

nuh.nuhmask = yylval.string;
nuh.nickptr = NULL;
nuh.userptr = block_state.user.buf;
nuh.hostptr = block_state.host.buf;
nuh.nicksize = 0;
nuh.usersize = sizeof(block_state.nick.buf);
nuh.hostsize = sizeof(block_state.host.buf);
split_nuh(&nuh);

strlcpy(block_state.nick.buf, nuh.userptr, sizeof(block_state.nick.buf));
strlcpy(block_state.host.buf, nuh.hostptr, sizeof(block_state.host.buf));
}
};

/***************************************************************************
* section logging
***************************************************************************/
@@ -1621,28 +1692,26 @@ port_item: NUMBER
{
if (conf_parser_ctx.pass == 2)
{
#ifndef HAVE_LIBCRYPTO
if (block_state.flags.value & LISTENER_SSL)
#ifdef HAVE_LIBCRYPTO
if (!ConfigServerInfo.server_ctx)
{
conf_error_report("SSL not available - port closed");
break;
}
#endif
{
conf_error_report("SSL not available - port closed");
break;
}
add_listener($1, block_state.addr.buf, block_state.flags.value);
}
} | NUMBER TWODOTS NUMBER
{
if (conf_parser_ctx.pass == 2)
{
#ifndef HAVE_LIBCRYPTO
if (block_state.flags.value & LISTENER_SSL)
#ifdef HAVE_LIBCRYPTO
if (!ConfigServerInfo.server_ctx)
{
conf_error_report("SSL not available - port closed");
break;
}
#endif
{
conf_error_report("SSL not available - port closed");
break;
}

for (int i = $1; i <= $3; ++i)
add_listener(i, block_state.addr.buf, block_state.flags.value);
@@ -2229,10 +2298,8 @@ connect_aftype: AFTYPE '=' T_IPV4 ';'
block_state.aftype.value = AF_INET;
} | AFTYPE '=' T_IPV6 ';'
{
#ifdef IPV6
if (conf_parser_ctx.pass == 2)
block_state.aftype.value = AF_INET6;
#endif
};

connect_flags: IRCD_FLAGS
@@ -2513,7 +2580,6 @@ general_item: general_away_count |
general_gline_min_cidr6 |
general_stats_e_disabled |
general_max_watch |
general_services_name |
general_cycle_on_host_change |
error;

@@ -2735,15 +2801,6 @@ general_max_targets: MAX_TARGETS '=' NUMBER ';'
ConfigGeneral.max_targets = $3;
};

general_services_name: T_SERVICES_NAME '=' QSTRING ';'
{
if (conf_parser_ctx.pass == 2 && valid_servname(yylval.string))
{
MyFree(ConfigGeneral.service_name);
ConfigGeneral.service_name = xstrdup(yylval.string);
}
};

general_ping_cookie: PING_COOKIE '=' TBOOL ';'
{
ConfigGeneral.ping_cookie = yylval.number;
@@ -0,0 +1,141 @@
/*
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
* Copyright (c) 1997-2014 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/

/*! \file conf_pseudo.c
* \brief Handles with pseudo commands/service aliases.
* \version $Id: conf_pseudo.c 4299 2014-07-20 13:51:28Z michael $
*/

#include "stdinc.h"
#include "list.h"
#include "client.h"
#include "parse.h"
#include "hash.h"
#include "irc_string.h"
#include "ircd.h"
#include "numeric.h"
#include "send.h"
#include "memory.h"
#include "user.h"
#include "server.h"
#include "conf_pseudo.h"

struct pseudo_cmd
{
dlink_node node;
struct Message msg;
char *name;
char *nick;
char *serv;
char *prep;
char *command;
};

static dlink_list pseudo_cmd_list;

static int
m_pseudo(struct Client *source_p, int parc, char *parv[])
{
char buffer[IRCD_BUFSIZE] = "";
const struct pseudo_cmd *pseudo = (const struct pseudo_cmd *)parv[1];
struct Client *target_p = NULL;
struct Client *server_p = NULL;
const char *msg = parv[parc - 1];

if (parc < 3 || EmptyString(msg))
{
sendto_one_numeric(source_p, &me, ERR_NOTEXTTOSEND);
return 0;
}

if (!EmptyString(pseudo->prep))
{
snprintf(buffer, sizeof(buffer), "%s%s", pseudo->prep, msg);
msg = buffer;
}

target_p = find_person(source_p, pseudo->nick);
server_p = hash_find_server(pseudo->serv);

if (target_p && server_p && (target_p->servptr == server_p) && !IsMe(server_p))
{
sendto_one(target_p, ":%s PRIVMSG %s :%s",
source_p->id, target_p->id, msg);
return 0;
}

sendto_one_numeric(source_p, &me, ERR_SERVICESDOWN, pseudo->name);
return 0;
}

void
pseudo_register(const char *name, const char *nick,
const char *serv, const char *prep,
const char *command)
{
struct pseudo_cmd *cmd = NULL;

if (find_command(command))
return;

cmd = MyCalloc(sizeof(*cmd));
cmd->name = xstrdup(name);
cmd->nick = xstrdup(nick);
cmd->serv = xstrdup(serv);
cmd->prep = xstrdup(prep);
cmd->command = xstrdup(command);

cmd->msg.cmd = cmd->command;
cmd->msg.args_max = 2;
cmd->msg.flags = MFLG_EXTRA|MFLG_SLOW;
cmd->msg.extra = cmd;
cmd->msg.handlers[UNREGISTERED_HANDLER] = m_unregistered;
cmd->msg.handlers[CLIENT_HANDLER] = m_pseudo;
cmd->msg.handlers[SERVER_HANDLER] = m_ignore;
cmd->msg.handlers[ENCAP_HANDLER] = m_ignore;
cmd->msg.handlers[OPER_HANDLER] = m_pseudo;
cmd->msg.handlers[DUMMY_HANDLER] = m_ignore;
dlinkAdd(cmd, &cmd->node, &pseudo_cmd_list);

mod_add_cmd(&cmd->msg);
}

void
pseudo_clear(void)
{
dlink_node *ptr = NULL, *ptr_next = NULL;

DLINK_FOREACH_SAFE(ptr, ptr_next, pseudo_cmd_list.head)
{
struct pseudo_cmd *cmd = ptr->data;
assert(find_command(cmd->msg.cmd));

mod_del_cmd(&cmd->msg);
dlinkDelete(&cmd->node, &pseudo_cmd_list);

MyFree(cmd->name);
MyFree(cmd->nick);
MyFree(cmd->serv);
MyFree(cmd->prep);
MyFree(cmd->command);
MyFree(cmd);
}
}
@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/

@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/

@@ -141,16 +141,16 @@ show_events(struct Client *source_p)
const dlink_node *node;

sendto_one_numeric(source_p, &me, RPL_STATSDEBUG|SND_EXPLICIT,
"E :Operation Next Execution");
"E :Operation Next Execution");
sendto_one_numeric(source_p, &me, RPL_STATSDEBUG|SND_EXPLICIT,
"E :-------------------------------------------");
"E :---------------------------------------------");

DLINK_FOREACH(node, events.head)
{
const struct event *ev = node->data;

sendto_one_numeric(source_p, &me, RPL_STATSDEBUG|SND_EXPLICIT,
"E :%-28s %-4d seconds",
"E :%-30s %-4d seconds",
ev->name,
(int)(ev->next - CurrentTime));
}
@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/

@@ -161,7 +161,7 @@ fd_close(fde_t *F)
* fd_dump() - dump the list of active filedescriptors
*/
void
fd_dump(struct Client *source_p)
fd_dump(struct Client *source_p, int parc, char *parv[])
{
for (unsigned int i = 0; i < FD_HASH_SIZE; ++i)
for (fde_t *F = fd_hash[i]; F; F = F->hnext)
@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/

@@ -26,6 +26,7 @@

#include "stdinc.h"
#include "ircd_getopt.h"
#include "memory.h"

#define OPTCHAR '-'

@@ -56,19 +57,20 @@ parseargs(int *argc, char ***argv, struct lgetopt *opts)
while (1)
{
int found = 0;
const char *opt = NULL;

(*argc)--;
(*argv)++;

if (*argc < 1 || (*argv)[0][0] != OPTCHAR)
return;

(*argv)[0]++;
opt = &(*argv)[0][1];

/* Search through our argument list, and see if it matches */
for (unsigned int i = 0; opts[i].opt; ++i)
{
if (!strcmp(opts[i].opt, (*argv)[0]))
if (!strcmp(opts[i].opt, opt))
{
/* Found our argument */
found = 1;
@@ -100,8 +102,7 @@ parseargs(int *argc, char ***argv, struct lgetopt *opts)
usage(progname, opts);
}

*((char**)opts[i].argloc) = malloc(strlen((*argv)[1]) + 1);
strcpy(*((char**)opts[i].argloc), (*argv)[1]);
*((char **)opts[i].argloc) = xstrdup((*argv)[1]);
(*argc)--;
(*argv)++;
break;
@@ -121,7 +122,7 @@ parseargs(int *argc, char ***argv, struct lgetopt *opts)
if (!found)
{
fprintf(stderr, "error: unknown argument '%c%s'\n",
OPTCHAR, (*argv)[0]);
OPTCHAR, opt);
usage(progname, opts);
}
}
@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/

@@ -46,11 +46,9 @@ find_is_glined(const char *host, const char *user)

if ((t = parse_netmask(host, &iphost, NULL)) != HM_HOST)
{
#ifdef IPV6
if (t == HM_IPV6)
aftype = AF_INET6;
else
#endif
aftype = AF_INET;
piphost = &iphost;
}
@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/

@@ -780,18 +780,18 @@ list_one_channel(struct Client *source_p, struct Channel *chptr)
lt->topicts_max)
return;

if (lt->topic[0] && match(lt->topic, chptr->topic))
return;

if (!list_allow_channel(chptr->chname, lt))
return;

if (HasUMode(source_p, UMODE_ADMIN))
{
channel_modes(chptr, source_p, modebuf, parabuf);
channel_modes(chptr, source_p, modebuf, parabuf);

if (chptr->topic[0])
snprintf(listbuf, sizeof(listbuf), "[%s] ", modebuf);
else
snprintf(listbuf, sizeof(listbuf), "[%s]", modebuf);
}
if (chptr->topic[0])
snprintf(listbuf, sizeof(listbuf), "[%s] ", modebuf);
else
snprintf(listbuf, sizeof(listbuf), "[%s]", modebuf);

sendto_one_numeric(source_p, &me, RPL_LIST, chptr->chname,
dlink_list_length(&chptr->members),
@@ -807,9 +807,6 @@ list_one_channel(struct Client *source_p, struct Channel *chptr)
* Walk the channel buckets, ensure all pointers in a bucket are
* traversed before blocking on a sendq. This means, no locking is needed.
*
* N.B. This code is "remote" safe, but is not currently used for
* remote clients.
*
* - Dianora
*/
void
@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/

@@ -57,7 +57,6 @@
Also a bug in DigitParse above.
-Gozem 2002-07-19 gozem@linux.nu
*/
#ifdef IPV6
static int
try_parse_v6_netmask(const char *text, struct irc_ssaddr *addr, int *b)
{
@@ -161,7 +160,6 @@ try_parse_v6_netmask(const char *text, struct irc_ssaddr *addr, int *b)
*b = bits;
return HM_IPV6;
}
#endif

/* int try_parse_v4_netmask(const char *, struct irc_ssaddr *, int *);
* Input: A possible IPV4 address as a string.
@@ -253,10 +251,9 @@ parse_netmask(const char *text, struct irc_ssaddr *addr, int *b)
{
if (strchr(text, '.'))
return try_parse_v4_netmask(text, addr, b);
#ifdef IPV6
if (strchr(text, ':'))
return try_parse_v6_netmask(text, addr, b);
#endif

return HM_HOST;
}

@@ -266,7 +263,6 @@ parse_netmask(const char *text, struct irc_ssaddr *addr, int *b)
* Output: if match, -1 else 0
* Side effects: None
*/
#ifdef IPV6
int
match_ipv6(const struct irc_ssaddr *addr, const struct irc_ssaddr *mask, int bits)
{
@@ -285,7 +281,6 @@ match_ipv6(const struct irc_ssaddr *addr, const struct irc_ssaddr *mask, int bit
return -1;
return 0;
}
#endif

/* int match_ipv4(struct irc_ssaddr *, struct irc_ssaddr *, int)
* Input: An IP address, an IP mask, the number of bits in the mask.
@@ -316,15 +311,11 @@ void
mask_addr(struct irc_ssaddr *ip, int bits)
{
int mask;
#ifdef IPV6
struct sockaddr_in6 *v6_base_ip;
int i, m, n;
#endif
struct sockaddr_in *v4_base_ip;

#ifdef IPV6
if (ip->ss.ss_family != AF_INET6)
#endif
if (ip->ss.ss_family == AF_INET)
{
uint32_t tmp = 0;
v4_base_ip = (struct sockaddr_in *)ip;
@@ -333,7 +324,6 @@ mask_addr(struct irc_ssaddr *ip, int bits)
tmp = ntohl(v4_base_ip->sin_addr.s_addr);
v4_base_ip->sin_addr.s_addr = htonl(tmp & mask);
}
#ifdef IPV6
else
{
n = bits / 8;
@@ -346,7 +336,6 @@ mask_addr(struct irc_ssaddr *ip, int bits)
for (i = n + 1; i < 16; i++)
v6_base_ip->sin6_addr.s6_addr[i] = 0;
}
#endif
}

/* Hashtable stuff...now external as it's used in m_stats.c */
@@ -382,7 +371,6 @@ hash_ipv4(const struct irc_ssaddr *addr, int bits)
* Output: A hash value of the IP address.
* Side effects: None
*/
#ifdef IPV6
static uint32_t
hash_ipv6(const struct irc_ssaddr *addr, int bits)
{
@@ -404,9 +392,9 @@ hash_ipv6(const struct irc_ssaddr *addr, int bits)
else
return v & (ATABLE_SIZE - 1);
}

return v & (ATABLE_SIZE - 1);
}
#endif

/* int hash_text(const char *start)
* Input: The start of the text to hash.
@@ -467,7 +455,6 @@ find_conf_by_address(const char *name, struct irc_ssaddr *addr, unsigned int typ
if (addr)
{
/* Check for IPV6 matches... */
#ifdef IPV6
if (fam == AF_INET6)
{
for (b = 128; b >= 0; b -= 16)
@@ -491,9 +478,7 @@ find_conf_by_address(const char *name, struct irc_ssaddr *addr, unsigned int typ
}
}
}
else
#endif
if (fam == AF_INET)
else if (fam == AF_INET)
{
for (b = 32; b >= 0; b -= 8)
{
@@ -656,13 +641,11 @@ add_conf_by_address(const unsigned int type, struct MaskItem *conf)
bits -= bits % 8;
dlinkAdd(arec, &arec->node, &atable[hash_ipv4(&arec->Mask.ipa.addr, bits)]);
break;
#ifdef IPV6
case HM_IPV6:
/* We have to do this, since we do not re-hash for every bit -A1kmm. */
bits -= bits % 16;
dlinkAdd(arec, &arec->node, &atable[hash_ipv6(&arec->Mask.ipa.addr, bits)]);
break;
#endif
default: /* HM_HOST */
arec->Mask.hostname = hostname;
dlinkAdd(arec, &arec->node, &atable[get_mask_hash(hostname)]);
@@ -693,13 +676,11 @@ delete_one_address_conf(const char *address, struct MaskItem *conf)
bits -= bits % 8;
hv = hash_ipv4(&addr, bits);
break;
#ifdef IPV6
case HM_IPV6:
/* We have to do this, since we do not re-hash for every bit -A1kmm. */
bits -= bits % 16;
hv = hash_ipv6(&addr, bits);
break;
#endif
default: /* HM_HOST */
hv = get_mask_hash(address);
break;
@@ -748,6 +729,7 @@ clear_out_address_conf(void)
continue;

dlinkDelete(&arec->node, &atable[i]);
arec->conf->active = 0;

if (!arec->conf->ref_count)
conf_free(arec->conf);
@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/

@@ -55,7 +55,6 @@ ipcache_hash_address(const struct irc_ssaddr *addr)
hash = ((ip >> 12) + ip) & (IP_HASH_SIZE - 1);
return hash;
}
#ifdef IPV6
else
{
const struct sockaddr_in6 *v6 = (const struct sockaddr_in6 *)addr;
@@ -67,9 +66,6 @@ ipcache_hash_address(const struct irc_ssaddr *addr)
hash = hash & (IP_HASH_SIZE - 1);
return hash;
}
#else
return 0;
#endif
}

/* ipcache_find_or_add_address()
@@ -88,14 +84,12 @@ ipcache_find_or_add_address(struct irc_ssaddr *addr)
struct ip_entry *iptr = NULL;
uint32_t hash_index = ipcache_hash_address(addr);
struct sockaddr_in *v4 = (struct sockaddr_in *)addr, *ptr_v4;
#ifdef IPV6
struct sockaddr_in6 *v6 = (struct sockaddr_in6 *)addr, *ptr_v6;
#endif

DLINK_FOREACH(ptr, ip_hash_table[hash_index].head)
{
iptr = ptr->data;
#ifdef IPV6

if (iptr->ip.ss.ss_family != addr->ss.ss_family)
continue;

@@ -106,7 +100,6 @@ ipcache_find_or_add_address(struct irc_ssaddr *addr)
return iptr; /* Found entry already in hash, return it. */
}
else
#endif
{
ptr_v4 = (struct sockaddr_in *)&iptr->ip;
if (!memcmp(&v4->sin_addr, &ptr_v4->sin_addr, sizeof(struct in_addr)))
@@ -137,14 +130,12 @@ ipcache_remove_address(struct irc_ssaddr *addr)
dlink_node *ptr = NULL;
uint32_t hash_index = ipcache_hash_address(addr);
struct sockaddr_in *v4 = (struct sockaddr_in *)addr, *ptr_v4;
#ifdef IPV6
struct sockaddr_in6 *v6 = (struct sockaddr_in6 *)addr, *ptr_v6;
#endif

DLINK_FOREACH(ptr, ip_hash_table[hash_index].head)
{
struct ip_entry *iptr = ptr->data;
#ifdef IPV6

if (iptr->ip.ss.ss_family != addr->ss.ss_family)
continue;

@@ -155,7 +146,6 @@ ipcache_remove_address(struct irc_ssaddr *addr)
continue;
}
else
#endif
{
ptr_v4 = (struct sockaddr_in *)&iptr->ip;
if (memcmp(&v4->sin_addr, &ptr_v4->sin_addr, sizeof(struct in_addr)))
@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/

@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/

@@ -429,6 +429,7 @@ ssl_init(void)

fprintf(stderr, "ERROR: Could not initialize the SSL Server context -- %s\n", s);
ilog(LOG_TYPE_IRCD, "ERROR: Could not initialize the SSL Server context -- %s\n", s);
exit(EXIT_FAILURE);
}

SSL_CTX_set_options(ConfigServerInfo.server_ctx, SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3);
@@ -457,6 +458,7 @@ ssl_init(void)

fprintf(stderr, "ERROR: Could not initialize the SSL Client context -- %s\n", s);
ilog(LOG_TYPE_IRCD, "ERROR: Could not initialize the SSL Client context -- %s\n", s);
exit(EXIT_FAILURE);
}

SSL_CTX_set_options(ConfigServerInfo.client_ctx, SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3);
@@ -531,7 +533,7 @@ main(int argc, char *argv[])
/* We need this to initialise the fd array before anything else */
fdlist_init();
log_set_file(LOG_TYPE_IRCD, 0, logFileName);
check_can_use_v6();

init_netio(); /* This needs to be setup early ! -- adrian */

/* Check if there is pidfile and daemon already running */
@@ -642,7 +644,7 @@ main(int argc, char *argv[])
event_addish(&event_try_connections, NULL);

/* Setup the timeout check. I'll shift it later :) -- adrian */
event_addish(&event_comm_checktimeouts, NULL);
event_add(&event_comm_checktimeouts, NULL);

event_addish(&event_save_all_databases, NULL);

@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/

@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/

@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/

@@ -38,13 +38,13 @@
#include "send.h"
#include "memory.h"

static PF accept_connection;
#define TOOFAST_WARNING "ERROR :Your host is trying to (re)connect too fast -- throttled.\r\n"
#define DLINE_WARNING "ERROR :You have been D-lined.\r\n"

static dlink_list ListenerPollList;
static void close_listener(struct Listener *listener);
static dlink_list listener_list;

static struct Listener *
make_listener(int port, struct irc_ssaddr *addr)
make_listener(const int port, const struct irc_ssaddr *addr)
{
struct Listener *listener = MyCalloc(sizeof(struct Listener));

@@ -59,7 +59,7 @@ free_listener(struct Listener *listener)
{
assert(listener);

dlinkDelete(&listener->node, &ListenerPollList);
dlinkDelete(&listener->node, &listener_list);
MyFree(listener);
}

@@ -90,7 +90,7 @@ show_ports(struct Client *source_p)
char *p = NULL;
const dlink_node *ptr = NULL;

DLINK_FOREACH(ptr, ListenerPollList.head)
DLINK_FOREACH(ptr, listener_list.head)
{
const struct Listener *listener = ptr->data;
p = buf;
@@ -122,6 +122,80 @@ show_ports(struct Client *source_p)
}
}

static void
listener_accept_connection(fde_t *pfd, void *data)
{
static time_t rate = 0;
struct irc_ssaddr addr;
int fd;
int pe;
struct Listener *listener = data;

assert(listener);

/* There may be many reasons for error return, but
* in otherwise correctly working environment the
* probable cause is running out of file descriptors
* (EMFILE, ENFILE or others?). The man pages for
* accept don't seem to list these as possible,
* although it's obvious that it may happen here.
* Thus no specific errors are tested at this
* point, just assume that connections cannot
* be accepted until some old is closed first.
*/
while ((fd = comm_accept(listener, &addr)) != -1)
{
/*
* check for connection limit
*/
if (number_fd > hard_fdlimit - 10)
{
++ServerStats.is_ref;
sendto_realops_flags_ratelimited(&rate, "All connections in use. (%s)",
get_listener_name(listener));

if (!(listener->flags & LISTENER_SSL))
send(fd, "ERROR :All connections in use\r\n", 32, 0);

close(fd);
break; /* jump out and re-register a new io request */
}

/*
* Do an initial check we aren't connecting too fast or with too many
* from this IP...
*/
if ((pe = conf_connect_allowed(&addr, addr.ss.ss_family)))
{
++ServerStats.is_ref;

if (!(listener->flags & LISTENER_SSL))
{
switch (pe)
{
case BANNED_CLIENT:
send(fd, DLINE_WARNING, sizeof(DLINE_WARNING)-1, 0);
break;
case TOO_FAST:
send(fd, TOOFAST_WARNING, sizeof(TOOFAST_WARNING)-1, 0);
break;
}
}

close(fd);
continue; /* drop the one and keep on clearing the queue */
}

++ServerStats.is_ac;
add_connection(listener, &addr, fd);
}

/* Re-register a new IO request for the next accept .. */
comm_setselect(&listener->fd, COMM_SELECT_READ, listener_accept_connection,
listener, 0);
}


/*
* inetport - create a listener socket in the AF_INET or AF_INET6 domain,
* bind it to the port given in 'port' and listen to it
@@ -190,7 +264,7 @@ inetport(struct Listener *listener)

/* Listen completion events are READ events .. */

accept_connection(&listener->fd, listener);
listener_accept_connection(&listener->fd, listener);
return 1;
}

@@ -201,7 +275,7 @@ find_listener(int port, struct irc_ssaddr *addr)
struct Listener *listener = NULL;
struct Listener *last_closed = NULL;

DLINK_FOREACH(ptr, ListenerPollList.head)
DLINK_FOREACH(ptr, listener_list.head)
{
listener = ptr->data;

@@ -219,6 +293,50 @@ find_listener(int port, struct irc_ssaddr *addr)
return (last_closed);
}

/*
* close_listener - close a single listener
*/
static void
close_listener(struct Listener *listener)
{
assert(listener != NULL);

if (listener == NULL)
return;

if (listener->fd.flags.open)
fd_close(&listener->fd);

listener->active = 0;

if (listener->ref_count)
return;

free_listener(listener);
}

/*
* close_listeners - close and free all listeners that are not being used
*/
void
close_listeners(void)
{
dlink_node *ptr = NULL, *ptr_next = NULL;

/* close all 'extra' listening ports we have */
DLINK_FOREACH_SAFE(ptr, ptr_next, listener_list.head)
close_listener(ptr->data);
}

void
listener_release(struct Listener *listener)
{
assert(listener->ref_count > 0);

if (--listener->ref_count == 0 && !listener->active)
close_listener(listener);
}

/*
* add_listener- create a new listener
* port - the port number to listen on
@@ -232,10 +350,8 @@ add_listener(int port, const char *vhost_ip, unsigned int flags)
struct irc_ssaddr vaddr;
struct addrinfo hints, *res;
char portname[PORTNAMELEN + 1];
#ifdef IPV6
static short int pass = 0; /* if ipv6 and no address specified we need to
have two listeners; one for each protocol. */
#endif

/*
* if no or invalid port in conf line, don't bother
@@ -252,28 +368,26 @@ add_listener(int port, const char *vhost_ip, unsigned int flags)
/* Get us ready for a bind() and don't bother doing dns lookup */
hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST;

#ifdef IPV6
if (ConfigServerInfo.can_use_v6)
{
snprintf(portname, sizeof(portname), "%d", port);
getaddrinfo("::", portname, &hints, &res);
vaddr.ss.ss_family = AF_INET6;
assert(res != NULL);
/* TBD: This makes no sense here at all. Needs to be reworked */

memcpy((struct sockaddr*)&vaddr, res->ai_addr, res->ai_addrlen);
vaddr.ss_port = port;
vaddr.ss_len = res->ai_addrlen;
freeaddrinfo(res);
}
else
#endif
snprintf(portname, sizeof(portname), "%d", port);
getaddrinfo("::", portname, &hints, &res);
vaddr.ss.ss_family = AF_INET6;
assert(res != NULL);

memcpy((struct sockaddr*)&vaddr, res->ai_addr, res->ai_addrlen);
vaddr.ss_port = port;
vaddr.ss_len = res->ai_addrlen;
freeaddrinfo(res);
#ifdef MAKES_NO_SENSE
{
struct sockaddr_in *v4 = (struct sockaddr_in*) &vaddr;
v4->sin_addr.s_addr = INADDR_ANY;
vaddr.ss.ss_family = AF_INET;
vaddr.ss_len = sizeof(struct sockaddr_in);
v4->sin_port = htons(port);
}
#endif

snprintf(portname, PORTNAMELEN, "%d", port);

@@ -289,15 +403,14 @@ add_listener(int port, const char *vhost_ip, unsigned int flags)
vaddr.ss_len = res->ai_addrlen;
freeaddrinfo(res);
}
#ifdef IPV6
else if (pass == 0 && ConfigServerInfo.can_use_v6)
else if (pass == 0)
{
/* add the ipv4 listener if we havent already */
pass = 1;
add_listener(port, "0.0.0.0", flags);
}

pass = 0;
#endif

if ((listener = find_listener(port, &vaddr)))
{
@@ -309,7 +422,7 @@ add_listener(int port, const char *vhost_ip, unsigned int flags)
else
{
listener = make_listener(port, &vaddr);
dlinkAdd(listener, &listener->node, &ListenerPollList);
dlinkAdd(listener, &listener->node, &listener_list);
listener->flags = flags;
}

@@ -318,125 +431,3 @@ add_listener(int port, const char *vhost_ip, unsigned int flags)
else
close_listener(listener);
}

/*
* close_listener - close a single listener
*/
static void
close_listener(struct Listener *listener)
{
assert(listener != NULL);

if (listener == NULL)
return;

if (listener->fd.flags.open)
fd_close(&listener->fd);

listener->active = 0;

if (listener->ref_count)
return;

free_listener(listener);
}

/*
* close_listeners - close and free all listeners that are not being used
*/
void
close_listeners(void)
{
dlink_node *ptr = NULL, *ptr_next = NULL;

/* close all 'extra' listening ports we have */
DLINK_FOREACH_SAFE(ptr, ptr_next, ListenerPollList.head)
close_listener(ptr->data);
}

#define TOOFAST_WARNING "ERROR :Your host is trying to (re)connect too fast -- throttled.\r\n"
#define DLINE_WARNING "ERROR :You have been D-lined.\r\n"

static void
accept_connection(fde_t *pfd, void *data)
{
static time_t last_oper_notice = 0;
struct irc_ssaddr addr;
int fd;
int pe;
struct Listener *listener = data;

memset(&addr, 0, sizeof(addr));

assert(listener);

/* There may be many reasons for error return, but
* in otherwise correctly working environment the
* probable cause is running out of file descriptors
* (EMFILE, ENFILE or others?). The man pages for
* accept don't seem to list these as possible,
* although it's obvious that it may happen here.
* Thus no specific errors are tested at this
* point, just assume that connections cannot
* be accepted until some old is closed first.
*/
while ((fd = comm_accept(listener, &addr)) != -1)
{
/*
* check for connection limit
*/
if (number_fd > hard_fdlimit - 10)
{
++ServerStats.is_ref;

/*
* slow down the whining to opers bit
*/
if ((last_oper_notice + 20) <= CurrentTime)
{
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
"All connections in use. (%s)",
get_listener_name(listener));
last_oper_notice = CurrentTime;
}

if (!(listener->flags & LISTENER_SSL))
send(fd, "ERROR :All connections in use\r\n", 32, 0);

close(fd);
break; /* jump out and re-register a new io request */
}

/*
* Do an initial check we aren't connecting too fast or with too many
* from this IP...
*/
if ((pe = conf_connect_allowed(&addr, addr.ss.ss_family)))
{
++ServerStats.is_ref;

if (!(listener->flags & LISTENER_SSL))
{
switch (pe)
{
case BANNED_CLIENT:
send(fd, DLINE_WARNING, sizeof(DLINE_WARNING)-1, 0);
break;
case TOO_FAST:
send(fd, TOOFAST_WARNING, sizeof(TOOFAST_WARNING)-1, 0);
break;
}
}

close(fd);
continue; /* drop the one and keep on clearing the queue */
}

++ServerStats.is_ac;
add_connection(listener, &addr, fd);
}

/* Re-register a new IO request for the next accept .. */
comm_setselect(&listener->fd, COMM_SELECT_READ, accept_connection,
listener, 0);
}
@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/

@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/

@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/

@@ -54,7 +54,7 @@ MyRealloc(void *x, size_t y)
{
void *ret = realloc(x, y);

if (ret == NULL)
if (y && ret == NULL)
outofmemory();

return ret;
@@ -693,7 +693,7 @@ mp_pool_assert_ok(mp_pool_t *pool)
}

void
mp_pool_garbage_collect(void *arg)
mp_pool_garbage_collect(void *unused)
{
for (mp_pool_t *pool = mp_allocated_pools; pool; pool = pool->next)
mp_pool_clean(pool, 0, 1);
@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/

@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/

@@ -16,7 +16,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/

@@ -69,11 +69,9 @@ motd_create(const char *mask, const char *path)
case HM_IPV4:
tmp->type = MOTD_IPMASKV4;
break;
#ifdef IPV6
case HM_IPV6:
tmp->type = MOTD_IPMASKV6;
break;
#endif
default: /* HM_HOST */
tmp->type = MOTD_HOSTMASK;
break;
@@ -256,13 +254,11 @@ motd_lookup(const struct Client *client_p)
if (match_ipv4(&client_p->localClient->ip, &motd->address, motd->addrbits))
return motd;
break;
#ifdef IPV6
case MOTD_IPMASKV6:
if (client_p->localClient->aftype == AF_INET6)
if (match_ipv6(&client_p->localClient->ip, &motd->address, motd->addrbits))
return motd;
break;
#endif
default: break;
}
}
@@ -410,7 +406,7 @@ motd_clear(void)
* \param source_p Client requesting statistics.
*/
void
motd_report(struct Client *source_p)
motd_report(struct Client *source_p, int parc, char *parv[])
{
const dlink_node *ptr = NULL;

@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/

@@ -315,7 +315,7 @@ static const char *const replies[] =
/* 282 RPL_ENDOFACCEPT */ ":End of /ACCEPT list.",
/* 283 */ NULL,
/* 284 */ NULL,
/* 285 RPL_NEWHOSTIS */ ":Your new host is %s",
/* 285 */ NULL,
/* 286 */ NULL,
/* 287 */ NULL,
/* 288 */ NULL,
@@ -426,7 +426,7 @@ static const char *const replies[] =
/* 393 */ NULL,
/* 394 */ NULL,
/* 395 */ NULL,
/* 396 */ NULL,
/* 396 RPL_VISIBLEHOST */ "%s :is now your visible host",
/* 397 */ NULL,
/* 398 */ NULL,
/* 399 */ NULL,
@@ -470,7 +470,7 @@ static const char *const replies[] =
/* 437 ERR_UNAVAILRESOURCE */ "%s :Nick/channel is temporarily unavailable",
/* 438 ERR_NICKTOOFAST */ "%s :Nick change too fast. Please wait %u seconds.",
/* 439 */ NULL,
/* 440 ERR_SERVICESDOWN */ "%s :Services is currently down.",
/* 440 ERR_SERVICESDOWN */ "%s :Services are currently unavailable.",
/* 441 ERR_USERNOTINCHANNEL */ "%s %s :They aren't on that channel",
/* 442 ERR_NOTONCHANNEL */ "%s :You're not on that channel",
/* 443 ERR_USERONCHANNEL */ "%s %s :is already on channel",
@@ -494,7 +494,7 @@ static const char *const replies[] =
/* 461 ERR_NEEDMOREPARAMS */ "%s :Not enough parameters",
/* 462 ERR_ALREADYREGISTRED */ ":You may not reregister",
/* 463 */ NULL,
/* 464 ERR_PASSWDMISMATCH */ ":Password Incorrect",
/* 464 ERR_PASSWDMISMATCH */ ":Password incorrect",
/* 465 ERR_YOUREBANNEDCREEP */ ":You are banned from this server- %s",
/* 466 */ NULL,
/* 467 */ NULL,
@@ -553,7 +553,7 @@ static const char *const replies[] =
/* 520 */ NULL,
/* 521 ERR_LISTSYNTAX */ ":Bad list syntax, type /QUOTE HELP LIST",
/* 522 */ NULL,
/* 523 */ NULL,
/* 523 ERR_WHOLIMEXCEED */ "%u :%s search limit exceeded.",
/* 524 ERR_HELPNOTFOUND */ "%s :Help not found",
/* 525 */ NULL,
/* 526 */ NULL,
@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/

@@ -301,7 +301,7 @@ read_packet(fde_t *fd, void *data)
switch (SSL_get_error(fd->ssl, length))
{
case SSL_ERROR_WANT_WRITE:
comm_setselect(fd, COMM_SELECT_WRITE, (PF *)sendq_unblocked, client_p, 0);
comm_setselect(fd, COMM_SELECT_WRITE, sendq_unblocked, client_p, 0);
return;
case SSL_ERROR_WANT_READ:
errno = EWOULDBLOCK;
@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/

@@ -102,7 +102,7 @@ static struct MessageTree
* side effects -
*/
static void
parse_remove_unknown(struct Client *client_p, char *lsender, char *lbuffer)
parse_remove_unknown(struct Client *client_p, const char *lsender, char *lbuffer)
{
/*
* Do kill if it came from a server because it means there is a ghost
@@ -297,7 +297,7 @@ parse(struct Client *client_p, char *pbuffer, char *bufend)
* Copy the prefix to 'sender' assuming it terminates
* with SPACE (or NULL, which is an error, though).
*/
char *sender = ++ch;
const char *sender = ++ch;

if ((s = strchr(ch, ' ')))
{
@@ -307,8 +307,8 @@ parse(struct Client *client_p, char *pbuffer, char *bufend)

if (*sender && IsServer(client_p))
{
if ((from = find_person(client_p, sender)) == NULL)
from = hash_find_server(sender);
if ((from = hash_find_id(sender)) == NULL)
from = hash_find_client(sender);

/*
* Hmm! If the client corresponding to the prefix is not found--what is
@@ -404,6 +404,14 @@ parse(struct Client *client_p, char *pbuffer, char *bufend)

para[parc] = ch;

if (msg_ptr && (msg_ptr->flags & MFLG_EXTRA))
{
/*
* XXX: This will have to go away after the command handler rewrite
*/
para[++parc] = msg_ptr->extra;
}

if (s)
{
if (paramcount > MAXPARA)