Do not send DNS queries against hostnames
the `dns.query` API takes an IP address. This ensures the `host` is always an IP Change-Id: Id9601173e68bab3b6b245215f82b02a6492670cd Closes-Bug: #1623949
This commit is contained in:
parent
66e69fb2c0
commit
a7dda9c341
@ -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
|
||||
)
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user