🐞 fix: Port scanning fixes

This commit is contained in:
Keith Solomon
2026-03-08 19:39:11 -05:00
parent 5dae17fb73
commit 7c5cbcbe7c
4 changed files with 11 additions and 2 deletions

View File

@@ -4,6 +4,7 @@ DB_PATH = os.getenv("NETTRAK_DB_PATH", "/data/nettrak.db")
DEFAULT_SUBNET = os.getenv("NETTRAK_SUBNET", "192.168.2.0/24")
SCAN_TIMEOUT_SECONDS = int(os.getenv("NETTRAK_SCAN_TIMEOUT", "1800"))
SCAN_TOP_PORTS = int(os.getenv("NETTRAK_TOP_PORTS", "100"))
SCAN_PORT_SPEC = os.getenv("NETTRAK_PORT_SPEC", "").strip()
SCAN_WORKERS = int(os.getenv("NETTRAK_SCAN_WORKERS", "12"))
PORT_PROBE_TIMEOUT_SECONDS = float(os.getenv("NETTRAK_PORT_PROBE_TIMEOUT", "0.4"))
ENABLE_OS_DETECTION = os.getenv("NETTRAK_ENABLE_OS_DETECTION", "0").lower() in {"1", "true", "yes", "on"}

View File

@@ -14,6 +14,7 @@ from .config import (
ENABLE_DOCKER_INSIGHTS,
ENABLE_OS_DETECTION,
PORT_PROBE_TIMEOUT_SECONDS,
SCAN_PORT_SPEC,
SCAN_TOP_PORTS,
)
@@ -270,8 +271,6 @@ def scan_host(ip: str, seed_host: dict[str, Any] | None = None) -> HostResult:
"--open",
"-sV",
"--version-light",
"--top-ports",
str(max(SCAN_TOP_PORTS, 1)),
"-T4",
"--max-retries",
"1",
@@ -279,6 +278,10 @@ def scan_host(ip: str, seed_host: dict[str, Any] | None = None) -> HostResult:
"45s",
ip,
]
if SCAN_PORT_SPEC:
base_args[5:5] = ["-p", SCAN_PORT_SPEC]
else:
base_args[5:5] = ["--top-ports", str(max(SCAN_TOP_PORTS, 1))]
result: HostResult | None = None
if ENABLE_OS_DETECTION: