forcegraph, main: l2tp support

This commit is contained in:
Milan Pässler 2016-04-24 01:02:17 +02:00
parent 2a78af4208
commit 2f28c51da1
2 changed files with 15 additions and 11 deletions

View File

@ -214,7 +214,7 @@ define(["d3"], function (d3) {
function drawLabel(d) { function drawLabel(d) {
var neighbours = d.neighbours.filter(function (d) { var neighbours = d.neighbours.filter(function (d) {
return d.link.o.type !== "VPN" return d.link.o.type !== "fastd" && d.link.o.type !== "L2TP"
}) })
var sum = neighbours.reduce(function (a, b) { var sum = neighbours.reduce(function (a, b) {
@ -332,8 +332,8 @@ define(["d3"], function (d3) {
ctx.moveTo(d.source.x + dx * nodeRadius, d.source.y + dy * nodeRadius) ctx.moveTo(d.source.x + dx * nodeRadius, d.source.y + dy * nodeRadius)
ctx.lineTo(d.target.x - dx * nodeRadius, d.target.y - dy * nodeRadius) ctx.lineTo(d.target.x - dx * nodeRadius, d.target.y - dy * nodeRadius)
ctx.strokeStyle = d.o.type === "Kabel" ? cableColor : d.color ctx.strokeStyle = d.o.type === "Kabel" ? cableColor : d.color
ctx.globalAlpha = d.o.type === "VPN" ? 0.1 : 0.8 ctx.globalAlpha = d.o.type === "fastd" || d.o.type === "L2TP" ? 0.1 : 0.8
ctx.lineWidth = d.o.type === "VPN" ? 1.5 : 2.5 ctx.lineWidth = d.o.type === "fastd" || d.o.type === "L2TP" ? 1.5 : 2.5
ctx.stroke() ctx.stroke()
}) })
@ -523,7 +523,7 @@ define(["d3"], function (d3) {
} }
var links = intLinks.filter(function (d) { var links = intLinks.filter(function (d) {
return d.o.type !== "VPN" return d.o.type !== "fastd" && d.o.type !== "L2TP"
}).filter(function (d) { }).filter(function (d) {
return distanceLink(e, d.source, d.target) < LINE_RADIUS return distanceLink(e, d.source, d.target) < LINE_RADIUS
}) })
@ -584,13 +584,13 @@ define(["d3"], function (d3) {
.charge(-250) .charge(-250)
.gravity(0.1) .gravity(0.1)
.linkDistance(function (d) { .linkDistance(function (d) {
if (d.o.type === "VPN") if (d.o.type === "fastd" || d.o.type === "L2TP")
return 0 return 0
else else
return LINK_DISTANCE return LINK_DISTANCE
}) })
.linkStrength(function (d) { .linkStrength(function (d) {
if (d.o.type === "VPN") if (d.o.type === "fastd" || d.o.type === "L2TP")
return 0 return 0
else else
return Math.max(0.5, 1 / d.o.tq) return Math.max(0.5, 1 / d.o.tq)
@ -644,7 +644,7 @@ define(["d3"], function (d3) {
e.source = newNodesDict[d.source.id] e.source = newNodesDict[d.source.id]
e.target = newNodesDict[d.target.id] e.target = newNodesDict[d.target.id]
if (d.type === "VPN") if (d.type === "fastd" || d.type === "L2TP")
e.color = "rgba(255, 255, 255, " + (0.6 / d.tq) + ")" e.color = "rgba(255, 255, 255, " + (0.6 / d.tq) + ")"
else else
e.color = linkScale(d.tq).hex() e.color = linkScale(d.tq).hex()

View File

@ -113,9 +113,13 @@ function (moment, Router, L, GUI, numeral) {
}) })
links.forEach( function (d) { links.forEach( function (d) {
if (d.type === "tunnel") console.log(d)
d.type = "VPN" if (d.type === "tunnel" || d.type === "fastd")
else if (d.type === "wireless") d.type = "fastd"
else if (d.type === "l2tp") {
d.type = "L2TP"
d.target.node.flags.uplink = true
} else if (d.type === "wireless")
d.type = "Wifi" d.type = "Wifi"
else if (d.type === "other") else if (d.type === "other")
d.type = "Kabel" d.type = "Kabel"
@ -128,7 +132,7 @@ function (moment, Router, L, GUI, numeral) {
} }
d.source.node.neighbours.push({ node: d.target.node, link: d, incoming: false }) 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 }) d.target.node.neighbours.push({ node: d.source.node, link: d, incoming: true })
if (d.type !== "VPN") if (d.type !== "fastd" && d.type !== "L2TP")
d.source.node.meshlinks = d.source.node.meshlinks ? d.source.node.meshlinks + 1 : 1 d.source.node.meshlinks = d.source.node.meshlinks ? d.source.node.meshlinks + 1 : 1
}) })