fix unmatches, add hybrid, trunk
This commit is contained in:
parent
13d2930898
commit
bc1756ad19
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
confs/
|
26
style.css
26
style.css
@ -9,11 +9,13 @@ main > table {
|
||||
margin: auto;
|
||||
}
|
||||
.member {
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0;
|
||||
margin: 0;
|
||||
border: 4px solid #335;
|
||||
}
|
||||
.vlans {
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0;
|
||||
/*! border-collapse: collapse; */
|
||||
}
|
||||
.member td,
|
||||
.vlans td {
|
||||
@ -24,11 +26,29 @@ main > table {
|
||||
min-width: 2em;
|
||||
height: 2em;
|
||||
mix-blend-mode: darken;
|
||||
padding: 3px;
|
||||
}
|
||||
.access,
|
||||
.pvid {
|
||||
background-color: hsl(var(--pvid) 100% 58%);
|
||||
background-color: hsl(var(--pvid) 100% 65%);
|
||||
}
|
||||
.trunk {
|
||||
position: relative;
|
||||
font-weight: bold;
|
||||
border: 5px solid !important;
|
||||
border-width: 5px !important;
|
||||
border-image-slice: 1 !important;
|
||||
border-image-source: linear-gradient(127deg, red, orange, yellow, green, blue, violet) !important;
|
||||
padding: 0;
|
||||
|
||||
}
|
||||
.hybrid {
|
||||
background-image: linear-gradient(135deg, hsl(var(--tagged) 100% 65%) 1.6rem, hsl(var(--untagged) 100% 65%) 1.6rem);
|
||||
}
|
||||
.shutdown {
|
||||
background-color: lightgray;
|
||||
color: gray;
|
||||
}
|
||||
td {
|
||||
text-align: left
|
||||
}
|
||||
|
48
vlans.php
48
vlans.php
@ -10,17 +10,20 @@ $conf = file_get_contents($path);
|
||||
|
||||
preg_match("/ sysname ([\w-]+)/", $conf, $sysname);
|
||||
preg_match("/ip address ([\d.]+)/", $conf, $address);
|
||||
preg_match_all("/\nvlan (?P<pvid>\d+)(?:[\r\n]+ name (?P<name>.+))?(?:[\r\n]+ description (?P<description>.*))?/", $conf, $vlans, PREG_SET_ORDER);
|
||||
preg_match_all("/\n(?P<conf>(?P<name>interface [\w-]+(?:[\r\n]+ .*)*(?P<member>\d+)\/0\/(?P<port>\d+))[\r\n]+(?: description (?P<description>.*))?[\r\n]+(?P<shutdown> shutdown[\r\n]+)?(?: port access vlan (?P<pvid>\d+)[\r\n]+| .*[\r\n]+)*)/", $conf, $interfaces, PREG_SET_ORDER);
|
||||
|
||||
preg_match_all("/(?<=\n)vlan (?P<pvid>\d+)[\r\n]+(?: name (?P<name>.+)[\r\n]+| description (?P<description>.+)[\r\n]+| .*[\r\n]+)*/", $conf, $vlans, PREG_SET_ORDER);
|
||||
preg_match_all("/(?<=\n)interface [\w-]+(?P<member>\d+)\/0\/(?P<port>\d+)[\r\n]+(?: port hybrid vlan (?P<tagged>\d+) tagged[\r\n]+| port hybrid vlan (?P<untagged>\d+)(?: \d+)* untagged[\r\n]+| port (?P<linktype>access|trunk pvid|hybrid pvid) vlan (?P<pvid>\d+)[\r\n]+| (?P<shutdown>shutdown)[\r\n]+| .*[\r\n]+)*/", $conf, $interfaces, PREG_SET_ORDER);
|
||||
$stack = array();
|
||||
foreach ($interfaces as $interface) {
|
||||
if (!$stack[$interface["member"]]) {
|
||||
if (!isset($stack[$interface["member"]])) {
|
||||
$stack[$interface["member"]] = array();
|
||||
}
|
||||
$stack[$interface["member"]][$interface["port"]] = $interface;
|
||||
}
|
||||
|
||||
echo "<!--\n";
|
||||
print_r($vlans);
|
||||
print_r($stack);
|
||||
echo "-->\n";
|
||||
?>
|
||||
<!DOCTYPE HTML>
|
||||
<html lang='fr'>
|
||||
@ -32,7 +35,7 @@ foreach ($interfaces as $interface) {
|
||||
<header>
|
||||
<h1>
|
||||
<div><?=$sysname[1]?></div>
|
||||
<div><small><a href="https://<?=$address[1]?>" target="_blank"><?=$address[1]?></a></small></div>
|
||||
<small><a href="https://<?=$address[1]?>" target="_blank"><?=$address[1]?></a></small>
|
||||
</h1>
|
||||
</header>
|
||||
<main>
|
||||
@ -40,36 +43,43 @@ foreach ($interfaces as $interface) {
|
||||
<caption><h2>Interfaces</h2></caption>
|
||||
<tbody>
|
||||
<?php
|
||||
function display_port($interface, $odd) {
|
||||
if ($interface["port"] % 2) {
|
||||
$shutdown = (isset($interface["shutdown"]) and $interface["shutdown"]) ? "shutdown" : "";
|
||||
$linktype = (isset($interface["linktype"]) and $interface["linktype"]) ? $interface["linktype"] : "";
|
||||
$tagged = (isset($interface["tagged"]) and $interface["tagged"]) ? $interface["tagged"] : "0";
|
||||
$untagged = (isset($interface["untagged"]) and $interface["untagged"]) ? $interface["untagged"] : "0";
|
||||
$pvid = (isset($interface["pvid"]) and $interface["pvid"]) ? $interface["pvid"] : "0";
|
||||
echo "<td class='number $shutdown $linktype' title='${interface[0]}' style='--tagged: $tagged; --untagged: $untagged; --pvid: $pvid'>${interface["port"]}</td>\n";
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($stack as $member => $interfaces) {
|
||||
echo "<tr>\n<th>$member</th>\n<td>\n<table class='member'>\n<tbody>\n<tr>\n";
|
||||
foreach ($interfaces as $interface) {
|
||||
if ($interface["port"] % 2) {
|
||||
echo "<td class='number ".($interface["shutdown"]? "shutdown" : "pvid")."' title='".$interface["conf"]."' style='--pvid: ".$interface["pvid"]."'>".$interface["port"]."</td>\n";
|
||||
}
|
||||
}
|
||||
foreach ($interfaces as $interface) display_port($interface, 1);
|
||||
echo "</tr>\n<tr>\n";
|
||||
foreach ($interfaces as $interface) {
|
||||
if ($interface["port"] % 2 == 0) {
|
||||
echo "<td class='number ".($interface["shutdown"]? "shutdown" : "pvid")."' title='".$interface["conf"]."' style='--pvid: ".$interface["pvid"]."'>".$interface["port"]."</td>\n";
|
||||
}
|
||||
}
|
||||
foreach ($interfaces as $interface) display_port($interface, 0);
|
||||
echo "</tr>\n</tbody>\n</table>\n</td>\n</tr>\n";
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class='vlans'>
|
||||
<caption><h2>VLANs</h2></caption>
|
||||
<caption><h2>Légende</h2></caption>
|
||||
<thead><tr><th>PVID</th><th>Nom</th><th>Description</th></tr></thead>
|
||||
<tbody>
|
||||
<?php
|
||||
foreach ($vlans as $vlan) {
|
||||
if ($vlan["pvid"] != 1) {
|
||||
echo "<tr><td class='number pvid' style='--pvid: ${vlan["pvid"]}'>${vlan["pvid"]}</td><td>${vlan["name"]}</td><td>${vlan["description"]}</td></tr>";
|
||||
if (isset($vlan["pvid"]) and $vlan["pvid"] != 1) {
|
||||
$name = isset($vlan["name"]) ? $vlan["name"] : "";
|
||||
$description = isset($vlan["description"]) ? $vlan["description"] : "";
|
||||
echo "<tr title='${vlan[0]}'><td class='number pvid' style='--pvid: ${vlan["pvid"]}'>${vlan["pvid"]}</td><td>$name</td><td>$description</td></tr>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
<tr><td class='number shutdown'></td><td colspan='2'>Interface désactivée</td></tr>
|
||||
<tr><td class='number trunk'>T</td><td colspan='2'>Trunk</td></tr>
|
||||
<tr><td class='number hybrid' style='--tagged:60; --untagged:0'>H</td><td colspan='2'>Hybride (tagged/untagged)</td></tr>
|
||||
<tr><td class='number shutdown'>S</td><td colspan='2'>Interface désactivée</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</main>
|
||||
|
Loading…
x
Reference in New Issue
Block a user