[svn] commit: r1889 - in /branches/trac185/src/bin/xfrin: tests/xfrin_test.py xfrin.py.in
BIND 10 source code commits
bind10-changes at lists.isc.org
Fri May 21 04:25:04 UTC 2010
Author: jinmei
Date: Fri May 21 04:25:04 2010
New Revision: 1889
Log:
avoid hardcoding the IN class at the time of query generation.
we still hardcode it as the fixed default value for retransfer/refresh command.
we should fix this so that this is specifiable.
Modified:
branches/trac185/src/bin/xfrin/tests/xfrin_test.py
branches/trac185/src/bin/xfrin/xfrin.py.in
Modified: branches/trac185/src/bin/xfrin/tests/xfrin_test.py
==============================================================================
--- branches/trac185/src/bin/xfrin/tests/xfrin_test.py (original)
+++ branches/trac185/src/bin/xfrin/tests/xfrin_test.py Fri May 21 04:25:04 2010
@@ -70,8 +70,10 @@
MockXfrin.check_command_hook()
class MockXfrinConnection(XfrinConnection):
- def __init__(self, TEST_ZONE_NAME, db_file, shutdown_event, master_addr):
- super().__init__(TEST_ZONE_NAME, db_file, shutdown_event, master_addr)
+ def __init__(self, zone_name, rrclass, db_file, shutdown_event,
+ master_addr):
+ super().__init__(zone_name, rrclass, db_file, shutdown_event,
+ master_addr)
self.query_data = b''
self.reply_data = b''
self.force_time_out = False
@@ -146,8 +148,8 @@
def setUp(self):
if os.path.exists(TEST_DB_FILE):
os.remove(TEST_DB_FILE)
- self.conn = MockXfrinConnection('example.com.', TEST_DB_FILE,
- threading.Event(),
+ self.conn = MockXfrinConnection('example.com.', TEST_RRCLASS,
+ TEST_DB_FILE, threading.Event(),
TEST_MASTER_IPV4_ADDRINFO)
self.axfr_after_soa = False
self.soa_response_params = {
@@ -169,10 +171,18 @@
# to confirm an AF_INET6 socket has been created. A naive application
# tends to assume it's IPv4 only and hardcode AF_INET. This test
# uncovers such a bug.
- c = MockXfrinConnection('example.com.', TEST_DB_FILE,
+ c = MockXfrinConnection('example.com.', TEST_RRCLASS, TEST_DB_FILE,
threading.Event(),
TEST_MASTER_IPV6_ADDRINFO)
c.bind(('::', 0))
+ c.close()
+
+ def test_init_chclass(self):
+ c = XfrinConnection('example.com.', rr_class.CH(), TEST_DB_FILE,
+ threading.Event(), TEST_MASTER_IPV4_ADDRINFO)
+ axfrmsg = c._create_query(rr_type.AXFR())
+ self.assertEqual(question_iter(axfrmsg).get_question().get_class(),
+ rr_class.CH())
c.close()
def test_response_with_invalid_msg(self):
Modified: branches/trac185/src/bin/xfrin/xfrin.py.in
==============================================================================
--- branches/trac185/src/bin/xfrin/xfrin.py.in (original)
+++ branches/trac185/src/bin/xfrin/xfrin.py.in Fri May 21 04:25:04 2010
@@ -66,7 +66,7 @@
'''Do xfrin in this class. '''
def __init__(self,
- zone_name, db_file, shutdown_event, master_addrinfo,
+ zone_name, rrclass, db_file, shutdown_event, master_addrinfo,
verbose = False, idle_timeout = 60):
''' idle_timeout: max idle time for read data from socket.
db_file: specify the data source file.
@@ -76,6 +76,7 @@
asyncore.dispatcher.__init__(self)
self.create_socket(master_addrinfo[0], master_addrinfo[1])
self._zone_name = zone_name
+ self._rrclass = rrclass
self._db_file = db_file
self._soa_rr_count = 0
self._idle_timeout = idle_timeout
@@ -104,7 +105,8 @@
msg.set_qid(query_id)
msg.set_opcode(op_code.QUERY())
msg.set_rcode(rcode.NOERROR())
- query_question = question(name(self._zone_name), rr_class.IN(), query_type)
+ query_question = question(name(self._zone_name), self._rrclass,
+ query_type)
msg.add_question(query_question)
return msg
@@ -322,10 +324,10 @@
sys.stdout.write('\n')
-def process_xfrin(xfrin_recorder, zone_name, db_file,
+def process_xfrin(xfrin_recorder, zone_name, rrclass, db_file,
shutdown_event, master_addrinfo, check_soa, verbose):
xfrin_recorder.increment(zone_name)
- conn = XfrinConnection(zone_name, db_file, shutdown_event,
+ conn = XfrinConnection(zone_name, rrclass, db_file, shutdown_event,
master_addrinfo, verbose)
if conn.connect_to_master():
conn.do_xfrin(check_soa)
@@ -409,8 +411,12 @@
if command == 'shutdown':
self._shutdown_event.set()
elif command == 'retransfer' or command == 'refresh':
+ # The default RR class is IN. We should fix this so that
+ # the class is passed in the command arg (where we specify
+ # the default)
+ rrclass = rr_class.IN()
zone_name, master_addr, db_file = self._parse_cmd_params(args)
- ret = self.xfrin_start(zone_name, db_file, master_addr,
+ ret = self.xfrin_start(zone_name, rrclass, db_file, master_addr,
False if command == 'retransfer' else True)
answer = create_answer(ret[0], ret[1])
else:
@@ -446,7 +452,7 @@
while not self._shutdown_event.is_set():
self._cc_check_command()
- def xfrin_start(self, zone_name, db_file, master_addrinfo,
+ def xfrin_start(self, zone_name, rrclass, db_file, master_addrinfo,
check_soa = True):
if "bind10_dns" not in sys.modules:
return (1, "xfrin failed, can't load dns message python library: 'bind10_dns'")
@@ -460,7 +466,7 @@
xfrin_thread = threading.Thread(target = process_xfrin,
args = (self.recorder,
- zone_name,
+ zone_name, rrclass,
db_file,
self._shutdown_event,
master_addrinfo, check_soa,
More information about the bind10-changes
mailing list