+2004-12-13 Michael Poole <mdpoole@troilus.org>
+
+ * doc/example.conf: Update configuration to move Client block
+ comment after sample Class blocks, and update entries in it.
+
+ * ircd/ircd_lexer.y: Recognize IP and USERNAME tokens.
+
+ * ircd/ircd_parser.y: Add ip and username global variables and IP
+ and USERNAME tokens. Add clientip and clientusername alternatives
+ for clientitem, and update clientblock to correspond.
+
+ * ircd/ircd_res.c (delete_resolver_queries): Do not try to walk
+ the request_list before request_list is initialized.
+ (cres_mem): Likewise.
+
+ * ircd/os_generic.c (sockaddr_from_irc): Improve guessing of
+ proper address family.
+
+ * ircd/s_conf.c (attach_iline): Allow aconf->host == NULL, which
+ means DNS reply is optional. If aconf->addrbits >= 0, test it.
+
+ * tools/crypter: Delete.
+
2004-12-11 Kevin L Mitchell <klmitch@mit.edu>
* ircd/*.c: use new assert() in ircd_log.h in preference to system
# usermode = "+i";
# };
#
+# maxlinks should be set at either 0 or 1.
+#
# <connect freq> applies only to servers, and specifies the frequency
# that the server tries to autoconnect. setting this to 0 will cause
# the server to attempt to connect repeatedly with no delay until the
# <maximum links> condition is satisfied. This is a Bad Thing(tm).
# Note that times can be specified as a number, or by giving something
# like: 1 minutes 20 seconds, or 1*60+20.
-# Client {
-# host = "user@host";
-# ip = "ip@host";
-# password = "password";
-# class = "classname";
-# };
-#
-# <maximum links> should be set at either 0 or 1.
#
# Recommended server classes:
# All your server uplinks you are not a hub for.
sendq = 9000000;
};
+# Client {
+# username = "ident";
+# host = "host";
+# ip = "127.0.0.0/8";
+# password = "password";
+# class = "classname";
+# maxlinks = 3;
+# };
+#
+# Everything in a Client block is optional. If a username mask is
+# given, it must match the client's username from the IDENT protocol.
+# If a host mask is given, the client's hostname must resolve and
+# match the host mask. If a CIDR-style IP mask is given, the client
+# must have an IP matching that range. If maxlinks is given, it is
+# limits the number of matching clients allowed from a particular IP
+# address.
+#
# Recommended client classes:
# Client classes. 10 = locals; 2 = for all .net and .com that are not
# in Europe; 1 = for everybody.
Client
{
class = "Other";
- host = "*@*";
+ username = "*";
};
Class {
name = "America";
TOKEN(SENDQ),
TOKEN(NAME),
TOKEN(HOST),
+ TOKEN(IP),
+ TOKEN(USERNAME),
TOKEN(PASS),
TOKEN(SECONDS),
TOKEN(MINUTES),
int yylex(void);
/* Now all the globals we need :/... */
int tping, tconn, maxlinks, sendq, port, invert, stringno;
- char *name, *pass, *host, *origin, *hub_limit;
+ char *name, *pass, *host, *ip, *username, *origin, *hub_limit;
char *stringlist[MAX_STRINGS];
struct ConnectionClass *c_class;
struct DenyConf *dconf;
%token SENDQ
%token NAME
%token HOST
+%token IP
+%token USERNAME
%token PASS
%token LOCAL
%token SECONDS
}
'{' clientitems '}' ';'
{
- if (host)
- {
- struct ConfItem *aconf = make_conf(CONF_CLIENT);
- conf_parse_userhost(aconf, host);
- aconf->conn_class = c_class ? c_class : find_class("default");
- aconf->maximum = maxlinks;
- }
+ struct ConfItem *aconf = make_conf(CONF_CLIENT);
+ unsigned char addrbits;
+ aconf->username = username;
+ aconf->host = host;
+ if (ip && ipmask_parse(ip, &aconf->address.addr, &addrbits))
+ aconf->addrbits = addrbits;
else
- {
- MyFree(host);
- parse_error("Bad client block");
- }
+ aconf->addrbits = -1;
+ aconf->conn_class = c_class ? c_class : find_class("default");
+ aconf->maximum = maxlinks;
host = NULL;
+ username = NULL;
c_class = NULL;
+ MyFree(ip);
};
clientitems: clientitem clientitems | clientitem;
-clientitem: clienthost | clientclass | clientpass | clientmaxlinks | error;
+clientitem: clienthost | clientip | clientusername | clientclass | clientpass | clientmaxlinks | error;
clienthost: HOST '=' QSTRING ';'
{
MyFree(host);
DupString(host, $3);
};
+clientip: IP '=' QSTRING ';'
+{
+ MyFree(ip);
+ DupString(ip, $3);
+}
+clientusername: USERNAME '=' QSTRING ';'
+{
+ MyFree(username);
+ DupString(username, $3);
+}
clientclass: CLASS '=' QSTRING ';'
{
c_class = find_class($3);
struct dlink *ptr, *next_ptr;
struct reslist *request;
- for (ptr = request_list.next; ptr != &request_list; ptr = next_ptr)
- {
- next_ptr = ptr->next;
- request = (struct reslist*)ptr;
- if (vptr == request->query.vptr) {
- Debug((DEBUG_DNS, "Removing request %p with vptr %p", request, vptr));
- rem_request(request);
+ if (request_list.next) {
+ for (ptr = request_list.next; ptr != &request_list; ptr = next_ptr)
+ {
+ next_ptr = ptr->next;
+ request = (struct reslist*)ptr;
+ if (vptr == request->query.vptr) {
+ Debug((DEBUG_DNS, "Removing request %p with vptr %p", request, vptr));
+ rem_request(request);
+ }
}
}
}
size_t request_mem = 0;
int request_count = 0;
- for (dlink = request_list.next; dlink != &request_list; dlink = dlink->next) {
- request = (struct reslist*)dlink;
- request_mem += sizeof(*request);
- if (request->name)
- request_mem += strlen(request->name) + 1;
- ++request_count;
+ if (request_list.next) {
+ for (dlink = request_list.next; dlink != &request_list; dlink = dlink->next) {
+ request = (struct reslist*)dlink;
+ request_mem += sizeof(*request);
+ if (request->name)
+ request_mem += strlen(request->name) + 1;
+ ++request_count;
+ }
}
send_reply(sptr, SND_EXPLICIT | RPL_STATSDEBUG,
int family;
slen = sizeof(sin6);
- if ((0 <= compat_fd) && (0 == getsockname(compat_fd, (struct sockaddr*)&sin6, &slen)))
- family = sin6.sin6_family;
- else if (irc_in_addr_is_ipv4(&VirtualHost.addr))
- family = AF_INET;
- else
- family = AF_INET6;
+ if (0 <= compat_fd) {
+ if (0 == getsockname(compat_fd, (struct sockaddr*)&sin6, &slen))
+ family = sin6.sin6_family;
+ else if (irc_in_addr_is_ipv4(&VirtualHost.addr))
+ family = AF_INET;
+ else
+ family = AF_INET6;
+ } else {
+ if (irc_in_addr_is_ipv4(&irc->addr))
+ family = AF_INET;
+ else
+ family = AF_INET6;
+ }
memset(v6, 0, sizeof(*v6));
if (!irc) {
hp = cli_dns_reply(cptr);
for (aconf = GlobalConfList; aconf; aconf = aconf->next) {
- if (aconf->status != CONF_CLIENT || !aconf->host)
+ if (aconf->status != CONF_CLIENT)
continue;
if (aconf->address.port && aconf->address.port != cli_listener(cptr)->addr.port)
continue;
if (match(aconf->username, cli_username(cptr)))
continue;
}
- if (hp) {
- Debug((DEBUG_DNS, "a_il: %s->%s", cli_sockhost(cptr), hp->h_name));
- if (!match(aconf->host, hp->h_name))
- return check_limit_and_attach(cptr, aconf);
- }
+ if (aconf->host && (!hp || match(aconf->host, hp->h_name)))
+ continue;
if ((aconf->addrbits >= 0)
- && ipmask_check(&cli_ip(cptr), &aconf->address.addr, aconf->addrbits))
- return check_limit_and_attach(cptr, aconf);
+ && !ipmask_check(&cli_ip(cptr), &aconf->address.addr, aconf->addrbits))
+ continue;
+ return check_limit_and_attach(cptr, aconf);
}
return ACR_NO_AUTHORIZATION;
}
+++ /dev/null
-#!/usr/bin/perl
-
-#************************************************************************
-#* IRC - Internet Relay Chat, tools/crypter
-#* Copyright (C) 1991 Sean Batt
-#*
-#* 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA.
-#*
-#* $Id: crypter,v 1.2 2002-03-07 22:52:57 ghostwolf Exp $
-#*/
-
-#From Sean Batt sean@coombs.anu.edu.au
-#
-#Temporary output file
-#
-$tmpfile = "/tmp/ircd.conf.tmp";
-
-#
-#Original ircd.conf file
-#
-$ircdconf = @ARGV[0];
-
-print "crypting ",$ircdconf,"\n";
-@saltset = ('a' .. 'z', 'A' .. 'Z', '0' .. '9', '.', '/');
-
-umask(0077);
-open ($ircdout, ">$tmpfile") || die "open $!";
-
-while ($text = <>) {
-#if its not an "O" line we can ignore it
- $text =~ /^o/i || print ($ircdout $text) && next;
- chop($text);
- @oline = split(':', $text);
- $salt = $saltset[rand(time)%64].$saltset[(rand(time)>>6)%64];
- $oline[2] = crypt(@oline[2], $salt);
- print ($ircdout join(':',@oline)."\n");
-}
-close ($ircdout);
-close ($ircdin);
-print "/bin/cp ",$tmpfile," ",$ircdconf,"\n";
-(fork()==0) ? exec("/bin/cp", $tmpfile, $ircdconf) : wait;
-print "",$ircdconf," has been crypted successfully!\n";
-
-#unlink($tmpfile);