]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
2379. [contrib] queryperf/gen-data-queryperf.py: removed redundant
authorTatuya JINMEI 神明達哉 <jinmei@isc.org>
Fri, 13 Jun 2008 18:18:04 +0000 (18:18 +0000)
committerTatuya JINMEI 神明達哉 <jinmei@isc.org>
Fri, 13 Jun 2008 18:18:04 +0000 (18:18 +0000)
TLDs and supported RRs with TTLs [RT #17972]

CHANGES
contrib/queryperf/utils/gen-data-queryperf.py

diff --git a/CHANGES b/CHANGES
index cd4b7fd04474ec69dd4b2c0cd2342f8b06b3b81c..ebe490a9c0c52b622c5cb2daa07d2438e65a5ef7 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+2379.  [contrib]       queryperf/gen-data-queryperf.py: removed redundant
+                       TLDs and supported RRs with TTLs [RT #17972]
+
 2378.  [bug]           gssapi_functions{} had a redundant member in BIND 9.5.
                        [RT #18169]
 
index b164025a06aeb9a9ff940857cf676171a5d4a8c8..28eaa3f7c12e17e6a06557b0996c689921fbaadf 100644 (file)
@@ -1,7 +1,7 @@
 #!/usr/bin/python
 
 #
-# $Id: gen-data-queryperf.py,v 1.1 2003/04/10 02:33:40 marka Exp $
+# $Id: gen-data-queryperf.py,v 1.1.1236.1 2008/06/13 18:18:04 jinmei Exp $
 #
 # Contributed by Stephane Bortzmeyer <bortzmeyer@nic.fr>
 #
@@ -32,9 +32,15 @@ percent_random = 0.3
 gen = None
 zone_file = None
 domains = {}
-domain_ns = "^([a-z0-9-]+)(\.([a-z0-9-\.]+|)|)( +IN|) +NS"
+domain_ns = r'^([a-z0-9-\.]+)((\s+\d+)?(\s+IN)?|(\s+IN)(\s+\d+)?)\s+NS'
 domain_ns_re = re.compile(domain_ns, re.IGNORECASE)
 
+def remove_tld(label, tld):
+    if label.endswith('.' + tld + '.'):
+        return label[0:-(1+ len(tld) + 1)]
+    else:
+        return label
+
 def gen_random_label():
     label = ""
     for i in range(gen.randint(1, maxsize)):
@@ -52,7 +58,7 @@ def usage():
 try:
     optlist, args = getopt.getopt(sys.argv[1:], "hp:f:n:t:m:",
                                   ["help", "percentrandom=", "zonefile=",
-                                   "num=", "tld=",
+                                   "number=", "tld=",
                                    "maxsize="])
     for option, value in optlist:
         if option == "--help" or option == "-h":
@@ -86,15 +92,22 @@ if zone_file:
     while line:
         domain_line = domain_ns_re.match(line)
         if domain_line:
-            domain = domain_line.group(1)
+            print domain_line.group(1)
+            domain = remove_tld(domain_line.group(1), tld)
             domains[domain] = 1
         line = file.readline()
     file.close()
+if zone_file:
+    domains = domains.keys()
+    if len(domains) == 0:
+        sys.stderr.write("No domains found in '%s'\n" % zone_file)
+        sys.exit(1)
 for i in range(num):
     if zone_file:
         if gen.random() < percent_random:
-            print make_domain(gen_random_label())
+            sys.stdout.write(make_domain(gen_random_label()))
         else:
-            print make_domain(gen.choice(domains.keys()))
+            sys.stdout.write(make_domain(gen.choice(domains)))
     else:
-        print make_domain(gen_random_label())
+        sys.stdout.write(make_domain(gen_random_label()))
+    sys.stdout.write("\n")