Commit 9611300c authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

[trac964] fixed the problem, with an additional test case.

parent a739faa4
......@@ -21,6 +21,7 @@ import threading
import time
import errno
from isc.datasrc import sqlite3_ds
from import addr
import isc
from pydnspp import *
......@@ -90,9 +91,9 @@ class ZoneNotifyInfo:
self._sock = None
self.notify_timeout = None
def create_socket(self, addrinfo):
# XXX we'll fix this
self._sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
def create_socket(self, dest_addr):
self._sock = socket.socket(addr.IPAddr(dest_addr).family,
return self._sock
def get_socket(self):
......@@ -392,12 +393,13 @@ class NotifyOut:
zone_notify_info.notify_msg_id = qid
sock = zone_notify_info.create_socket(addrinfo)
sock = zone_notify_info.create_socket(addrinfo[0])
sock.sendto(render.get_data(), 0, addrinfo)
self._log_msg('info', 'sending notify to %s' % addr_to_str(addrinfo))
except socket.error as err:
self._log_msg('error', 'send notify to %s failed: %s' % (addr_to_str(addrinfo), str(err)))
except (socket.error, addr.InvalidAddress) as err:
self._log_msg('error', 'send notify to %s failed: %s' %
(addr_to_str(addrinfo), str(err)))
return False
return True
......@@ -257,6 +257,17 @@ class TestNotifyOut(unittest.TestCase):
self.assertEqual(socket.AF_INET6, example_com_info.sock_family)
def test_send_notify_message_with_bogus_address(self):
example_com_info = self._notify._notify_infos[('', 'IN')]
# As long as the underlying data source validates RDATA this shouldn't
# happen, but right now it's not actually the case. Even if the
# data source does its job, it's prudent to confirm the behavior for
# an unexpected case.
ret = self._notify._send_notify_message_udp(example_com_info,
('invalid', 53))
def test_zone_notify_handler(self):
old_send_msg = self._notify._send_notify_message_udp
def _fake_send_notify_message_udp(va1, va2):
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