pkgs/gateway-report: init
This commit is contained in:
parent
db2d0537e3
commit
8e3ca3bc7c
|
@ -100,6 +100,10 @@ let
|
||||||
inherit self nixpkgs system;
|
inherit self nixpkgs system;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
gateway-report = import ./gateway-report.nix {
|
||||||
|
inherit self nixpkgs system;
|
||||||
|
};
|
||||||
|
|
||||||
vlan-report = import ./vlan-report.nix {
|
vlan-report = import ./vlan-report.nix {
|
||||||
inherit self nixpkgs system;
|
inherit self nixpkgs system;
|
||||||
};
|
};
|
||||||
|
@ -111,6 +115,6 @@ in
|
||||||
rootfs-packages // vm-packages // device-templates // openwrt-packages // network-graphs // network-cypher-graphs // starlink // subnetplans // {
|
rootfs-packages // vm-packages // device-templates // openwrt-packages // network-graphs // network-cypher-graphs // starlink // subnetplans // {
|
||||||
inherit export-openwrt-models export-config dns-slaves
|
inherit export-openwrt-models export-config dns-slaves
|
||||||
encrypt-secrets decrypt-secrets switch-to-production
|
encrypt-secrets decrypt-secrets switch-to-production
|
||||||
homepage vlan-report
|
homepage gateway-report vlan-report
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,111 @@
|
||||||
|
{ self, nixpkgs, system }:
|
||||||
|
with nixpkgs.legacyPackages.${system};
|
||||||
|
let
|
||||||
|
config = self.lib.config;
|
||||||
|
|
||||||
|
in
|
||||||
|
writeText "vlan-report.md" ''
|
||||||
|
# Gateway Report
|
||||||
|
|
||||||
|
${lib.concatMapStrings (net:
|
||||||
|
let
|
||||||
|
netConfig = config.site.net.${net};
|
||||||
|
|
||||||
|
routers4 = builtins.filter (hostName:
|
||||||
|
config.site.hosts ? ${hostName} &&
|
||||||
|
config.site.hosts.${hostName}.isRouter
|
||||||
|
) (
|
||||||
|
builtins.attrNames netConfig.hosts4
|
||||||
|
);
|
||||||
|
|
||||||
|
routers6 = builtins.filter (hostName:
|
||||||
|
config.site.hosts ? ${hostName} &&
|
||||||
|
config.site.hosts.${hostName}.isRouter
|
||||||
|
) (lib.unique (
|
||||||
|
builtins.concatMap builtins.attrNames (builtins.attrValues netConfig.hosts6)
|
||||||
|
));
|
||||||
|
|
||||||
|
upstreamAt = l: n:
|
||||||
|
if n < builtins.length l
|
||||||
|
then
|
||||||
|
let
|
||||||
|
hostName = builtins.elemAt l n;
|
||||||
|
hostConfig = config.site.hosts.${hostName};
|
||||||
|
providers =
|
||||||
|
map ({ upstream, ... }: upstream.provider) (
|
||||||
|
builtins.filter ({ upstream, ... }:
|
||||||
|
upstream.provider or null != null
|
||||||
|
) (builtins.attrValues hostConfig.interfaces)
|
||||||
|
);
|
||||||
|
in
|
||||||
|
"${hostName}${
|
||||||
|
lib.optionalString (providers != []) " (${lib.concatStringsSep ", " providers})"
|
||||||
|
}"
|
||||||
|
else "";
|
||||||
|
|
||||||
|
in
|
||||||
|
lib.optionalString (net != "core" && (routers4 != [] || routers6 != [])) ''
|
||||||
|
## Network ${net}
|
||||||
|
|
||||||
|
${lib.optionalString (routers4 != []) ''
|
||||||
|
### IPv4 `${netConfig.subnet4}`
|
||||||
|
|
||||||
|
| Address | Name | Upstream | Fallback |
|
||||||
|
|-|-|-|-|
|
||||||
|
${lib.concatMapStrings (hostName:
|
||||||
|
let
|
||||||
|
hostConfig = config.site.hosts.${hostName};
|
||||||
|
isDhcpDefault = hostName == netConfig.dhcp.router or null;
|
||||||
|
upstream4a = upstreamAt hostConfig.ospf.allowedUpstreams 0;
|
||||||
|
upstream4b = upstreamAt hostConfig.ospf.allowedUpstreams 1;
|
||||||
|
in ''
|
||||||
|
|`${
|
||||||
|
netConfig.hosts4.${hostName}
|
||||||
|
}`|${
|
||||||
|
if isDhcpDefault
|
||||||
|
then "**${hostName}**"
|
||||||
|
else hostName
|
||||||
|
}|${
|
||||||
|
upstream4a
|
||||||
|
}|${
|
||||||
|
upstream4b
|
||||||
|
}|
|
||||||
|
''
|
||||||
|
) (lib.naturalSort routers4)}
|
||||||
|
''}
|
||||||
|
|
||||||
|
${lib.optionalString (routers6 != {}) ''
|
||||||
|
### IPv6: ${lib.concatStringsSep " " (
|
||||||
|
map (s: "`${s}`") (
|
||||||
|
builtins.attrValues netConfig.subnets6
|
||||||
|
)
|
||||||
|
)}
|
||||||
|
|
||||||
|
| Address | Name | Upstream | Description |
|
||||||
|
|-|-|-|-|
|
||||||
|
${lib.concatMapStrings (hostName:
|
||||||
|
let
|
||||||
|
hostConfig = config.site.hosts.${hostName};
|
||||||
|
upstream6a = upstreamAt hostConfig.ospf.allowedUpstreams6 0;
|
||||||
|
upstream6b = upstreamAt hostConfig.ospf.allowedUpstreams6 1;
|
||||||
|
in ''
|
||||||
|
|${
|
||||||
|
lib.concatMapStringsSep " " (ctx:
|
||||||
|
"`${netConfig.hosts6.${ctx}.${hostName}}`"
|
||||||
|
) (builtins.filter (ctx:
|
||||||
|
netConfig.hosts6.${ctx} ? ${hostName}
|
||||||
|
) (builtins.attrNames netConfig.hosts6))
|
||||||
|
}|${
|
||||||
|
hostName
|
||||||
|
}|${
|
||||||
|
upstream6a
|
||||||
|
}|${
|
||||||
|
upstream6b
|
||||||
|
}|
|
||||||
|
''
|
||||||
|
) (lib.naturalSort routers6)}
|
||||||
|
''}
|
||||||
|
|
||||||
|
''
|
||||||
|
) (lib.naturalSort (builtins.attrNames config.site.net))}
|
||||||
|
''
|
|
@ -7,7 +7,9 @@
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
inherit (self.packages.${system}) network-graphs subnetplans vlan-report;
|
inherit (self.packages.${system})
|
||||||
|
gateway-report network-graphs
|
||||||
|
subnetplans vlan-report;
|
||||||
|
|
||||||
in
|
in
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
|
@ -22,6 +24,7 @@ stdenv.mkDerivation {
|
||||||
buildPhase = ''
|
buildPhase = ''
|
||||||
pandoc -t html ${../../../doc/hello.md} > index.html
|
pandoc -t html ${../../../doc/hello.md} > index.html
|
||||||
pandoc -t html ${vlan-report} > vlan-report.html
|
pandoc -t html ${vlan-report} > vlan-report.html
|
||||||
|
pandoc -t html ${gateway-report} > gateway-report.html
|
||||||
ln -s ${substituteAll {
|
ln -s ${substituteAll {
|
||||||
src = ./figure.html;
|
src = ./figure.html;
|
||||||
img = "physical.png";
|
img = "physical.png";
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
<nav>
|
<nav>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="index.html">Willkommen</a></li>
|
<li><a href="index.html">Willkommen</a></li>
|
||||||
|
<li><a href="gateway-report.html">Router-Adressen</a></li>
|
||||||
<li><a href="subnetplan4.html">IPv4-Plan</a></li>
|
<li><a href="subnetplan4.html">IPv4-Plan</a></li>
|
||||||
<li><a href="subnetplan6.html">IPv6-Plan</a></li>
|
<li><a href="subnetplan6.html">IPv6-Plan</a></li>
|
||||||
<li><a href="vlan-report.html">VLAN-Belegungen</a></li>
|
<li><a href="vlan-report.html">VLAN-Belegungen</a></li>
|
||||||
|
|
|
@ -75,4 +75,19 @@ main figure img {
|
||||||
|
|
||||||
main table {
|
main table {
|
||||||
font-size: 75%;
|
font-size: 75%;
|
||||||
|
border-collapse: collapse;
|
||||||
|
border: 1px solid #555;
|
||||||
|
}
|
||||||
|
main table th {
|
||||||
|
background-color: #555;
|
||||||
|
color: #FFF;
|
||||||
|
padding: 0.4rem;
|
||||||
|
}
|
||||||
|
main table td {
|
||||||
|
border: 1px solid #555;
|
||||||
|
padding: 0.2rem 0.4rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
main h3 code {
|
||||||
|
margin-left: 0.6rem;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue