[IRC-Dev CVS] [CVS] Module ircd-ircdev: Change committed
Brought to you by:
zolty
From: Toni G. <zo...@us...> - 2005-02-21 10:22:12
|
CVSROOT : /cvsroot/irc-dev Module : ircd-ircdev Commit time: 2005-02-21 10:20:35 UTC Modified files: ChangeLog ChangeLog.es configure include/patchlevel.h ircd/IPcheck.c ircd/channel.c ircd/engine_epoll.c ircd/ircd_parser.y ircd/m_silence.c ircd/s_bsd.c ircd/s_err.c ircd/s_stats.c ircd/test/ircd_chattr_t.c Added files: tools/convert-conf.py Log message: Author: zoltan <zo...@ir...> Log message: 2005-02-21 Toni García <zo...@ir...> 1.0.alpha18 * Fix de más bugs IPv6 * Fix bugs IPv6 de STATS I, C, O * Fix bugs STATS U * Fix de un bug de SILENCE ---------------------- diff included ---------------------- Index: ircd-ircdev/ChangeLog diff -u ircd-ircdev/ChangeLog:1.18 ircd-ircdev/ChangeLog:1.19 --- ircd-ircdev/ChangeLog:1.18 Tue Feb 15 08:31:48 2005 +++ ircd-ircdev/ChangeLog Mon Feb 21 02:19:26 2005 @@ -1,10 +1,16 @@ # # ChangeLog for ircd-ircdev # -# $Id: ChangeLog,v 1.18 2005/02/15 16:31:48 zolty Exp $ +# $Id: ChangeLog,v 1.19 2005/02/21 10:19:26 zolty Exp $ # # Insert new changes at beginning of the change list. # +2005-02-21 Toni García <zo...@ir...> 1.0.alpha18 + * Fix some IPv6 bugs + * Fix IPv6 on STATS bugs + * Fix STATS U bug + * Fix SILENCE bug + 2005-02-15 Toni García <zo...@ir...> 1.0.alpha17 * Fix IPv6 bug * Fix MOTD bug Index: ircd-ircdev/ChangeLog.es diff -u ircd-ircdev/ChangeLog.es:1.18 ircd-ircdev/ChangeLog.es:1.19 --- ircd-ircdev/ChangeLog.es:1.18 Tue Feb 15 08:31:49 2005 +++ ircd-ircdev/ChangeLog.es Mon Feb 21 02:19:43 2005 @@ -1,14 +1,20 @@ # # Log de Cambios para ircd-ircdev # -# $Id: ChangeLog.es,v 1.18 2005/02/15 16:31:49 zolty Exp $ +# $Id: ChangeLog.es,v 1.19 2005/02/21 10:19:43 zolty Exp $ # # Insertar los nuevos cambios al principio de esta lista de cambios. # +2005-02-21 Toni García <zo...@ir...> 1.0.alpha18 + * Fix de más bugs IPv6 + * Fix bugs IPv6 de STATS I, C, O + * Fix bugs STATS U + * Fix de un bug de SILENCE + 2005-02-15 Toni García <zo...@ir...> 1.0.alpha17 - * Fix de un bug IPv6 - * Fix de un bug MOTD - * Fix de un bug GLINE + * Fix de un bug de IPv6 + * Fix de un bug de MOTD + * Fix de un bug de GLINE 2005-01-26 Toni García <zo...@ir...> 1.0.alpha16 * Sincronizacion Undernet Index: ircd-ircdev/configure diff -u ircd-ircdev/configure:1.11 ircd-ircdev/configure:1.12 --- ircd-ircdev/configure:1.11 Wed Jan 26 09:19:38 2005 +++ ircd-ircdev/configure Mon Feb 21 02:19:43 2005 @@ -8859,9 +8859,8 @@ elif echo "" | $YACC -V -v --version > /dev/null 2>&1 ; then : else - { { echo "$as_me:$LINENO: error: Cannot use $YACC as yacc." >&5 -echo "$as_me: error: Cannot use $YACC as yacc." >&2;} - { (exit 1); exit 1; }; } + { echo "$as_me:$LINENO: WARNING: $YACC may not work as yacc." >&5 +echo "$as_me: WARNING: $YACC may not work as yacc." >&2;} fi Index: ircd-ircdev/include/patchlevel.h diff -u ircd-ircdev/include/patchlevel.h:1.19 ircd-ircdev/include/patchlevel.h:1.20 --- ircd-ircdev/include/patchlevel.h:1.19 Tue Feb 15 08:31:50 2005 +++ ircd-ircdev/include/patchlevel.h Mon Feb 21 02:19:48 2005 @@ -17,10 +17,10 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: patchlevel.h,v 1.19 2005/02/15 16:31:50 zolty Exp $ + * $Id: patchlevel.h,v 1.20 2005/02/21 10:19:48 zolty Exp $ * */ -#define PATCHLEVEL ".alpha17" +#define PATCHLEVEL ".alpha18" #define RELEASE "1.0" Index: ircd-ircdev/ircd/IPcheck.c diff -u ircd-ircdev/ircd/IPcheck.c:1.8 ircd-ircdev/ircd/IPcheck.c:1.9 --- ircd-ircdev/ircd/IPcheck.c:1.8 Mon Jan 10 04:22:58 2005 +++ ircd-ircdev/ircd/IPcheck.c Mon Feb 21 02:19:50 2005 @@ -21,7 +21,7 @@ */ /** @file * @brief Code to count users connected from particular IP addresses. - * @version $Id: IPcheck.c,v 1.8 2005/01/10 12:22:58 zolty Exp $ + * @version $Id: IPcheck.c,v 1.9 2005/02/21 10:19:50 zolty Exp $ */ #include "config.h" @@ -124,8 +124,8 @@ ip_registry_canonicalize(&canon, ip); entry = hashTable[ip_registry_hash(&canon)]; for ( ; entry; entry = entry->next) { - int bits = (ip->in6_16[0] == ntohs(0x2002)) ? 48 : 64; - if (ipmask_check(ip, &entry->addr, bits)) + int bits = (canon.in6_16[0] == htons(0x2002)) ? 48 : 64; + if (ipmask_check(&canon, &entry->addr, bits)) break; } return entry; Index: ircd-ircdev/ircd/channel.c diff -u ircd-ircdev/ircd/channel.c:1.12 ircd-ircdev/ircd/channel.c:1.13 --- ircd-ircdev/ircd/channel.c:1.12 Wed Jan 26 09:19:46 2005 +++ ircd-ircdev/ircd/channel.c Mon Feb 21 02:19:50 2005 @@ -21,7 +21,7 @@ */ /** @file * @brief Channel management and maintanance - * @version $Id: channel.c,v 1.12 2005/01/26 17:19:46 zolty Exp $ + * @version $Id: channel.c,v 1.13 2005/02/21 10:19:50 zolty Exp $ */ #include "config.h" @@ -2863,12 +2863,14 @@ remove_count++; } } + if (remove_count) + return 0; + /* If no matches were found, fail. */ if (do_free) free_ban(newban); else MyFree(newban->banstr); - /* If no matches were found, fail. */ - return remove_count ? 0 : 3; + return 3; } if (do_free) free_ban(newban); Index: ircd-ircdev/ircd/engine_epoll.c diff -u ircd-ircdev/ircd/engine_epoll.c:1.7 ircd-ircdev/ircd/engine_epoll.c:1.8 --- ircd-ircdev/ircd/engine_epoll.c:1.7 Mon Jan 10 04:22:58 2005 +++ ircd-ircdev/ircd/engine_epoll.c Mon Feb 21 02:19:51 2005 @@ -21,7 +21,7 @@ */ /** @file * @brief Linux epoll_*() event engine. - * @version $Id: engine_epoll.c,v 1.7 2005/01/10 12:22:58 zolty Exp $ + * @version $Id: engine_epoll.c,v 1.8 2005/02/21 10:19:51 zolty Exp $ */ #include "config.h" @@ -229,7 +229,7 @@ { struct epoll_event *events; struct Socket *sock; - size_t codesize; + socklen_t codesize; int events_count, i, wait, nevs, errcode; if ((events_count = feature_int(FEAT_POLLS_PER_LOOP)) < 20) Index: ircd-ircdev/ircd/ircd_parser.y diff -u ircd-ircdev/ircd/ircd_parser.y:1.11 ircd-ircdev/ircd/ircd_parser.y:1.12 --- ircd-ircdev/ircd/ircd_parser.y:1.11 Wed Jan 26 09:19:47 2005 +++ ircd-ircdev/ircd/ircd_parser.y Mon Feb 21 02:20:02 2005 @@ -18,7 +18,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: ircd_parser.y,v 1.11 2005/01/26 17:19:47 zolty Exp $ + * $Id: ircd_parser.y,v 1.12 2005/02/21 10:20:02 zolty Exp $ * */ %{ @@ -512,7 +512,7 @@ } else { - log_write(LS_CONFIG, L_ERROR, 0, "operator blocks need a name, password, and host."); + parse_error("operator blocks need a name, password, and host."); MyFree(name); MyFree(pass); MyFree(host); @@ -652,32 +652,56 @@ } '{' clientitems '}' ';' { - struct ConfItem *aconf = make_conf(CONF_CLIENT); + struct irc_in_addr addr; unsigned char addrbits; - aconf->username = username; - aconf->host = host; - if (ip && ipmask_parse(ip, &aconf->address.addr, &addrbits)) + + if (ip && !ipmask_parse(ip, &addr, &addrbits)) { + parse_error("Invalid IP address in block"); + MyFree(username); + MyFree(host); + MyFree(ip); + } else { + struct ConfItem *aconf = make_conf(CONF_CLIENT); + aconf->username = username; + aconf->host = host; + memcpy(&aconf->address.addr, &addr, sizeof(aconf->address.addr)); aconf->addrbits = addrbits; - else - aconf->addrbits = -1; - aconf->conn_class = c_class ? c_class : find_class("default"); - aconf->maximum = maxlinks; + aconf->name = ip; + aconf->conn_class = c_class ? c_class : find_class("default"); + aconf->maximum = maxlinks; + } host = NULL; username = NULL; c_class = NULL; - MyFree(ip); + ip = NULL; }; clientitems: clientitem clientitems | clientitem; clientitem: clienthost | clientip | clientusername | clientclass | clientpass | clientmaxlinks | error; clienthost: HOST '=' QSTRING ';' { + char *sep = strchr($3, '@'); MyFree(host); - DupString(host, $3); + if (sep) { + *sep++ = '\0'; + MyFree(username); + DupString(username, $3); + DupString(host, sep); + } else { + DupString(host, $3); + } }; clientip: IP '=' QSTRING ';' { + char *sep = strchr($3, '@'); MyFree(ip); - DupString(ip, $3); + if (sep) { + *sep++ = '\0'; + MyFree(username); + DupString(username, $3); + DupString(ip, sep); + } else { + DupString(ip, $3); + } }; clientusername: USERNAME '=' QSTRING ';' { @@ -753,7 +777,7 @@ killreason: REASON '=' QSTRING ';' { - dconf->flags &= DENY_FLAGS_FILE; + dconf->flags &= ~DENY_FLAGS_FILE; MyFree(dconf->message); DupString(dconf->message, $3); }; @@ -868,8 +892,7 @@ { if (qconf->chname == NULL || qconf->reason == NULL) { - log_write(LS_CONFIG, L_ERROR, 0, "quarantine blocks need a channel name " - "and a reason."); + parse_error("quarantine blocks need a channel name and a reason."); return 0; } qconf->next = GlobalQuarantineList; @@ -894,7 +917,7 @@ { if (!smap->name || !smap->services) { - log_write(LS_CONFIG, L_ERROR, 0, "pseudo commands need a service name and list of target nicks."); + parse_error("pseudo commands need a service name and list of target nicks."); return 0; } if (register_mapping(smap)) @@ -949,7 +972,7 @@ } iauthitems '}' ';' { if (!host || !port) { - log_write(LS_CONFIG, L_ERROR, 0, "IAuth block needs a server name and port."); + parse_error("IAuth block needs a server name and port."); return 0; } iauth_connect(host, port, pass, tconn, tping); Index: ircd-ircdev/ircd/m_silence.c diff -u ircd-ircdev/ircd/m_silence.c:1.5 ircd-ircdev/ircd/m_silence.c:1.6 --- ircd-ircdev/ircd/m_silence.c:1.5 Mon Jan 10 04:23:03 2005 +++ ircd-ircdev/ircd/m_silence.c Mon Feb 21 02:20:04 2005 @@ -21,7 +21,7 @@ */ /** @file * @brief Handlers for SILENCE command. - * @version $Id: m_silence.c,v 1.5 2005/01/10 12:23:03 zolty Exp $ + * @version $Id: m_silence.c,v 1.6 2005/02/21 10:20:04 zolty Exp $ */ #include "config.h" @@ -116,11 +116,13 @@ maxlength = maxsiles * feature_int(FEAT_AVBANLEN); siles = totlength = 0; /* Count number of current silences and their total length. */ + plast = &cli_user(sptr)->silence; for (sile = cli_user(sptr)->silence; sile; sile = sile->next) { if (sile->flags & (BAN_OVERLAPPED | BAN_ADD | BAN_DEL)) continue; siles++; totlength += strlen(sile->banstr); + plast = &sile->next; } for (ii = jj = 0; ii < ac_count; ++ii) { sile = accepted[ii]; @@ -130,12 +132,16 @@ if (!(sile->flags & (BAN_OVERLAPPED | BAN_DEL))) { slen = strlen(sile->banstr); if ((siles >= maxsiles) || (totlength + slen >= maxlength)) { + *plast = NULL; + if (MyUser(sptr)) + send_reply(sptr, ERR_SILELISTFULL, accepted[ii]->banstr); free_ban(accepted[ii]); continue; } /* Update counts. */ siles++; totlength += slen; + plast = &sile->next; } /* Store the update. */ accepted[jj++] = sile; Index: ircd-ircdev/ircd/s_bsd.c diff -u ircd-ircdev/ircd/s_bsd.c:1.9 ircd-ircdev/ircd/s_bsd.c:1.10 --- ircd-ircdev/ircd/s_bsd.c:1.9 Mon Jan 10 04:23:03 2005 +++ ircd-ircdev/ircd/s_bsd.c Mon Feb 21 02:20:05 2005 @@ -21,7 +21,7 @@ */ /** @file * @brief Functions that now (or in the past) relied on BSD APIs. - * @version $Id: s_bsd.c,v 1.9 2005/01/10 12:23:03 zolty Exp $ + * @version $Id: s_bsd.c,v 1.10 2005/02/21 10:20:05 zolty Exp $ */ #include "config.h" @@ -261,6 +261,12 @@ cli_fd(cptr) = -1; return 0; } + /* + * Set the TOS bits - this is nonfatal if it doesn't stick. + */ + if (!os_set_tos(cli_fd(cptr), FEAT_TOS_SERVER)) { + report_error(TOS_ERROR_MSG, cli_name(cptr), errno); + } if ((result = os_connect_nonb(cli_fd(cptr), &aconf->address)) == IO_FAILURE) { cli_error(cptr) = errno; report_error(CONNECT_ERROR_MSG, cli_name(cptr), errno); Index: ircd-ircdev/ircd/s_err.c diff -u ircd-ircdev/ircd/s_err.c:1.11 ircd-ircdev/ircd/s_err.c:1.12 --- ircd-ircdev/ircd/s_err.c:1.11 Mon Jan 10 04:23:03 2005 +++ ircd-ircdev/ircd/s_err.c Mon Feb 21 02:20:06 2005 @@ -21,7 +21,7 @@ */ /** @file * @brief Error handling support. - * @version $Id: s_err.c,v 1.11 2005/01/10 12:23:03 zolty Exp $ + * @version $Id: s_err.c,v 1.12 2005/02/21 10:20:06 zolty Exp $ */ #include "config.h" @@ -465,11 +465,11 @@ /* 212 */ { RPL_STATSCOMMANDS, "%s %u %u", "212" }, /* 213 */ - { RPL_STATSCLINE, "C %s %s %d %d %s %s", "213" }, + { RPL_STATSCLINE, "C %s %s%s %d %d %s %s", "213" }, /* 214 */ { 0 }, /* 215 */ - { RPL_STATSILINE, "I %s %d %s %d %s", "215" }, + { RPL_STATSILINE, "I %s %d %s%s %d %s", "215" }, /* 216 */ { RPL_STATSKLINE, "%c %s \"%s\" %s 0 0", "216" }, /* 217 */ @@ -525,7 +525,7 @@ /* 242 */ { RPL_STATSUPTIME, ":Server Up %d days, %d:%02d:%02d", "242" }, /* 243 */ - { RPL_STATSOLINE, "O %s * %s %d %d", "243" }, + { RPL_STATSOLINE, "O %s@%s * %s %d %d", "243" }, /* 244 */ { 0 }, /* 245 */ Index: ircd-ircdev/ircd/s_stats.c diff -u ircd-ircdev/ircd/s_stats.c:1.6 ircd-ircdev/ircd/s_stats.c:1.7 --- ircd-ircdev/ircd/s_stats.c:1.6 Mon Jan 10 04:23:03 2005 +++ ircd-ircdev/ircd/s_stats.c Mon Feb 21 02:20:07 2005 @@ -22,7 +22,7 @@ /** @file * @brief Report configuration lines and other statistics from this * server. - * @version $Id: s_stats.c,v 1.6 2005/01/10 12:23:03 zolty Exp $ + * @version $Id: s_stats.c,v 1.7 2005/02/21 10:20:07 zolty Exp $ * * Note: The info is reported in the order the server uses * it--not reversed as in ircd.conf! @@ -87,7 +87,7 @@ struct ConfItem *tmp; unsigned short int port; int maximum; - char *host, *pass, *name, *hub_limit; + char *host, *pass, *name, *username, *hub_limit; for (tmp = GlobalConfList; tmp; tmp = tmp->next) { @@ -96,17 +96,22 @@ host = BadPtr(tmp->host) ? null : tmp->host; pass = BadPtr(tmp->passwd) ? null : tmp->passwd; name = BadPtr(tmp->name) ? null : tmp->name; + username = BadPtr(tmp->username) ? null : tmp->username; hub_limit = BadPtr(tmp->hub_limit) ? null : tmp->hub_limit; maximum = tmp->maximum; port = tmp->address.port; + if (tmp->status & CONF_UWORLD) - send_reply(sptr, RPL_STATSULINE, name); + send_reply(sptr, RPL_STATSULINE, host); else if (tmp->status & CONF_SERVER) - send_reply(sptr, RPL_STATSCLINE, name, host, port, maximum, hub_limit, get_conf_class(tmp)); + send_reply(sptr, RPL_STATSCLINE, name, (host[0] == ':' ? "0" : ""), host, port, maximum, hub_limit, get_conf_class(tmp)); else if (tmp->status & CONF_CLIENT) - send_reply(sptr, RPL_STATSILINE, host, maximum, name, port, get_conf_class(tmp)); + send_reply(sptr, RPL_STATSILINE, + (tmp->host ? tmp->host : "*"), maximum, + (name[0] == ':' ? "0" : ""), (tmp->name ? tmp->name : "*"), + port, get_conf_class(tmp)); else if (tmp->status & CONF_OPERATOR) - send_reply(sptr, RPL_STATSOLINE, host, name, port, get_conf_class(tmp)); + send_reply(sptr, RPL_STATSOLINE, username, host, name, port, get_conf_class(tmp)); } } } Index: ircd-ircdev/ircd/test/ircd_chattr_t.c diff -u ircd-ircdev/ircd/test/ircd_chattr_t.c:1.2 ircd-ircdev/ircd/test/ircd_chattr_t.c:1.3 --- ircd-ircdev/ircd/test/ircd_chattr_t.c:1.2 Tue Dec 28 03:15:47 2004 +++ ircd-ircdev/ircd/test/ircd_chattr_t.c Mon Feb 21 02:20:08 2005 @@ -77,6 +77,12 @@ return (0 != IsIPChar(c)); } +int eval_ip6_char(char c) +{ + return (0 != IsIP6Char(c)); +} + + int eval_eol(char c) { return (0 != IsEol(c)); @@ -105,6 +111,7 @@ { "IsUserChar: ", eval_user_char }, { "IsHostChar: ", eval_host_char }, { "IsIPChar: ", eval_ip_char }, + { "IsIP6Char: ", eval_ip6_char }, { "IsEol: ", eval_eol }, { "IsKTimeChar: ", eval_ktime_char } }; Index: ircd-ircdev/tools/convert-conf.py diff -u /dev/null ircd-ircdev/tools/convert-conf.py:1.1 --- /dev/null Mon Feb 21 02:22:02 2005 +++ ircd-ircdev/tools/convert-conf.py Mon Feb 21 02:20:16 2005 @@ -0,0 +1,263 @@ +#!/usr/bin/env python +# +# IRC-Dev IRCD - An advanced and innovative IRC Daemon, tools/ringlog.pl +# +# Copyright (C) 2002-2004 IRC-Dev Development Team <de...@ir...> +# Copyright (C) 2002 Alex Badea <va...@p1...> +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# $Id: convert-conf.py,v 1.1 2005/02/21 10:20:16 zolty Exp $ +# + +# Configuration file converter from 2.10.11 to 2.10.12 format +# Usage: +# convert-conf.py < old.conf > new.conf +# + +import sys +from string import * +import re + +if len(sys.argv) > 1: + f = open(sys.argv[1], "r") +else: + f = sys.stdin + +connects = {} +jupes = [] +feats = [ ("OPLEVELS","FALSE")] + +def qstr(s): + return replace(s,'"','\\"') + +def istr(s): + return str(int(strip(s))) + + +def do_uline(parts): + print "Uworld {" + print "\tname = \"%s\";" % qstr(parts[1]) + print "};" + print + if len(parts[2]): + for i in split(parts[2],","): + jupes.append(i) + +def do_hline(parts): + if not connects.has_key(lower(parts[3])): + connects[lower(parts[3])]={ + "name" : lower(parts[3]) + } + connects[lower(parts[3])]["hub"] = parts[1] + +def do_lline(parts): + if not connects.has_key(lower(parts[3])): + connects[lower(parts[3])]={ + "name" : lower(parts[3]) + } + del connects[lower(parts[3])]["hub"] + +def do_pline(parts): + print "Port {" + print "\tport = %s;" % istr(parts[4]) + if len(parts[1]): + print "\tmask = \"%s\";" % qstr(parts[1]) + if len(parts[2]): + print "\tvhost = \"%s\";" % qstr(parts[2]) + if count(parts[3], 'S'): + print "\tserver = yes;" + if count(parts[3], 'H'): + print "\thidden = yes;" + print "};" + print + +def do_fline(parts): + feats.append((parts[1], parts[2])) + +def do_kline(parts): + if len(parts)!=4: + sys.stderr.write("WARNING: Wrong number of parameters on line %i\n" % lno) + return + letter,host,reason,user=parts + print "Kill {" + if host[:2]=="$R": + if host=="$R": + sys.stderr.write("WARNING: Empty realname kline on line %i\n" % lno) + print "\trealname = \"%s\";" % qstr(host[2:]) + else: + print "\thost = \"%s@%s\";" % (qstr(user),qstr(host)) + if reason[:1]=="!": + print "\tfile = \"%s\";" % qstr(reason[1:]) + else: + print "\treason = \"%s\";" % qstr(reason) + print "};" + print + +def do_iline(parts): + if len(parts)!=6: + sys.stderr.write("WARNING: I:line doesn't have enough fields on line %i\n" % lno) + return + iline,ip,password,host,dummy,clss = parts + for i in [0,1]: + mask = [ip,host][i] + # Ignore things that aren't masks + if "." not in mask and "*" not in mask and "@" not in mask: + continue + if "@" in mask: + user,host = split(mask,"@") + else: + user,host = "*",mask + if i==0 and not re.match("^[0-9\.\*]+$",host): + sys.stderr.write("WARNING: Bad IP mask in line %s (%s)\n" % (lno,repr(mask))) + continue + print "Client {" + if re.match("^[1-9][1-9]?$",password): + print "\tmaxlinks = %s;" % int(password) + elif password: + print "\tpassword = \"%s\";" % qstr(password) + print "\tclass = \"%s\";" % clss + if i == 0: + print "\tip = \"%s\";" % qstr(host) + else: + print "\thost = \"%s\";" % qstr(host) + if user!="*": + print "\tusername = \"%s\";" % qstr(user) + print "};" + print + +def do_cline(parts): + name=lower(parts[3]) + if not connects.has_key(name): + connects[name]={} + connects[name]["host"]=parts[1] + connects[name]["password"]=parts[2] + connects[name]["name"]=parts[3] + connects[name]["port"]=parts[4] + connects[name]["class"]=parts[5] + +cvtmap = { + 'M': ('General', ('name', 'vhost', 'description', '', '!numeric'), ''), + 'A': ('Admin', ('location', 'contact', 'contact'), ''), + 'Y': ('Class', ('name', '!pingfreq', '!connectfreq', '!maxlinks', '!sendq'), ''), + 'I': do_iline, + 'T': ('motd', ('host', 'file'), ''), + 'U': do_uline, + 'H': do_hline, + 'L': do_lline, + 'K': do_kline, + 'k': do_kline, + 'C': do_cline, + 'D': ('CRULE', ('server', '', 'rule'), '\tall = yes;'), + 'd': ('CRULE', ('server', '', 'rule'), ''), + 'O': ('Operator', ('host', 'password', 'name', '', 'class'), '\tlocal = no;'), + 'o': ('Operator', ('host', 'password', 'name', '', 'class'), '\tlocal = yes;'), + 'P': do_pline, + 'F': do_fline +} + +lno=0 +for line in f.readlines(): + lno=lno+1 + line = strip(line) + if line=="": + continue + if line[0]=="#": + print "#"+line + continue + print "#",line + parts = split(line, ":") + parts=[''] + # This statemachine is pretty much directly stolen from ircu + # to give an "authentic" parser :) + state=0 # normal + quoted=0 + for i in line: + if state==0: + if i=="\\": + state=1 # escaped + elif i=='"': + quoted=not quoted + elif i==':': + if quoted: + parts[-1]=parts[-1]+i + else: + parts.append("") + elif i=='#': + break + else: + parts[-1]=parts[-1]+i + elif state==1: + if i in "bfnrtv": + parts[-1]=parts[-1]+"\b\f\n\r\t\v"[index("bfnrtv",i)] + else: + parts[-1]=parts[-1]+i + state=0 + if quoted: + sys.stderr.write("WARNING: No closing quote on line %i\n"%lno) + if not len(parts): + continue + if not cvtmap.has_key(parts[0]): + print "#Unknown:",line + continue + if callable(cvtmap[parts[0]]): + cvtmap[parts[0]](parts) + continue + (block, items, extra) = cvtmap[parts[0]] + + print block, "{" + idx = 1 + for item in items: + if idx >= len(parts): + break + if len(parts[idx]) and len(item): + if item[0] == '!': + print "\t%s = %s;" % (item[1:], istr(parts[idx])) + else: + print "\t%s = \"%s\";" % (item, qstr(parts[idx])) + idx = idx + 1 + if len(extra): + print extra + print "};" + print + +if len(jupes): + print "Jupe {" + for nick in jupes: + print "\tnick = \"%s\";" % qstr(nick) + print "};" + print + +if len(connects.keys()): + for i in connects.keys(): + print "Connect {" + print "\tname = \"%s\";" % qstr(connects[i]["name"]) + print "\thost = \"%s\";" % qstr(connects[i]["host"]) + print "\tpassword = \"%s\";" % qstr(connects[i]["password"]) + print "\tport = %s;" % connects[i]["port"] + print "\tclass = \"%s\";" % qstr(connects[i]["class"]) + if connects[i].has_key("hub"): + print "\thub = \"%s\";" % qstr(connects[i]["hub"]) + else: + print "\tleaf = \"yes\";" + print "};" + print + +if len(feats): + print "features {" + for (name, value) in feats: + print "\t\"%s\" = \"%s\";" % (qstr(name), qstr(value)) + print "};" + print ----------------------- End of diff ----------------------- |