From 4b2c5e9157e26dbe319ddce9408004090d2bbfe4 Mon Sep 17 00:00:00 2001 From: Martin Geno Date: Sun, 19 Mar 2017 00:21:58 +0100 Subject: [PATCH] [TASK] Decrease condition to detect vpn links --- lib/forcegraph.js | 4 ++-- lib/forcegraph/draw.js | 6 ++---- lib/main.js | 8 +------- lib/map.js | 4 ++-- 4 files changed, 7 insertions(+), 15 deletions(-) diff --git a/lib/forcegraph.js b/lib/forcegraph.js index beaf9d2..30843cc 100644 --- a/lib/forcegraph.js +++ b/lib/forcegraph.js @@ -86,13 +86,13 @@ define(['d3-selection', 'd3-force', 'd3-zoom', 'd3-drag', 'utils/math', 'forcegr forceLink = d3Force.forceLink() .distance(function (d) { - if (d.o.type === 'fastd' || d.o.type === 'L2TP') { + if (d.o.vpn) { return 0; } return 75; }) .strength(function (d) { - if (d.o.type === 'fastd' || d.o.type === 'L2TP') { + if (d.o.vpn) { return 0.02; } return Math.max(0.5, 1 / d.o.tq); diff --git a/lib/forcegraph/draw.js b/lib/forcegraph/draw.js index 3e66442..62b0eff 100644 --- a/lib/forcegraph/draw.js +++ b/lib/forcegraph/draw.js @@ -11,8 +11,6 @@ define(['helper'], function (helper) { var nodeColor = '#fff'; var clientColor = '#e6324b'; - - var cableColor = '#50b0f0'; var highlightColor = 'rgba(255, 255, 255, 0.2)'; var labelColor = '#fff'; @@ -88,8 +86,8 @@ define(['helper'], function (helper) { to = drawHighlightLink(d, to); ctx.lineTo(to[0], to[1]); - ctx.strokeStyle = d.o.type === 'Kabel' ? cableColor : d.color; - if (d.o.type === 'fastd' || d.o.type === 'L2TP') { + ctx.strokeStyle = d.color; + if (d.o.vpn) { ctx.globalAlpha = 0.2; ctx.lineWidth = 1.5; } else { diff --git a/lib/main.js b/lib/main.js index d9c8042..b1f68c9 100644 --- a/lib/main.js +++ b/lib/main.js @@ -96,16 +96,10 @@ define(['polyglot', 'moment', 'router', 'leaflet', 'gui', 'helper', 'language'], d.target.node.neighbours.push({ id: d.source.id, link: d, incoming: true }); ids = [d.source.id.replace(/:/g, ''), d.target.node.nodeinfo.node_id]; } else { - if (d.target.node.flags.gateway === true || d.source.node.flags.gateway === true) { - d.type = 'fastd'; - } else { - d.type = 'N/A'; - } - ids = [d.source.node.nodeinfo.node_id, d.target.node.nodeinfo.node_id]; d.source.node.neighbours.push({ node: d.target.node, link: d, incoming: false }); d.target.node.neighbours.push({ node: d.source.node, link: d, incoming: true }); - if (d.type !== 'fastd' && d.type !== 'L2TP') { + if (d.vpn) { d.source.node.meshlinks = d.source.node.meshlinks ? d.source.node.meshlinks + 1 : 1; } } diff --git a/lib/map.js b/lib/map.js index 20a1a5e..1210838 100644 --- a/lib/map.js +++ b/lib/map.js @@ -87,12 +87,12 @@ define(['map/clientlayer', 'map/labellayer', 'leaflet', 'moment', 'map/locationm function addLinksToMap(dict, linkScale, graph, router) { graph = graph.filter(function (d) { - return 'distance' in d && d.type !== 'VPN'; + return 'distance' in d && !d.vpn; }); return graph.map(function (d) { var opts = { - color: d.type === 'Kabel' ? '#50B0F0' : linkScale(1 / d.tq), + color: linkScale(1 / d.tq), weight: 4, opacity: 0.5, dashArray: 'none'