Commit e5005185 authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

[master] Merge branch 'trac1866'

fixed Conflicts:
	src/bin/ddns/tests/ddns_test.py
	src/bin/xfrin/tests/xfrin_test.py
	src/lib/dns/python/tests/zone_checker_python_test.py
	src/lib/python/isc/ddns/tests/session_tests.py
parents 89fbc1a1 6b09c6be
......@@ -134,7 +134,7 @@ def get_datasrc_client(cc_session):
function will simply be removed.
'''
HARDCODED_DATASRC_CLASS = RRClass.IN()
HARDCODED_DATASRC_CLASS = RRClass.IN
file, is_default = cc_session.get_remote_config_value("Auth",
"database_file")
# See xfrout.py:get_db_file() for this trick:
......@@ -469,7 +469,7 @@ class DDNSServer:
self.__request_msg.clear(Message.PARSE)
# specify PRESERVE_ORDER as we need to handle each RR separately.
self.__request_msg.from_wire(req_data, Message.PRESERVE_ORDER)
if self.__request_msg.get_opcode() != Opcode.UPDATE():
if self.__request_msg.get_opcode() != Opcode.UPDATE:
raise self.InternalError('Update request has unexpected '
'opcode: ' +
str(self.__request_msg.get_opcode()))
......
......@@ -39,9 +39,9 @@ TESTDATA_PATH = os.environ['TESTDATA_PATH'] + os.sep
READ_ZONE_DB_FILE = TESTDATA_PATH + "rwtest.sqlite3" # original, to be copied
TEST_ZONE_NAME = Name('example.org')
TEST_ZONE_NAME_STR = TEST_ZONE_NAME.to_text()
UPDATE_RRTYPE = RRType.SOA()
UPDATE_RRTYPE = RRType.SOA
TEST_QID = 5353 # arbitrary chosen
TEST_RRCLASS = RRClass.IN()
TEST_RRCLASS = RRClass.IN
TEST_RRCLASS_STR = TEST_RRCLASS.to_text()
TEST_SERVER6 = ('2001:db8::53', 53, 0, 0)
TEST_CLIENT6 = ('2001:db8::1', 53000, 0, 0)
......@@ -169,9 +169,9 @@ class FakeUpdateSession:
self.__msg.make_response()
self.__msg.clear_section(SECTION_ZONE)
if self.__faked_result == UPDATE_SUCCESS:
self.__msg.set_rcode(Rcode.NOERROR())
self.__msg.set_rcode(Rcode.NOERROR)
else:
self.__msg.set_rcode(Rcode.REFUSED())
self.__msg.set_rcode(Rcode.REFUSED)
return self.__msg
class FakeKeyringModule:
......@@ -478,7 +478,7 @@ class TestDDNSServer(unittest.TestCase):
# By default (in our faked config) it should be derived from the
# test data source
rrclass, datasrc_client = self.ddns_server._datasrc_info
self.assertEqual(RRClass.IN(), rrclass)
self.assertEqual(RRClass.IN, rrclass)
self.assertEqual(DataSourceClient.SUCCESS,
datasrc_client.find_zone(Name('example.org'))[0])
......@@ -491,7 +491,7 @@ class TestDDNSServer(unittest.TestCase):
{'database_file': './notexistentdir/somedb.sqlite3'}
self.__cc_session.add_remote_config_by_name('Auth')
rrclass, datasrc_client = self.ddns_server._datasrc_info
self.assertEqual(RRClass.IN(), rrclass)
self.assertEqual(RRClass.IN, rrclass)
self.assertRaises(isc.datasrc.Error,
datasrc_client.find_zone, Name('example.org'))
......@@ -887,12 +887,12 @@ class TestDDNSServer(unittest.TestCase):
self.__select_answer = ([], [10], [])
self.assertRaises(KeyError, self.ddns_server.run)
def create_msg(opcode=Opcode.UPDATE(), zones=[TEST_ZONE_RECORD], prereq=[],
def create_msg(opcode=Opcode.UPDATE, zones=[TEST_ZONE_RECORD], prereq=[],
tsigctx=None):
msg = Message(Message.RENDER)
msg.set_qid(TEST_QID)
msg.set_opcode(opcode)
msg.set_rcode(Rcode.NOERROR())
msg.set_rcode(Rcode.NOERROR)
for z in zones:
msg.add_question(z)
for p in prereq:
......@@ -936,7 +936,7 @@ class TestDDNSSession(unittest.TestCase):
return FakeUpdateSession(req_message, client_addr, zone_config,
self.__faked_result)
def check_update_response(self, resp_wire, expected_rcode=Rcode.NOERROR(),
def check_update_response(self, resp_wire, expected_rcode=Rcode.NOERROR,
tsig_ctx=None, tcp=False):
'''Check if given wire data are valid form of update response.
......@@ -963,7 +963,7 @@ class TestDDNSSession(unittest.TestCase):
self.assertNotEqual(None, tsig_record)
self.assertEqual(TSIGError.NOERROR,
tsig_ctx.verify(tsig_record, resp_wire))
self.assertEqual(Opcode.UPDATE(), msg.get_opcode())
self.assertEqual(Opcode.UPDATE, msg.get_opcode())
self.assertEqual(expected_rcode, msg.get_rcode())
self.assertEqual(TEST_QID, msg.get_qid())
for section in [SECTION_ZONE, SECTION_PREREQUISITE, SECTION_UPDATE]:
......@@ -977,7 +977,7 @@ class TestDDNSSession(unittest.TestCase):
server_addr = TEST_SERVER6 if ipv6 else TEST_SERVER4
client_addr = TEST_CLIENT6 if ipv6 else TEST_CLIENT4
tsig = TSIGContext(tsig_key) if tsig_key is not None else None
rcode = Rcode.NOERROR() if result == UPDATE_SUCCESS else Rcode.REFUSED()
rcode = Rcode.NOERROR if result == UPDATE_SUCCESS else Rcode.REFUSED
has_response = (result != UPDATE_DROP)
self.assertEqual(has_response,
......@@ -1015,7 +1015,7 @@ class TestDDNSSession(unittest.TestCase):
# Opcode is not UPDATE
self.assertFalse(self.server.handle_request(
(self.__sock, None, None, create_msg(opcode=Opcode.QUERY()))))
(self.__sock, None, None, create_msg(opcode=Opcode.QUERY))))
self.assertEqual((None, None), (s._sent_data, s._sent_addr))
# TSIG verification error. We use UPDATE_DROP to signal check_session
......@@ -1031,7 +1031,7 @@ class TestDDNSSession(unittest.TestCase):
TEST_CLIENT6,
create_msg())))
# this check ensures sendto() was really attempted.
self.check_update_response(self.__sock._sent_data, Rcode.NOERROR())
self.check_update_response(self.__sock._sent_data, Rcode.NOERROR)
def test_tcp_request(self):
# A simple case using TCP: all resopnse data are sent out at once.
......@@ -1040,7 +1040,7 @@ class TestDDNSSession(unittest.TestCase):
self.assertTrue(self.server.handle_request((s, TEST_SERVER6,
TEST_CLIENT6,
create_msg())))
self.check_update_response(s._sent_data, Rcode.NOERROR(), tcp=True)
self.check_update_response(s._sent_data, Rcode.NOERROR, tcp=True)
# In the current implementation, the socket should be closed
# immedidately after a successful send.
self.assertEqual(1, s._close_called)
......@@ -1071,7 +1071,7 @@ class TestDDNSSession(unittest.TestCase):
s.make_send_ready()
self.assertEqual(DNSTCPContext.SEND_DONE,
self.server._tcp_ctxs[s.fileno()][0].send_ready())
self.check_update_response(s._sent_data, Rcode.NOERROR(), tcp=True)
self.check_update_response(s._sent_data, Rcode.NOERROR, tcp=True)
def test_tcp_request_error(self):
# initial send() on the TCP socket will fail. The request handling
......@@ -1127,9 +1127,9 @@ class TestDDNSSession(unittest.TestCase):
self.__faked_result = UPDATE_DROP
# Put the same RR twice in the prerequisite section. We should see
# them as separate RRs.
dummy_record = RRset(TEST_ZONE_NAME, TEST_RRCLASS, RRType.NS(),
dummy_record = RRset(TEST_ZONE_NAME, TEST_RRCLASS, RRType.NS,
RRTTL(0))
dummy_record.add_rdata(Rdata(RRType.NS(), TEST_RRCLASS, "ns.example."))
dummy_record.add_rdata(Rdata(RRType.NS, TEST_RRCLASS, "ns.example."))
self.server.handle_request((self.__sock, TEST_SERVER6, TEST_CLIENT6,
create_msg(prereq=[dummy_record,
dummy_record])))
......
......@@ -164,7 +164,7 @@ class LoadZoneRunner:
self._zone_class = RRClass(options.zone_class)
except isc.dns.InvalidRRClass as ex:
raise BadArgument('Invalid zone class: ' + str(ex))
if self._zone_class != RRClass.IN():
if self._zone_class != RRClass.IN:
raise BadArgument("RR class is not supported: " +
str(self._zone_class))
......
......@@ -79,7 +79,7 @@ class TestLoadZoneRunner(unittest.TestCase):
self.assertEqual(DATASRC_CONFIG, self.__runner._datasrc_config)
self.assertEqual('sqlite3', self.__runner._datasrc_type) # default
self.assertEqual(10000, self.__runner._report_interval) # default
self.assertEqual(RRClass.IN(), self.__runner._zone_class) # default
self.assertEqual(RRClass.IN, self.__runner._zone_class) # default
self.assertEqual('INFO', self.__runner._log_severity) # default
self.assertEqual(0, self.__runner._log_debuglevel)
......@@ -135,7 +135,7 @@ class TestLoadZoneRunner(unittest.TestCase):
'memory')
def __common_load_setup(self):
self.__runner._zone_class = RRClass.IN()
self.__runner._zone_class = RRClass.IN
self.__runner._zone_name = TEST_ZONE_NAME
self.__runner._zone_file = NEW_ZONE_TXT_FILE
self.__runner._datasrc_type = 'sqlite3'
......@@ -159,7 +159,7 @@ class TestLoadZoneRunner(unittest.TestCase):
self.assertEqual(client.NOTFOUND, result)
return
self.assertEqual(client.SUCCESS, result)
result, rrset, _ = finder.find(zone_name, RRType.SOA())
result, rrset, _ = finder.find(zone_name, RRType.SOA)
if soa_txt:
self.assertEqual(finder.SUCCESS, result)
self.assertEqual(soa_txt, rrset.to_text())
......
This diff is collapsed.
......@@ -78,7 +78,7 @@ DBG_XFRIN_TRACE = logger.DBGLVL_TRACE_BASIC
# (TODO: have similar support to get default values for command
# arguments as we do for config options)
DEFAULT_MASTER_PORT = 53
DEFAULT_ZONE_CLASS = RRClass.IN()
DEFAULT_ZONE_CLASS = RRClass.IN
__version__ = 'BIND10'
......@@ -135,7 +135,7 @@ def _check_zone_class(zone_class_str):
"""If the given argument is a string: checks if the given class is
a valid one, and returns an RRClass object if so.
Raises XfrinZoneInfoException if not.
If it is None, this function returns the default RRClass.IN()"""
If it is None, this function returns the default RRClass.IN"""
if zone_class_str is None:
return DEFAULT_ZONE_CLASS
try:
......@@ -316,12 +316,12 @@ class XfrinState:
class XfrinInitialSOA(XfrinState):
def handle_rr(self, conn, rr):
if rr.get_type() != RRType.SOA():
if rr.get_type() != RRType.SOA:
raise XfrinProtocolError('First RR in zone transfer must be SOA ('
+ rr.get_type().to_text() + ' received)')
conn._end_serial = get_soa_serial(rr.get_rdata()[0])
if conn._request_type == RRType.IXFR() and \
if conn._request_type == RRType.IXFR and \
conn._end_serial <= conn._request_serial:
logger.info(XFRIN_IXFR_UPTODATE, conn.zone_str(),
conn._request_serial, conn._end_serial)
......@@ -364,8 +364,8 @@ class XfrinFirstData(XfrinState):
http://www.ietf.org/mail-archive/web/dnsext/current/msg07908.html
'''
if conn._request_type == RRType.IXFR() and \
rr.get_type() == RRType.SOA() and \
if conn._request_type == RRType.IXFR and \
rr.get_type() == RRType.SOA and \
conn._request_serial == get_soa_serial(rr.get_rdata()[0]):
logger.debug(DBG_XFRIN_TRACE, XFRIN_GOT_INCREMENTAL_RESP,
conn.zone_str())
......@@ -382,7 +382,7 @@ class XfrinFirstData(XfrinState):
class XfrinIXFRDeleteSOA(XfrinState):
def handle_rr(self, conn, rr):
if rr.get_type() != RRType.SOA():
if rr.get_type() != RRType.SOA:
# this shouldn't happen; should this occur it means an internal
# bug.
raise XfrinException(rr.get_type().to_text() +
......@@ -402,7 +402,7 @@ class XfrinIXFRDeleteSOA(XfrinState):
class XfrinIXFRDelete(XfrinState):
def handle_rr(self, conn, rr):
if rr.get_type() == RRType.SOA():
if rr.get_type() == RRType.SOA:
# This is the only place where current_serial is set
conn._current_serial = get_soa_serial(rr.get_rdata()[0])
self.set_xfrstate(conn, XfrinIXFRAddSOA())
......@@ -413,7 +413,7 @@ class XfrinIXFRDelete(XfrinState):
class XfrinIXFRAddSOA(XfrinState):
def handle_rr(self, conn, rr):
if rr.get_type() != RRType.SOA():
if rr.get_type() != RRType.SOA:
# this shouldn't happen; should this occur it means an internal
# bug.
raise XfrinException(rr.get_type().to_text() +
......@@ -425,7 +425,7 @@ class XfrinIXFRAddSOA(XfrinState):
class XfrinIXFRAdd(XfrinState):
def handle_rr(self, conn, rr):
if rr.get_type() == RRType.SOA():
if rr.get_type() == RRType.SOA:
# This SOA marks the end of a difference sequence
conn.get_transfer_stats().ixfr_changeset_count += 1
soa_serial = get_soa_serial(rr.get_rdata()[0])
......@@ -480,7 +480,7 @@ class XfrinAXFR(XfrinState):
Handle the RR by putting it into the zone.
"""
conn._diff.add_data(rr)
if rr.get_type() == RRType.SOA():
if rr.get_type() == RRType.SOA:
# SOA means end. Don't commit it yet - we need to perform
# post-transfer checks
......@@ -662,7 +662,7 @@ class XfrinConnection(asyncore.dispatcher):
result, finder = self._datasrc_client.find_zone(self._zone_name)
if result != DataSourceClient.SUCCESS:
return None
result, soa_rrset, _ = finder.find(self._zone_name, RRType.SOA())
result, soa_rrset, _ = finder.find(self._zone_name, RRType.SOA)
if result != ZoneFinder.SUCCESS:
logger.info(XFRIN_ZONE_NO_SOA, self.zone_str())
return None
......@@ -714,8 +714,8 @@ class XfrinConnection(asyncore.dispatcher):
query_id = random.randint(0, 0xFFFF)
self._query_id = query_id
msg.set_qid(query_id)
msg.set_opcode(Opcode.QUERY())
msg.set_rcode(Rcode.NOERROR())
msg.set_opcode(Opcode.QUERY)
msg.set_rcode(Rcode.NOERROR)
msg.add_question(Question(self._zone_name, self._rrclass, query_type))
# Remember our serial, if known
......@@ -723,7 +723,7 @@ class XfrinConnection(asyncore.dispatcher):
if self._zone_soa is not None else None
# Set the authority section with our SOA for IXFR
if query_type == RRType.IXFR():
if query_type == RRType.IXFR:
if self._zone_soa is None:
# (incremental) IXFR doesn't work without known SOA
raise XfrinException('Failed to create IXFR query due to no ' +
......@@ -855,7 +855,7 @@ class XfrinConnection(asyncore.dispatcher):
resp_question = msg.get_question()[0]
if resp_question.get_name() != self._zone_name or \
resp_question.get_class() != self._rrclass or \
resp_question.get_type() != RRType.SOA():
resp_question.get_type() != RRType.SOA:
raise XfrinProtocolError('Invalid response to SOA query: '
'question mismatch: ' +
str(resp_question))
......@@ -863,21 +863,21 @@ class XfrinConnection(asyncore.dispatcher):
# Look into the answer section for SOA
soa = None
for rr in msg.get_section(Message.SECTION_ANSWER):
if rr.get_type() == RRType.SOA():
if rr.get_type() == RRType.SOA:
if soa is not None:
raise XfrinProtocolError('SOA response had multiple SOAs')
soa = rr
# There should not be a CNAME record at top of zone.
if rr.get_type() == RRType.CNAME():
if rr.get_type() == RRType.CNAME:
raise XfrinProtocolError('SOA query resulted in CNAME')
# If SOA is not found, try to figure out the reason then report it.
if soa is None:
# See if we have any SOA records in the authority section.
for rr in msg.get_section(Message.SECTION_AUTHORITY):
if rr.get_type() == RRType.NS():
if rr.get_type() == RRType.NS:
raise XfrinProtocolError('SOA query resulted in referral')
if rr.get_type() == RRType.SOA():
if rr.get_type() == RRType.SOA:
raise XfrinProtocolError('SOA query resulted in NODATA')
raise XfrinProtocolError('No SOA record found in response to ' +
'SOA query')
......@@ -901,7 +901,7 @@ class XfrinConnection(asyncore.dispatcher):
'''
self._send_query(RRType.SOA())
self._send_query(RRType.SOA)
data_len = self._get_request_response(2)
msg_len = socket.htons(struct.unpack('H', data_len)[0])
soa_response = self._get_request_response(msg_len)
......@@ -925,7 +925,7 @@ class XfrinConnection(asyncore.dispatcher):
return XFRIN_OK
def do_xfrin(self, check_soa, request_type=RRType.AXFR()):
def do_xfrin(self, check_soa, request_type=RRType.AXFR):
'''Do an xfr session by sending xfr request and parsing responses.'''
try:
......@@ -933,7 +933,7 @@ class XfrinConnection(asyncore.dispatcher):
self._request_type = request_type
# Right now RRType.[IA]XFR().to_text() is 'TYPExxx', so we need
# to hardcode here.
req_str = 'IXFR' if request_type == RRType.IXFR() else 'AXFR'
req_str = 'IXFR' if request_type == RRType.IXFR else 'AXFR'
if check_soa:
self._check_soa_serial()
self.close()
......@@ -1024,7 +1024,7 @@ class XfrinConnection(asyncore.dispatcher):
# cause interoperability trouble with stricter checks.
msg_rcode = msg.get_rcode()
if msg_rcode != Rcode.NOERROR():
if msg_rcode != Rcode.NOERROR:
raise XfrinProtocolError('error response: %s' %
msg_rcode.to_text())
......@@ -1120,13 +1120,13 @@ def __process_xfrin(server, zone_name, rrclass, db_file,
ret = XFRIN_FAIL
if conn.connect_to_master():
ret = conn.do_xfrin(check_soa, request_type)
if ret == XFRIN_FAIL and request_type == RRType.IXFR():
if ret == XFRIN_FAIL and request_type == RRType.IXFR:
# IXFR failed for some reason. It might mean the server can't
# handle it, or we don't have the zone or we are out of sync or
# whatever else. So we retry with with AXFR, as it may succeed
# in many such cases.
retry = True
request_type = RRType.AXFR()
request_type = RRType.AXFR
logger.warn(XFRIN_XFR_TRANSFER_FALLBACK, conn.zone_str())
conn.close()
conn = None
......@@ -1172,7 +1172,7 @@ def process_xfrin(server, xfrin_recorder, zone_name, rrclass, db_file,
xfrin_recorder.decrement(zone_name)
if exception is not None:
typestr = "AXFR" if request_type == RRType.AXFR() else "IXFR"
typestr = "AXFR" if request_type == RRType.AXFR else "IXFR"
logger.error(XFRIN_XFR_PROCESS_FAILURE, typestr, zone_name.to_text(),
str(rrclass), str(exception))
......@@ -1507,9 +1507,9 @@ class Xfrin:
logger.info(XFRIN_RETRANSFER_UNKNOWN_ZONE, zone_str)
answer = create_answer(1, errmsg)
else:
request_type = RRType.AXFR()
request_type = RRType.AXFR
if zone_info.use_ixfr:
request_type = RRType.IXFR()
request_type = RRType.IXFR
master_addr = zone_info.get_master_addr_info()
if notify_addr[0] == master_addr[0] and\
notify_addr[2] == master_addr[2]:
......@@ -1538,11 +1538,11 @@ class Xfrin:
rrclass)
zone_info = self._get_zone_info(zone_name, rrclass)
tsig_key = None
request_type = RRType.AXFR()
request_type = RRType.AXFR
if zone_info:
tsig_key = zone_info.get_tsig_key()
if zone_info.use_ixfr:
request_type = RRType.IXFR()
request_type = RRType.IXFR
db_file = args.get('db_file') or self._get_db_file()
ret = self.xfrin_start(zone_name,
rrclass,
......
This diff is collapsed.
......@@ -227,9 +227,9 @@ class XfroutSession():
self._tsig_key_ring)
tsig_error = self._tsig_ctx.verify(tsig_record, request_data)
if tsig_error != TSIGError.NOERROR:
return Rcode.NOTAUTH()
return Rcode.NOTAUTH
return Rcode.NOERROR()
return Rcode.NOERROR
def _parse_query_message(self, mdata):
''' parse query message to [socket,message]'''
......@@ -239,11 +239,11 @@ class XfroutSession():
Message.from_wire(msg, mdata)
except Exception as err: # Exception is too broad
logger.error(XFROUT_PARSE_QUERY_ERROR, err)
return Rcode.FORMERR(), None
return Rcode.FORMERR, None
# TSIG related checks
rcode = self._check_request_tsig(msg, mdata)
if rcode != Rcode.NOERROR():
if rcode != Rcode.NOERROR:
return rcode, msg
# Make sure the question is valid. This should be ensured by
......@@ -257,9 +257,9 @@ class XfroutSession():
# Identify the request type
self._request_type = question.get_type()
if self._request_type == RRType.AXFR():
if self._request_type == RRType.AXFR:
self._request_typestr = 'AXFR'
elif self._request_type == RRType.IXFR():
elif self._request_type == RRType.IXFR:
self._request_typestr = 'IXFR'
else:
# Likewise, this should be impossible.
......@@ -283,7 +283,7 @@ class XfroutSession():
logger.debug(DBG_XFROUT_TRACE, XFROUT_QUERY_REJECTED,
self._request_type, format_addrinfo(self._remote),
format_zone_str(zone_name, zone_class))
return Rcode.REFUSED(), msg
return Rcode.REFUSED, msg
return rcode, msg
......@@ -351,16 +351,16 @@ class XfroutSession():
'''
result, finder = self._datasrc_client.find_zone(zone_name)
if result != DataSourceClient.SUCCESS:
return (Rcode.NOTAUTH(), None)
result, soa_rrset, _ = finder.find(zone_name, RRType.SOA())
return (Rcode.NOTAUTH, None)
result, soa_rrset, _ = finder.find(zone_name, RRType.SOA)
if result != ZoneFinder.SUCCESS:
return (Rcode.SERVFAIL(), None)
return (Rcode.SERVFAIL, None)
# Especially for database-based zones, a working zone may be in
# a broken state where it has more than one SOA RR. We proactively
# check the condition and abort the xfr attempt if we identify it.
if soa_rrset.get_rdata_count() != 1:
return (Rcode.SERVFAIL(), None)
return (Rcode.NOERROR(), soa_rrset)
return (Rcode.SERVFAIL, None)
return (Rcode.NOERROR, soa_rrset)
def __axfr_setup(self, zone_name):
'''Setup a zone iterator for AXFR or AXFR-style IXFR.
......@@ -379,16 +379,16 @@ class XfroutSession():
# update get_iterator() API so that we can distinguish "no such
# zone" and other cases (#1373). For now we consider all these
# cases as NOTAUTH.
return Rcode.NOTAUTH()
return Rcode.NOTAUTH
# If we are an authoritative name server for the zone, but fail
# to find the zone's SOA record in datasource, xfrout can't
# provide zone transfer for it.
self._soa = self._iterator.get_soa()
if self._soa is None or self._soa.get_rdata_count() != 1:
return Rcode.SERVFAIL()
return Rcode.SERVFAIL
return Rcode.NOERROR()
return Rcode.NOERROR
def __ixfr_setup(self, request_msg, zone_name, zone_class):
'''Setup a zone journal reader for IXFR.
......@@ -405,21 +405,21 @@ class XfroutSession():
# Ignore data whose owner name is not the zone apex, and
# ignore non-SOA or different class of records.
if auth_rrset.get_name() != zone_name or \
auth_rrset.get_type() != RRType.SOA() or \
auth_rrset.get_type() != RRType.SOA or \
auth_rrset.get_class() != zone_class:
continue
if auth_rrset.get_rdata_count() != 1:
logger.info(XFROUT_IXFR_MULTIPLE_SOA,
format_addrinfo(self._remote))
return Rcode.FORMERR()
return Rcode.FORMERR
remote_soa = auth_rrset
if remote_soa is None:
logger.info(XFROUT_IXFR_NO_SOA, format_addrinfo(self._remote))
return Rcode.FORMERR()
return Rcode.FORMERR
# Retrieve the local SOA
rcode, self._soa = self._get_zone_soa(zone_name)
if rcode != Rcode.NOERROR():
if rcode != Rcode.NOERROR:
return rcode
# RFC1995 says "If an IXFR query with the same or newer version
......@@ -437,7 +437,7 @@ class XfroutSession():
logger.info(XFROUT_IXFR_UPTODATE, format_addrinfo(self._remote),
format_zone_str(zone_name, zone_class),
begin_serial, end_serial)
return Rcode.NOERROR()
return Rcode.NOERROR
# Set up the journal reader or fall back to AXFR-style IXFR
try:
......@@ -462,12 +462,12 @@ class XfroutSession():
# between these two operations. We treat it as NOTAUTH.
logger.warn(XFROUT_IXFR_NO_ZONE, format_addrinfo(self._remote),
format_zone_str(zone_name, zone_class))
return Rcode.NOTAUTH()
return Rcode.NOTAUTH
# Use the reader as the iterator to generate the response.
self._iterator = self._jnl_reader
return Rcode.NOERROR()
return Rcode.NOERROR
def _xfrout_setup(self, request_msg, zone_name, zone_class):
'''Setup a context for xfr responses according to the request type.
......@@ -490,7 +490,7 @@ class XfroutSession():
self._server.get_db_file() + '"}'
self._datasrc_client = self.ClientClass('sqlite3', datasrc_config)
if self._request_type == RRType.AXFR():
if self._request_type == RRType.AXFR:
return self.__axfr_setup(zone_name)
else:
return self.__ixfr_setup(request_msg, zone_name, zone_class)
......@@ -500,17 +500,17 @@ class XfroutSession():
#TODO. create query message and parse header
if rcode_ is None: # Dropped by ACL
return
elif rcode_ == Rcode.NOTAUTH() or rcode_ == Rcode.REFUSED():
elif rcode_ == Rcode.NOTAUTH or rcode_ == Rcode.REFUSED:
return self._reply_query_with_error_rcode(msg, sock_fd, rcode_)
elif rcode_ != Rcode.NOERROR():
elif rcode_ != Rcode.NOERROR:
return self._reply_query_with_error_rcode(msg, sock_fd,
Rcode.FORMERR())
Rcode.FORMERR)
elif not quota_ok:
logger.warn(XFROUT_QUERY_QUOTA_EXCCEEDED, self._request_typestr,
format_addrinfo(self._remote),
self._server._max_transfers_out)
return self._reply_query_with_error_rcode(msg, sock_fd,
Rcode.REFUSED())
Rcode.REFUSED)
question = msg.get_question()[0]
zone_name = question.get_name()
......@@ -522,15 +522,15 @@ class XfroutSession():
except Exception as ex:
logger.error(XFROUT_XFR_TRANSFER_CHECK_ERROR, self._request_typestr,
format_addrinfo(self._remote), zone_str, ex)
rcode_ = Rcode.SERVFAIL()
if rcode_ != Rcode.NOERROR():
rcode_ = Rcode.SERVFAIL
if rcode_ != Rcode.NOERROR:
logger.info(XFROUT_XFR_TRANSFER_FAILED, self._request_typestr,
format_addrinfo(self._remote), zone_str, rcode_)
return self._reply_query_with_error_rcode(msg, sock_fd, rcode_)
try:
# increment Xfr starts by RRType
if self._request_type == RRType.AXFR():
if self._request_type == RRType.AXFR:
self._inc_axfr_running()
else:
self._inc_ixfr_running()
......@@ -542,7 +542,7 @@ class XfroutSession():
format_addrinfo(self._remote), zone_str, err)
finally:
# decrement Xfr starts by RRType
if self._request_type == RRType.AXFR():
if self._request_type == RRType.AXFR:
self._dec_axfr_running()
else:
self._dec_ixfr_running()
......@@ -614,7 +614,7 @@ class XfroutSession():
# For AXFR (or AXFR-style IXFR), in which case _jnl_reader is None,
# we should skip SOAs from the iterator.
if self._jnl_reader is None and rrset.get_type() == RRType.SOA():
if self._jnl_reader is None and rrset.get_type() == RRType.SOA:
continue
# We calculate the maximum size of the RRset (i.e. the
......@@ -1215,7 +1215,7 @@ class XfroutServer:
zone_name = args.get('zone_name')
zone_class = args.get('zone_class')
if not zone_class:
zone_class = str(RRClass.IN())
zone_class = str(RRClass.IN)
if zone_name:
logger.info(XFROUT_NOTIFY_COMMAND, zone_name, zone_class)
if self.send_notify(zone_name, zone_class):
......
......@@ -8,6 +8,10 @@ AM_CXXFLAGS = $(B10_CXXFLAGS)
CLEANFILES = *.gcno *.gcda
CLEANFILES += rrclass.h rrtype.h rrparamregistry.cc rdataclass.h rdataclass.cc
# These two are created with rrtype/class.h, so not explicitly listed in
# BUILT_SOURCES.
CLEANFILES += python/rrtype_constants_inc.cc
CLEANFILES += python/rrclass_constants_inc.cc
EXTRA_DIST = rrclass-placeholder.h
EXTRA_DIST += rrparamregistry-placeholder.cc
......
......@@ -46,9 +46,30 @@ new_rdata_factory_users = [('aaaa', 'in'),
('txt', 'generic')