From 8e592614462cf081219badf61869b5fb7786c11e Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Sat, 27 Apr 2024 13:28:19 +0200 Subject: [PATCH] connections.cgi: Define colours for WG address space Signed-off-by: Michael Tremer --- html/cgi-bin/connections.cgi | 45 ++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/html/cgi-bin/connections.cgi b/html/cgi-bin/connections.cgi index 24702980c8..7f11d1ac19 100644 --- a/html/cgi-bin/connections.cgi +++ b/html/cgi-bin/connections.cgi @@ -219,6 +219,48 @@ push(@network, "224.0.0.0"); push(@masklen, "239.0.0.0"); push(@colour, $colour_multicast); +# Load the WireGuard client pool +if (-e "/var/ipfire/wireguard/settings") { + my %wgsettings = (); + + &General::readhash("/var/ipfire/wireguard/settings", \%wgsettings); + + if (defined $wgsettings{'CLIENT_POOL'}) { + my $netaddr = &Network::get_netaddress($wgsettings{'CLIENT_POOL'}); + my $netmask = &Network::get_netmask($wgsettings{'CLIENT_POOL'}); + + if (defined $netaddr && defined $netmask) { + push(@network, $netaddr); + push(@masklen, $netmask); + push(@colour, ${Header::colourwg}); + } + } +} + +# Load routed WireGuard networks +if (-e "/var/ipfire/wireguard/peers") { + my %wgpeers = (); + + # Load all peers + &General::readhasharray("/var/ipfire/wireguard/peers", \%wgpeers); + + foreach my $key (keys %wgpeers) { + my $networks = $wgpeers{$key}[6]; + + # Split the string + my @networks = split(/\|/, $networks); + + foreach my $network (@networks) { + my $netaddr = &Network::get_netaddress($network); + my $netmask = &Network::get_netmask($network); + + push(@network, $netaddr); + push(@masklen, $netmask); + push(@colour, ${Header::colourwg}); + } + } +} + # Add OpenVPN net and RED/BLUE/ORANGE entry (when appropriate) if (-e "${General::swroot}/ovpn/settings") { my %ovpnsettings = (); @@ -333,6 +375,9 @@ print < $Lang::tr{'vpn'} + + $Lang::tr{'wireguard'} + $Lang::tr{'OpenVPN'} -- 2.47.3