Author: Isomer <Isomer@undernet.org>
authorPerry Lorier <isomer@undernet.org>
Sun, 17 Apr 2005 02:18:55 +0000 (02:18 +0000)
committerPerry Lorier <isomer@undernet.org>
Sun, 17 Apr 2005 02:18:55 +0000 (02:18 +0000)
Log message:

Fix lots of conversion problems with:
 * oper privielges (now they are converted),
 * features (deprecated features commented out, most converted to priviliges),
 * realname klines (also add host= lines)
 * quarintines (generate blocks for them),
 * connect blocks (don't generate empty port config lines)

and perhaps some others too

git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@1364 c9e4aea6-c8fd-4c43-8297-357d70d61c8c

ChangeLog
tools/convert-conf.py

index c6c6600e91d42f9d4acd971d4b06a115f1b4fdc8..a67dd1d609a3f5e6939fbfd0d23a10c64d5b3d58 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2005-04-17  Perry Lorier <isomer@undernet.org>
+       
+       * tools/convert-conf.py: Fix lots of conversion problems with
+       oper privielges (now they are converted), 
+       features (deprecated features commented out, most converted to
+       priviliges), 
+       realname klines (also add host= lines)
+       quarintines (generate blocks for them), 
+       connect blocks (don't generate empty port config lines)
+       etc...
+
 2005-04-16  Michael Poole <mdpoole@troilus.org>
 
        * ircd/gline.c (do_gline): Fix typo when activating IP-based
index 5a466e3ec95e1cd540d7e5fa021d52ca78a2c3f7..c9f8831614754e70bd7b5cc57560c41b28c64098 100755 (executable)
@@ -22,7 +22,7 @@
 # Usage:
 #   convert-conf.py < old.conf > new.conf
 #
-# $Id: convert-conf.py,v 1.4 2005-04-09 03:54:24 isomer Exp $
+# $Id: convert-conf.py,v 1.5 2005-04-17 02:18:55 isomer Exp $
 #
 
 import sys
@@ -37,6 +37,44 @@ else:
 connects = {}
 jupes = []
 feats = [ ("OPLEVELS","FALSE")]
+opers = []
+quarintines = []
+
+useable_features = [
+       "LOG", "DOMAINNAME", "RELIABLE_CLOCK", "BUFFERPOOL", 
+       "HAS_FERGUNSON_FLUSHER", "CLIENT_FLOOD", "SERVER_PORT", "NODEFAULTMOTD",
+       "MOTD_BANNER", "KILL_IPMISMATCH", "IDLE_FROM_MSG", "HUB", 
+       "WALLOPS_OPER_ONLY", "NODNS", "RANDOM_SEED", "DEFAULT_LIST_PARAM",
+       "NICKNAMEHISTORYLENGTH", "NETWORK", "HOST_HIDING", "HIDDEN_HOST",
+       "HIDDEN_IP", "KILLCHASETIMELIMIT", "MAXCHANNELSPERUSER", "NICKLEN",
+       "AVBANLEN", "MAXBANS", "MAXSILES", "HANGONGOODLINK", "HANGONRETRYDELAY",
+       "CONNECTTIMEOUT", "MAXIMUM_LINKS", "PINGFREQUENCY", "CONNECTFREQUENCY",
+       "DEFAULTMAXSENDQLENGTH", "GLINEMAXUSERCOUNT", "MPATH", "RPATH", "PPATH",
+       "TOS_SERVER", "TOS_CLIENT", "POLLS_PER_LOOP", "IRCD_RES_TIMEOUT",
+       "IRCD_RES_RETRIES", "AUTH_TIMEOUT", "IPCHECK_CLONE_LIMIT", 
+       "IPCHECK_CLONE_PERIOD", "IPCHECK_CLONE_DELAY", "CONFIG_OPERCMDS", 
+       "OPLEVELS", "LOCAL_CHANNELS", "ANNOUNCE_INVITES", "HIS_SNOTICES",
+       "HIS_DEBUG_OPER_ONLY", "HIS_WALLOPS", "HIS_MAP", "HIS_LINKS", 
+       "HIS_TRACE", "HIS_STATS_a", "HIS_STATS_c", "HIS_STATS_d", "HIS_STATS_e",
+       "HIS_STATS_f", "HIS_STATS_g", "HIS_STATS_i", "HIS_STATS_j", 
+       "HIS_STATS_J", "HIS_STATS_k", "HIS_STATS_l", "HIS_STATS_L",
+       "HIS_STATS_m", "HIS_STATS_M", "HIS_STATS_o", "HIS_STATS_p",
+       "HIS_STATS_q", "HIS_STATS_r", "HIS_STATS_R", "HIS_STATS_t",
+       "HIS_STATS_T", "HIS_STATS_u", "HIS_STATS_U", "HIS_STATS_v",
+       "HIS_STATS_v", "HIS_STATS_w", "HIS_STATS_x", "HIS_STATS_z",
+       "HIS_WHOIS_SERVERNAME", "HIS_WHOIS_IDLETIME", "HIS_WHOIS_LOCALCHAN",
+       "HIS_WHO_SERVERNAME", "HIS_WHO_HOPCOUNT"," HIS_BANWHO", "HIS_KILLWHO",
+       "HIS_REWRITE", "HIS_REMOTE", "HIS_NETSPLIT", "HIS_SERVERNAME", 
+       "HIS_SERVERINFO", "HIS_URLSERVERS"
+       ]
+
+# [ "old feature" => ( local oper priv, global oper priv ) ]
+# None means don't add this
+feature_to_priv = {
+       "UNLIMIT_OPER_QUERY" : ("unlimit_query","unlimit_query"),
+       "OPER_WALK_THROUGH_LMODES" : (None, "walk_lchan"),
+       "NO_OPER_DEOP_LCHAN" : (None, "deop_lchan"),
+       }
 
 def qstr(s):
        return replace(s,'"','\\"')
@@ -94,6 +132,8 @@ def do_kline(parts):
        if host[:2]=="$R":
                if host=="$R":
                        sys.stderr.write("WARNING: Empty realname kline on line %i\n" % lno)
+               if user!="*":
+                       print '\thost = "%s@*";' % qstr(user)
                print "\trealname = \"%s\";" % qstr(host[2:])
        else:
                print "\thost = \"%s@%s\";" % (qstr(user),qstr(host))
@@ -117,7 +157,7 @@ def do_iline(parts):
                if "@" in mask:
                        user,host = split(mask,"@")
                else:
-                       user,host = "*",mask
+                       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
@@ -131,7 +171,7 @@ def do_iline(parts):
                        print "\tip = \"%s\";" % qstr(host)
                else:
                        print "\thost = \"%s\";" % qstr(host)
-               if user!="*":
+               if user!="":
                        print "\tusername = \"%s\";" % qstr(user)
                print "};"
                print
@@ -143,9 +183,18 @@ def do_cline(parts):
        connects[name]["host"]=parts[1]
        connects[name]["password"]=parts[2]
        connects[name]["name"]=parts[3]
-       connects[name]["port"]=parts[4]
+       if parts[4].strip()!="":
+               connects[name]["port"]=parts[4]
        connects[name]["class"]=parts[5]
 
+def do_qline(parts):
+       print "Quarintine {"
+       print '\t"%s" = "%s";' % (qstr(parts[1]),qstr(parts[2]))
+       print "}"
+
+def do_oline(parts):
+       opers.append(parts)
+
 cvtmap = {
        'M': ('General', ('name', 'vhost', 'description', '', '!numeric'), ''),
        'A': ('Admin', ('location', 'contact', 'contact'), ''),
@@ -160,8 +209,9 @@ cvtmap = {
        '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;'),
+       'O': do_oline,
+       'o': do_oline,
+       'Q': ('Quarintine', ('channel','reason', '', '', ''), ''),
        'P': do_pline,
        'F': do_fline
 }
@@ -231,6 +281,43 @@ for line in f.readlines():
        print "};"
        print
 
+if len(opers):
+       for i in opers:
+               print 'Operator {'
+               print '\tname = "%s";' % qstr(i[3])
+               print '\thost = "%s";' % qstr(i[1])
+               print '\tpassword = "%s";' % qstr(i[2])
+               print '\tclass = "%s";' % qstr(i[5])
+               if i[0]=='O':
+                       print '\tlocal = no;'
+               else:
+                       print '\tlocal = yes;'
+               for j in feats:
+                       if (j[0].startswith("LOCOP_") and i[0]=='o'):
+                               print "#",i
+                               if j[1].lower()=="true":
+                                       print '\t%s = yes;'% (j[0][6:].lower())
+                               else:
+                                       print '\t%s = no;' % (j[0][6:].lower())
+                       if (j[0].startswith("OPER_") and i[0]=='O'):
+                               if j[1].lower()=="true":
+                                       print '\t%s = yes;'% (j[0][5:].lower())
+                               else:
+                                       print '\t%s = no;' % (j[0][5:].lower())
+                       if feature_to_priv.has_key(j[0]):
+                               if i[0]=="o" and feature_to_priv[j[0]][0]:
+                                       if j[1].lower()=="true":
+                                               print '\t%s = yes;' % feature_to_priv[j[0]][0]
+                                       else:
+                                               print '\t%s = yes;' % feature_to_priv[j[0]][0]
+                               if i[0]=="O" and feature_to_priv[j[0]][1]:
+                                       if j[1].lower()=="true":
+                                               print '\t%s = yes;' % feature_to_priv[j[0]][1]
+                                       else:
+                                               print '\t%s = yes;' % feature_to_priv[j[0]][1]
+               print '};'
+               print
+
 if len(jupes):
        print "Jupe {"
        for nick in jupes:
@@ -244,7 +331,8 @@ if len(connects.keys()):
                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"]
+               if connects[i]["port"]:
+                       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"])
@@ -256,6 +344,18 @@ if len(connects.keys()):
 if len(feats):
        print "features {"
        for (name, value) in feats:
-               print "\t\"%s\" = \"%s\";" % (qstr(name), qstr(value))
+               if name in useable_features:
+                       print "\t\"%s\" = \"%s\";" % (qstr(name), qstr(value))
+               else:
+                       if feature_to_priv.has_key(name):
+                               print '# Option converted to privilege "%s"' % \
+                                       qstr(feature_to_priv[name][1])
+                       elif name.startswith("LOCOP_"):
+                               print "# Option converted to locop privilege"
+                       elif name.startswith("OPER_"):
+                               print "# Option converted to oper privilege"
+                       else:
+                               print "# Option no longer exists in 2.10.12"
+                       print "#\t\"%s\" = \"%s\";" % (qstr(name), qstr(value))
        print "};"
        print