Commit 660a0d16 authored by Mukund Sivaraman's avatar Mukund Sivaraman
Browse files

Merge branch 'master' into trac2672

Conflicts:
	src/lib/python/isc/ddns/session.py
parents 1a80b1dd 9b16b116
567. [doc] marcin, stephen, tomek
Update DHCP sections of the BIND 10 guide.
(Trac #2657, git 1d0c2004865d1bf322bf78d13630d992e39179fd)
566. [func]* jinmei
libdns++/Python isc.dns: In Python isc.dns, function style
constants for RRType, RRClass, Rcode and Opcode were deprecated
and replaced with straightforward object constants, e.g., from
RRType.AAAA() to RRType.AAAA. This is a backward incompatible
change (see the Trac ticket for a conversion script if needed).
Also, these constants are now more consistent between C++
and Python, and RRType constants for all currently standardized
types are now supported (even if Rdata for these are not yet
available).
(Trac #1866 and #2409, git e5005185351cf73d4a611407c2cfcd163f80e428)
565. [func]* jelte
The main initializer script (formerly known as either 'bind10',
'boss', or 'bob'), has been renamed to b10-init (and Init in
......
......@@ -238,6 +238,21 @@ AM_CONDITIONAL(SET_ENV_LIBRARY_PATH, test $SET_ENV_LIBRARY_PATH = yes)
AC_SUBST(SET_ENV_LIBRARY_PATH)
AC_SUBST(ENV_LIBRARY_PATH)
# Our experiments have shown Solaris 10 has broken support for the
# IPV6_USE_MIN_MTU socket option for getsockopt(); it doesn't return the value
# previously set via setsockopt(). We know it doesn't happen on one instance
# on Solaris 11, but we don't know whether it happens for any Solaris 10
# implementations or for earlier versions of Solaris. In any case, at the
# moment this matters for only one unittest case, so we'll simply disable
# the affected test using the following definition with the specific hardcoding
# of that version of Solaris.
case "$host" in
*-solaris2.10)
AC_DEFINE([HAVE_BROKEN_GET_IPV6_USE_MIN_MTU], [1],
[Define to 1 if getsockopt(IPV6_USE_MIN_MTU) does not work])
;;
esac
m4_define([_AM_PYTHON_INTERPRETER_LIST], [python python3.3 python3.2 python3.1 python3])
AC_ARG_WITH([pythonpath],
AC_HELP_STRING([--with-pythonpath=PATH],
......@@ -1319,7 +1334,7 @@ AC_OUTPUT([doc/version.ent
src/bin/stats/stats_httpd.py
src/bin/bind10/init.py
src/bin/bind10/run_bind10.sh
src/bin/bind10/tests/bind10_test.py
src/bin/bind10/tests/init_test.py
src/bin/bindctl/run_bindctl.sh
src/bin/bindctl/bindctl_main.py
src/bin/bindctl/tests/bindctl_test
......
This diff is collapsed.
......@@ -106,7 +106,7 @@ public:
rollbackAddresses_ = old;
}
virtual void commit() {
rollbackAddresses_.release();
rollbackAddresses_.reset();
}
private:
AuthSrv& server_;
......
......@@ -130,7 +130,7 @@ TEST_F(AuthConfigTest, invalidListenAddressConfig) {
isc::testutils::portconfig::invalidListenAddressConfig(server);
}
// Try setting addresses trough config
// Try setting addresses through config
TEST_F(AuthConfigTest, listenAddressConfig) {
isc::testutils::portconfig::listenAddressConfig(server);
......
#!/bin/sh
prefix=@prefix@
exec_prefix=@exec_prefix@
exec @libexecdir@/@PACKAGE@/b10-init $*
# We use this wrapper script both for production and in-source tests; in
# the latter case B10_FROM_BUILD environment is expected to be defined.
if test -n "${B10_FROM_BUILD}"; then
exec ${B10_FROM_BUILD}/src/bin/bind10/b10-init $*
else
prefix=@prefix@
exec_prefix=@exec_prefix@
exec @libexecdir@/@PACKAGE@/b10-init $*
fi
......@@ -72,6 +72,7 @@ import isc.cc
import isc.util.process
import isc.net.parse
import isc.log
import isc.config
from isc.log_messages.init_messages import *
import isc.bind10.component
import isc.bind10.special_component
......
PYCOVERAGE_RUN = @PYCOVERAGE_RUN@
#PYTESTS = args_test.py bind10_test.py
# NOTE: this has a generated test found in the builddir
PYTESTS = bind10_test.py
PYTESTS = init_test.py
noinst_SCRIPTS = $(PYTESTS)
# If necessary (rare cases), explicitly specify paths to dynamic libraries
......
......@@ -31,8 +31,8 @@ import signal
import socket
from isc.net.addr import IPAddr
import time
import isc
import isc.log
import isc.config
import isc.bind10.socket_cache
import errno
import random
......
......@@ -25,7 +25,7 @@ from bindctl.moduleinfo import *
from bindctl.cmdparse import BindCmdParser
from bindctl import command_sets
from xml.dom import minidom
import isc
import isc.config
import isc.cc.data
import http.client
import json
......
......@@ -23,7 +23,7 @@ BINDCTL_PATH=@abs_top_builddir@/src/bin/bindctl
# Note: lib/dns/python/.libs is necessary because __init__.py of isc package
# automatically imports isc.datasrc, which then requires the DNS loadable
# module. #2145 should eliminate the need for it.
PYTHONPATH=@abs_top_srcdir@/src/bin:@abs_top_builddir@/src/lib/python/isc/log_messages:@abs_top_builddir@/src/lib/python:@abs_top_builddir@/src/bin:@abs_top_srcdir@/src/lib/python:@abs_top_builddir@/src/lib/dns/python/.libs
PYTHONPATH=@abs_top_srcdir@/src/bin:@abs_top_builddir@/src/lib/python/isc/log_messages:@abs_top_builddir@/src/lib/python:@abs_top_builddir@/src/bin:@abs_top_srcdir@/src/lib/python
export PYTHONPATH
# If necessary (rare cases), explicitly specify paths to dynamic libraries
......
......@@ -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())
......
......@@ -12,6 +12,8 @@
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
#include <config.h>
#include "../sockcreator.h"
#include <util/unittests/fork.h>
......@@ -195,7 +197,12 @@ TEST(get_sock, tcp4_create) {
testAnyCreate<sockaddr_in>(SOCK_STREAM, tcpCheck);
}
TEST(get_sock, udp6_create) {
#ifdef HAVE_BROKEN_GET_IPV6_USE_MIN_MTU
TEST(get_sock, DISABLED_udp6_create)
#else
TEST(get_sock, udp6_create)
#endif
{
testAnyCreate<sockaddr_in6>(SOCK_DGRAM, udpCheck<sockaddr_in6>);
}
......
......@@ -26,7 +26,8 @@ from optparse import OptionParser, OptionValueError
import errno
import select
import isc
import isc.cc
import isc.config
import isc.util.process
import isc.log
from isc.log_messages.stats_messages import *
......
......@@ -20,20 +20,8 @@ export PYTHON_EXEC
SYSINFO_PATH=@abs_top_builddir@/src/bin/sysinfo
# Note: we shouldn't need log_messages and lib/dns except for the seemingly
# necessary dependency due to the automatic import in the isc package (its
# __init__.py imports some other modules)
# #2145 should eliminate the need for them.
PYTHONPATH=@abs_top_builddir@/src/lib/python:@abs_top_srcdir@/src/lib/python:@abs_top_builddir@/src/lib/python/isc/log_messages:@abs_top_builddir@/src/lib/dns/python/.libs
PYTHONPATH=@abs_top_builddir@/src/lib/python:@abs_top_srcdir@/src/lib/python
export PYTHONPATH
# Likewise, we need only because isc.log requires some loadable modules.
# sysinfo itself shouldn't need any of them.
SET_ENV_LIBRARY_PATH=@SET_ENV_LIBRARY_PATH@
if test $SET_ENV_LIBRARY_PATH = yes; then
@ENV_LIBRARY_PATH@=@abs_top_builddir@/src/lib/dns/.libs:@abs_top_builddir@/src/lib/dns/python/.libs:@abs_top_builddir@/src/lib/cryptolink/.libs:@abs_top_builddir@/src/lib/cc/.libs:@abs_top_builddir@/src/lib/config/.libs:@abs_top_builddir@/src/lib/log/.libs:@abs_top_builddir@/src/lib/acl/.libs:@abs_top_builddir@/src/lib/util/.libs:@abs_top_builddir@/src/lib/util/io/.libs:@abs_top_builddir@/src/lib/exceptions/.libs:@abs_top_builddir@/src/lib/datasrc/.libs:$@ENV_LIBRARY_PATH@
export @ENV_LIBRARY_PATH@
fi
cd ${SYSINFO_PATH}
exec ${PYTHON_EXEC} -O sysinfo.py "$@"
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,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment