forked from openlp/openlp
Extract filtering to make things more testable
This commit is contained in:
parent
f0b6a723e3
commit
f27e4f8821
@ -92,6 +92,19 @@ class ZeroconfWorker(ThreadWorker):
|
|||||||
self._can_run = False
|
self._can_run = False
|
||||||
|
|
||||||
|
|
||||||
|
def filter_interfaces():
|
||||||
|
"""
|
||||||
|
Return a list of interfaces filtered down to valid interfaces
|
||||||
|
"""
|
||||||
|
all_interfaces = get_local_ip4()
|
||||||
|
interfaces = {}
|
||||||
|
for name, interface in all_interfaces.items():
|
||||||
|
log.debug('Interface {name}: {interface}'.format(name=name, interface=interface))
|
||||||
|
if not INTERFACE_FILTER.search(name):
|
||||||
|
interfaces[name] = interface
|
||||||
|
return interfaces
|
||||||
|
|
||||||
|
|
||||||
def start_zeroconf():
|
def start_zeroconf():
|
||||||
"""
|
"""
|
||||||
Start the Zeroconf service
|
Start the Zeroconf service
|
||||||
@ -101,9 +114,6 @@ def start_zeroconf():
|
|||||||
return
|
return
|
||||||
http_port = Settings().value('api/port')
|
http_port = Settings().value('api/port')
|
||||||
ws_port = Settings().value('api/websocket port')
|
ws_port = Settings().value('api/websocket port')
|
||||||
for name, interface in get_local_ip4().items():
|
for name, interface in filter_interfaces().items():
|
||||||
log.debug('Interface {name}: {interface}'.format(name=name, interface=interface))
|
worker = ZeroconfWorker(interface['ip'], http_port, ws_port)
|
||||||
if not INTERFACE_FILTER.search(name):
|
run_thread(worker, 'api_zeroconf_{name}'.format(name=name))
|
||||||
# Only advertise on real interfaces
|
|
||||||
worker = ZeroconfWorker(interface['ip'], http_port, ws_port)
|
|
||||||
run_thread(worker, 'api_zeroconf_{name}'.format(name=name))
|
|
||||||
|
Loading…
Reference in New Issue
Block a user