diff --git a/confluent_server/confluent/discovery/protocols/slp.py b/confluent_server/confluent/discovery/protocols/slp.py index f640702d..a2c8a220 100644 --- a/confluent_server/confluent/discovery/protocols/slp.py +++ b/confluent_server/confluent/discovery/protocols/slp.py @@ -198,7 +198,14 @@ def _find_srvtype(net, net4, srvtype, addresses, xid): :param addresses: Pass through of addresses argument from find_targets :return: """ - if addresses is None: + if addresses is not None: + for addr in addresses: + for saddr in socket.getaddrinfo(addr, 427): + if saddr[0] == socket.AF_INET: + net4.sendto(data, saddr[4]) + elif saddr[0] == socket.AF_INET6: + net.sendto(data, saddr[4]) + else: data = _generate_request_payload(srvtype, True, xid) net4.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) v6addrs = [] diff --git a/misc/slpscan.py b/misc/slpscan.py index dcae465e..3412e254 100644 --- a/misc/slpscan.py +++ b/misc/slpscan.py @@ -1,10 +1,5 @@ # vim: tabstop=4 shiftwidth=4 softtabstop=4 -# This is extracting the confluent slp support into -# a standalone script, for use in environments that -# can't run full confluent and/or would prefer -# a utility style approach to SLP - # Copyright 2017-2019 Lenovo # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,6 +14,12 @@ # See the License for the specific language governing permissions and # limitations under the License. +# This is extracting the confluent slp support into +# a standalone script, for use in environments that +# can't run full confluent and/or would prefer +# a utility style approach to SLP + + import os import random import select @@ -199,8 +200,15 @@ def _find_srvtype(net, net4, srvtype, addresses, xid): :param addresses: Pass through of addresses argument from find_targets :return: """ - if addresses is None: - data = _generate_request_payload(srvtype, True, xid) + data = _generate_request_payload(srvtype, True, xid) + if addresses is not None: + for addr in addresses: + for saddr in socket.getaddrinfo(addr, 427): + if saddr[0] == socket.AF_INET: + net4.sendto(data, saddr[4]) + elif saddr[0] == socket.AF_INET6: + net.sendto(data, saddr[4]) + else: net4.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) v6addrs = [] v6hash = _v6mcasthash(srvtype) @@ -846,6 +854,4 @@ def natural_sort(iterable): if __name__ == '__main__': - def testsnoop(a): - print(repr(a)) - snoop(testsnoop) + print(repr(list(scan(addresses=['10.240.52.189']))))