Skip to content

Commit f9b413d

Browse files
committed
PLG: ICMP handling VLANS #1662
1 parent 62e4070 commit f9b413d

2 files changed

Lines changed: 40 additions & 4 deletions

File tree

docs/DEV_ENV_SETUP.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@ Before starting development, please review the following guidelines.
1818
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.
1919

2020
For details, see:
21+
2122
- [Plugins Development](PLUGINS_DEV.md) (includes video)
2223
- [Settings System](SETTINGS_SYSTEM.md)
2324

2425
Focus on **core functionality** and integrate with existing tools rather than reinventing the wheel.
2526

2627
Examples:
28+
2729
- Using **Apprise** for notifications instead of implementing multiple separate gateways
2830
- Implementing **regex-based validation** instead of one-off validation for each setting
2931

front/plugins/icmp_scan/icmp.py

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,47 @@
3636

3737
def parse_scan_subnets(subnets):
3838
"""Extract subnet and interface from SCAN_SUBNETS"""
39+
3940
ranges = []
4041
interfaces = []
42+
4143
for entry in subnets:
42-
parts = entry.split("--interface=")
43-
ranges.append(parts[0].strip())
44-
if len(parts) > 1:
45-
interfaces.append(parts[1].strip())
44+
45+
# Extract interface
46+
interface_match = re.search(r'--interface=([^\s]+)', entry)
47+
interface = interface_match.group(1) if interface_match else None
48+
49+
# Extract vlan
50+
vlan_match = re.search(r'--vlan=(\d+)', entry)
51+
vlan = vlan_match.group(1) if vlan_match else None
52+
53+
# If VLAN interface exists, use it
54+
if interface and vlan:
55+
vlan_interface = f"{interface}.{vlan}"
56+
57+
if os.path.exists(f"/sys/class/net/{vlan_interface}"):
58+
interface = vlan_interface
59+
mylog('verbose', [
60+
f'[{pluginName}] Using VLAN interface: {interface}'
61+
])
62+
else:
63+
mylog('verbose', [
64+
f'[{pluginName}] VLAN interface {vlan_interface} not found, using {interface}'
65+
])
66+
67+
if interface:
68+
interfaces.append(interface)
69+
70+
# Remove interface/vlan options from subnet definition
71+
subnet = re.sub(r'\s+--interface=[^\s]+', '', entry)
72+
subnet = re.sub(r'\s+--vlan=\d+', '', subnet)
73+
74+
ranges.append(subnet.strip())
75+
76+
mylog('verbose', [f'[{pluginName}] SCAN_SUBNETS value: {subnets}'])
77+
mylog('verbose', [f'[{pluginName}] Parsed subnets: {ranges}'])
78+
mylog('verbose', [f'[{pluginName}] Parsed interfaces: {interfaces}'])
79+
4680
return ranges, interfaces
4781

4882

0 commit comments

Comments
 (0)