# When not testing ACLs, simply accept
isc.acl.dns.REQUEST_LOADER.load(
[{"action": "ACCEPT"}]),
- {})
+ {},
+ xfrout.Counters(xfrout.SPECFILE_LOCATION))
self.set_request_type(RRType.AXFR) # test AXFR by default
self.mdata = self.create_request_data()
self.soa_rrset = create_soa(SOA_CURRENT_VERSION)
# This would be the handler class, but we just check it is passed
# the right parametes, so function is enough for that.
keys = isc.server_common.tsig_keyring.get_keyring()
- def handler(sock, data, server, keyring, address, acl, config):
+ def handler(sock, data, server, keyring, address, acl, config,
+ counters):
self.assertEqual("sock", sock)
self.assertEqual("data", data)
self.assertEqual(self.unix, server)
self.assertEqual("Address", address)
self.assertEqual("acl", acl)
self.assertEqual("Zone config", config)
+ self.assertIs(self.unix._counters, counters)
self.unix.RequestHandlerClass = handler
self.unix.finish_request("sock", "data")
finally:
xfrout.ThreadingUnixStreamServer = DummySocketserver
xfrout.super = lambda : DummySocketserver()
xfrout.select.select = lambda x,y,z: ([None],[None],[None])
- self.unix = UnixSockServer(None, None, threading.Event(), None, None)
+ self._counters = xfrout.Counters(xfrout.SPECFILE_LOCATION)
+ self.unix = UnixSockServer(None, None, threading.Event(), None, None,
+ self._counters)
def tearDown(self):
( UnixSockServer._remove_unused_sock_file,
'socket', 'unixdomain', 'openfail')
xfrout.ThreadingUnixStreamServer = DummySocketserverException
try:
- self.unix = UnixSockServer(None, None, None, None, None)
+ self.unix = UnixSockServer(None, None, None, None, None,
+ self._counters)
except Exception:
pass
else:
self.unix._counters.get,
'socket', 'unixdomain', 'acceptfail')
xfrout.super = lambda : DummyClassException()
- self.unix = UnixSockServer(None, None, None, None, None)
+ self.unix = UnixSockServer(None, None, None, None, None, self._counters)
self.assertRaises(Exception, self.unix.get_request)
self.assertEqual(
self.unix._counters.get('socket', 'unixdomain', 'acceptfail'), 1)
class XfroutSession():
def __init__(self, sock_fd, request_data, server, tsig_key_ring, remote,
- default_acl, zone_config, client_class=DataSourceClient):
+ default_acl, zone_config, counters,
+ client_class=DataSourceClient):
self._sock_fd = sock_fd
self._request_data = request_data
self._server = server
self._jnl_reader = None # will be set to a reader for IXFR
# Creation of self.counters should be done before of
# invoking self._handle()
- self._counters = Counters(SPECFILE_LOCATION)
+ self._counters = counters
self._handle()
def create_tsig_ctx(self, tsig_record, tsig_key_ring):
'''The unix domain socket server which accept xfr query sent from auth server.'''
def __init__(self, sock_file, handle_class, shutdown_event, config_data,
- cc):
+ cc, counters):
self._remove_unused_sock_file(sock_file)
self._sock_file = sock_file
socketserver_mixin.NoPollMixIn.__init__(self)
- self._counters = Counters(SPECFILE_LOCATION)
+ self._counters = counters
try:
ThreadingUnixStreamServer.__init__(self, sock_file, \
handle_class)
self._lock.release()
self.RequestHandlerClass(sock_fd, request_data, self,
isc.server_common.tsig_keyring.get_keyring(),
- self._guess_remote(sock_fd), acl, zone_config)
+ self._guess_remote(sock_fd), acl, zone_config,
+ self._counters)
def _remove_unused_sock_file(self, sock_file):
'''Try to remove the socket file. If the file is being used
self._shutdown_event = threading.Event()
self._cc = isc.config.ModuleCCSession(SPECFILE_LOCATION, self.config_handler, self.command_handler)
self._config_data = self._cc.get_full_config()
+ self._counters = Counters(SPECFILE_LOCATION)
self._cc.start()
self._cc.add_remote_config(AUTH_SPECFILE_LOCATION)
isc.server_common.tsig_keyring.init_keyring(self._cc)
self._start_xfr_query_listener()
self._start_notifier()
- self._counters = Counters(SPECFILE_LOCATION)
def _start_xfr_query_listener(self):
'''Start a new thread to accept xfr query. '''
XfroutSession,
self._shutdown_event,
self._config_data,
- self._cc)
+ self._cc, self._counters)
listener = threading.Thread(target=self._unix_socket_server.serve_forever)
listener.start()