From acb305f590ce401aa69898761c761cd24a4c9d18 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Thu, 19 Jul 2012 12:28:12 +0200 Subject: [PATCH] index.cgi: Print OpenVPN N2N status in the same way as IPsec connections. --- html/cgi-bin/index.cgi | 76 ++++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 36 deletions(-) diff --git a/html/cgi-bin/index.cgi b/html/cgi-bin/index.cgi index 01bb3d6850..04a87cf630 100644 --- a/html/cgi-bin/index.cgi +++ b/html/cgi-bin/index.cgi @@ -394,48 +394,52 @@ END } ### -# m.a.d n2n +# Print the OpenVPN N2N connection status. ### - if ( -d "${General::swroot}/ovpn/n2nconf") { -my %confighash=(); -my $display = ''; - -&General::readhasharray("${General::swroot}/ovpn/ovpnconfig", \%confighash); -foreach my $dkey (keys %confighash) { -if ($confighash{$dkey}[3] eq 'net') { - - - if (-e "/var/run/$confighash{$dkey}[1]n2n.pid") { - my @output = ""; - my @tustate = ""; - my $tport = $confighash{$dkey}[22]; - my $tnet = new Net::Telnet ( Timeout=>5, Errmode=>'return', Port=>$tport); - if ($tport ne '') { - $tnet->open('127.0.0.1'); - @output = $tnet->cmd(String => 'state', Prompt => '/(END.*\n|ERROR:.*\n)/'); - @tustate = split(/\,/, $output[1]); - if ( $tustate[1] eq 'CONNECTED') - { $display = "$Lang::tr{'capsopen'}"; - } else { - $display = "$tustate[1]"; } + my %confighash=(); + + &General::readhasharray("${General::swroot}/ovpn/ovpnconfig", \%confighash); + foreach my $dkey (keys %confighash) { + if (($confighash{$dkey}[3] eq 'net') && (-e "/var/run/$confighash{$dkey}[1]n2n.pid")) { + my $tport = $confighash{$dkey}[22]; + next if ($tport eq ''); + + my $tnet = new Net::Telnet ( Timeout=>5, Errmode=>'return', Port=>$tport); + $tnet->open('127.0.0.1'); + my @output = $tnet->cmd(String => 'state', Prompt => '/(END.*\n|ERROR:.*\n)/'); + my @tustate = split(/\,/, $output[1]); + + my $display; + my $display_colour = $Header::colourred; + if ( $tustate[1] eq 'CONNECTED') { + $display_colour = $Header::colourgreen; + $display = $Lang::tr{'capsopen'}; + } else { + $display = $tustate[1]; + } - print <OpenVPN n2n
- $confighash{$dkey}[10] $display - + print < + + $confighash{$dkey}[1] + + + $confighash{$dkey}[11] + + + + + $display + + + + END -; -} -} -} -} + } + } } -### -# m.a.d n2n end -### - # Fireinfo if ( ! -e "/var/ipfire/main/send_profile") { $warnmessage .= "
  • $Lang::tr{'fireinfo please enable'}
  • "; -- 2.39.5