From f9b413d17252a261bd415a25565c8748297f285d Mon Sep 17 00:00:00 2001 From: jokob-sk Date: Sun, 31 May 2026 08:51:48 +1000 Subject: [PATCH] PLG: ICMP handling VLANS #1662 --- docs/DEV_ENV_SETUP.md | 2 ++ front/plugins/icmp_scan/icmp.py | 42 +++++++++++++++++++++++++++++---- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/docs/DEV_ENV_SETUP.md b/docs/DEV_ENV_SETUP.md index 9547482d..6da0fc21 100755 --- a/docs/DEV_ENV_SETUP.md +++ b/docs/DEV_ENV_SETUP.md @@ -18,12 +18,14 @@ Before starting development, please review the following guidelines. The application architecture is designed for extensibility and maintainability. It relies heavily on configuration manifests via plugins and settings to dynamically build the UI and populate the application with data from various sources. For details, see: + - [Plugins Development](PLUGINS_DEV.md) (includes video) - [Settings System](SETTINGS_SYSTEM.md) Focus on **core functionality** and integrate with existing tools rather than reinventing the wheel. Examples: + - Using **Apprise** for notifications instead of implementing multiple separate gateways - Implementing **regex-based validation** instead of one-off validation for each setting diff --git a/front/plugins/icmp_scan/icmp.py b/front/plugins/icmp_scan/icmp.py index 91be5311..ab4b8541 100755 --- a/front/plugins/icmp_scan/icmp.py +++ b/front/plugins/icmp_scan/icmp.py @@ -36,13 +36,47 @@ RESULT_FILE = os.path.join(LOG_PATH, f'last_result.{pluginName}.log') def parse_scan_subnets(subnets): """Extract subnet and interface from SCAN_SUBNETS""" + ranges = [] interfaces = [] + for entry in subnets: - parts = entry.split("--interface=") - ranges.append(parts[0].strip()) - if len(parts) > 1: - interfaces.append(parts[1].strip()) + + # Extract interface + interface_match = re.search(r'--interface=([^\s]+)', entry) + interface = interface_match.group(1) if interface_match else None + + # Extract vlan + vlan_match = re.search(r'--vlan=(\d+)', entry) + vlan = vlan_match.group(1) if vlan_match else None + + # If VLAN interface exists, use it + if interface and vlan: + vlan_interface = f"{interface}.{vlan}" + + if os.path.exists(f"/sys/class/net/{vlan_interface}"): + interface = vlan_interface + mylog('verbose', [ + f'[{pluginName}] Using VLAN interface: {interface}' + ]) + else: + mylog('verbose', [ + f'[{pluginName}] VLAN interface {vlan_interface} not found, using {interface}' + ]) + + if interface: + interfaces.append(interface) + + # Remove interface/vlan options from subnet definition + subnet = re.sub(r'\s+--interface=[^\s]+', '', entry) + subnet = re.sub(r'\s+--vlan=\d+', '', subnet) + + ranges.append(subnet.strip()) + + mylog('verbose', [f'[{pluginName}] SCAN_SUBNETS value: {subnets}']) + mylog('verbose', [f'[{pluginName}] Parsed subnets: {ranges}']) + mylog('verbose', [f'[{pluginName}] Parsed interfaces: {interfaces}']) + return ranges, interfaces