mirror of
https://github.com/home-assistant/core.git
synced 2025-07-30 00:27:19 +00:00
Remove lock and add host timeout to NMAP scanner
This commit is contained in:
parent
c3fc19353b
commit
4484baa866
@ -1,7 +1,6 @@
|
|||||||
""" Supports scanning using nmap. """
|
""" Supports scanning using nmap. """
|
||||||
import logging
|
import logging
|
||||||
from datetime import timedelta, datetime
|
from datetime import timedelta, datetime
|
||||||
import threading
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
import subprocess
|
import subprocess
|
||||||
import re
|
import re
|
||||||
@ -54,7 +53,6 @@ class NmapDeviceScanner(object):
|
|||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
self.last_results = []
|
self.last_results = []
|
||||||
|
|
||||||
self.lock = threading.Lock()
|
|
||||||
self.hosts = config[CONF_HOSTS]
|
self.hosts = config[CONF_HOSTS]
|
||||||
minutes = convert(config.get(CONF_HOME_INTERVAL), int, 0)
|
minutes = convert(config.get(CONF_HOME_INTERVAL), int, 0)
|
||||||
self.home_interval = timedelta(minutes=minutes)
|
self.home_interval = timedelta(minutes=minutes)
|
||||||
@ -116,10 +114,9 @@ class NmapDeviceScanner(object):
|
|||||||
if not self.success_init:
|
if not self.success_init:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
with self.lock:
|
|
||||||
_LOGGER.info("Scanning")
|
_LOGGER.info("Scanning")
|
||||||
|
|
||||||
options = "-F"
|
options = "-F --host-timeout 5"
|
||||||
exclude_targets = set()
|
exclude_targets = set()
|
||||||
if self.home_interval:
|
if self.home_interval:
|
||||||
now = datetime.now()
|
now = datetime.now()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user