# Usage:
# convert-conf.py < old.conf > new.conf
#
-# $Id: convert-conf.py,v 1.3 2005-03-19 23:04:07 entrope Exp $
+# $Id: convert-conf.py,v 1.5 2005-04-17 02:18:55 isomer Exp $
#
import sys
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,'"','\\"')
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))
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
+ iline,ip,password,hostname,dummy,clss = parts
for i in [0,1]:
- mask = [ip,host][i]
+ mask = [ip,hostname][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
+ 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 "\tip = \"%s\";" % qstr(host)
else:
print "\thost = \"%s\";" % qstr(host)
- if user!="*":
+ if user!="":
print "\tusername = \"%s\";" % qstr(user)
print "};"
print
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'), ''),
'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
}
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:
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"])
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