Merge "Do not send DNS queries against hostnames"

This commit is contained in:
Jenkins 2017-02-01 20:12:45 +00:00 committed by Gerrit Code Review
commit 31ca41e05b
2 changed files with 8 additions and 3 deletions

View File

@ -309,4 +309,9 @@ class NotifyEndpoint(base.BaseEndpoint):
:return: response
"""
send = dns_query.tcp if CONF['service:mdns'].all_tcp else dns_query.udp
return send(dns_message, host, port=port, timeout=timeout)
return send(
dns_message,
socket.gethostbyname(host),
port=port,
timeout=timeout
)

View File

@ -266,9 +266,9 @@ class MdnsNotifyTest(base.BaseTestCase):
@mock.patch.object(notify.dns_query, 'tcp')
@mock.patch.object(notify.dns_query, 'udp')
def test_send_dns_message(self, *mocks):
out = self.notify._send_dns_message('msg', 'host', 123, 1)
out = self.notify._send_dns_message('msg', '192.0.2.1', 1234, 1)
assert not notify.dns_query.tcp.called
notify.dns_query.udp.assert_called_with('msg', 'host', port=123,
notify.dns_query.udp.assert_called_with('msg', '192.0.2.1', port=1234,
timeout=1)
assert isinstance(out, Mock)