PLG: ICMP handling VLANS #1662

This commit is contained in:
jokob-sk
2026-05-31 08:51:48 +10:00
parent 62e40707f9
commit f9b413d172
2 changed files with 40 additions and 4 deletions

View File

@@ -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

View File

@@ -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