-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix-vlan-interface.patch
More file actions
51 lines (50 loc) · 1.99 KB
/
fix-vlan-interface.patch
File metadata and controls
51 lines (50 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
--- a/server.js
+++ b/server.js
@@ -6797,21 +6797,37 @@ app.get('/api/mac/search/hybrid', async (req, res) => {
if (localResults.length > 0) {
const best = localResults[0];
- result.source = 'local-db';
- result.found = true;
- result.endpoint = {
- device: best.device,
- deviceIp: best.device_ip,
- ifName: best.interface,
- vlan: best.vlan,
- source: 'local-nodes'
- };
+ const bestIsPhysical = isPhysicalPort(best.interface);
+
+ // Salva i risultati DB
result.dbResult = {
local: { count: localResults.length, data: localResults }
};
- result.elapsed = `${Date.now() - t0}ms`;
- console.log(`[MAC-HYBRID] Found in LOCAL DB: ${result.endpoint?.device} ${result.endpoint?.ifName} (${localElapsed}ms)`);
- return res.json(result);
+
+ // Se la migliore porta è FISICA, restituisci subito
+ if (bestIsPhysical) {
+ result.source = 'local-db';
+ result.found = true;
+ result.endpoint = {
+ device: best.device,
+ deviceIp: best.device_ip,
+ ifName: best.interface,
+ vlan: best.vlan,
+ source: 'local-nodes'
+ };
+ result.elapsed = `${Date.now() - t0}ms`;
+ console.log(`[MAC-HYBRID] Found PHYSICAL PORT in LOCAL DB: ${result.endpoint?.device} ${result.endpoint?.ifName} (${localElapsed}ms)`);
+ return res.json(result);
+ }
+
+ // Se è VLAN interface, salva info e continua per trovare porta fisica
+ console.log(`[MAC-HYBRID] Local DB has only VLAN interface (${best.interface}), continuing to find physical port...`);
+ result.vlanResult = {
+ device: best.device,
+ deviceIp: best.device_ip,
+ vlanInterface: best.interface,
+ vlan: best.vlan
+ };
}
} catch (localErr) {