From patchwork Tue Apr 28 15:57:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephan Feddersen X-Patchwork-Id: 3023 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 49BRB95S5Lz3yC1 for ; Tue, 28 Apr 2020 15:57:53 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail02.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 49BRB85cVSz24k; Tue, 28 Apr 2020 15:57:52 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 49BRB837Kkz2yVL; Tue, 28 Apr 2020 15:57:52 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 49BRB63tzfz2xmp for ; Tue, 28 Apr 2020 15:57:50 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) by mail01.ipfire.org (Postfix) with ESMTPSA id 49BRB6071hzRn; Tue, 28 Apr 2020 15:57:49 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1588089470; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc; bh=74WW0rpqdbwONanlPCfjCIcefcf2QWnpLOMvIHynsa8=; b=hXXqgfEbM7ZcQGTamMgBMp7B2A6B3JWj8l606Lux6wqSMAEdHDZMCBM8ChYoNPFC+1V092 WkodQwsnEl4wwXAQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1588089470; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc; bh=74WW0rpqdbwONanlPCfjCIcefcf2QWnpLOMvIHynsa8=; b=aCUipzVaIrMAwgJqZvfaxpK+k9rz0/2VhBnwRaDmJAp/eJJlmsw9TYyj5prV9G3UhD2m9y IojuNA3oV32pFTmPtkmec+vkWdPQpDWsKDkg3Wz0h42hADOaoOu9Szr0ooFP8E/5raDKoQ vY/Va7IH22tRb1x2oKieTAYN7/8enZ8qxyPOF7HLFYddhFVf82edFTAwXZPbFSxrSRE46Q 3bLko2wVEAGoPclr4s5V/PnrzDl/7KrOdIwj1Xcrmkvu030xM7XDnSrTzxRAwV9uZWs+W5 y7BTl/ctOOI2OGayTJOlhl5AbV3qjrmUgsDUiid1W68darrx5Lh3soDaMmaPzQ== From: Stephan Feddersen To: development@lists.ipfire.org Subject: [PATCH] WIO: wio.cgi - Patch Bug 12284 - IPSec Connected since information was added Date: Tue, 28 Apr 2020 17:57:42 +0200 Message-Id: <20200428155742.8252-1-sfeddersen@ipfire.org> Authentication-Results: mail01.ipfire.org; auth=pass smtp.mailfrom=sfeddersen@ipfire.org X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stephan Feddersen Errors-To: development-bounces@lists.ipfire.org Sender: "Development" --- src/wio/wio.cgi | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/wio/wio.cgi b/src/wio/wio.cgi index 1c380b1a5..3094ec30c 100644 --- a/src/wio/wio.cgi +++ b/src/wio/wio.cgi @@ -3,7 +3,7 @@ ############################################################################### # # # IPFire.org - A linux based firewall # -# Copyright (C) 2017-2019 Stephan Feddersen # +# Copyright (C) 2017-2020 Stephan Feddersen # # All Rights Reserved. # # # # This program is free software: you can redistribute it and/or modify # @@ -21,7 +21,7 @@ # # ############################################################################### # -# Version: 2019/11/08 14:35:23 +# Version: 2020/26/04 19:35:23 # # This wio.cgi is based on the Code from the IPCop WIO Addon # and is extremly adapted to work with IPFire. @@ -1217,7 +1217,7 @@ print" foreach $key (sort SortByTunnelName (keys(%vpnconfighash))) { -my $vpncheck = ''; +my ( $vpncheck, $vpntime, $vpnclient ) = ''; if ( -e '/var/log/wio/.vpncache' ) { $vpncheck = strftime("%d.%m.%Y - %H:%M:%S",localtime(((stat('/var/log/wio/.vpncache'))[9]))); @@ -1225,6 +1225,7 @@ if ( -e '/var/log/wio/.vpncache' ) { $status = "bgcolor='${Header::colourred}'"; $statustxt = "$Lang::tr{'capsclosed'}"; +$vpnclient = $vpnconfighash{$key}[1]; if ($vpnconfighash{$key}[0] eq 'off') { $status = "bgcolor='${Header::colourblue}'"; @@ -1232,9 +1233,11 @@ $statustxt = "$Lang::tr{'capsclosed'}"; } foreach (@vpnstatus) { - if ($_ =~ /$vpnconfighash{$key}[1]\{.*INSTALLED/) { + if ($_ =~ /$vpnclient.*ESTABLISHED/) { $status = "bgcolor='${Header::colourgreen}'"; $statustxt = "$Lang::tr{'capsopen'}"; + $vpntime = `/usr/local/bin/ipsecctrl I | grep $vpnclient.*ESTABLISHED | sed 's/^[ \t]*//' | cut -d " " -f 3-4`; + $vpntime = &WIO::contime($vpntime, "ipsec"); last; } } @@ -1243,11 +1246,11 @@ $statustxt = "$Lang::tr{'capsclosed'}"; my $vpnnr = $idvpn+1; - printf (" %02d", $vpnnr); + printf ("%02d", $vpnnr); print"$vpncheck - $vpnconfighash{$key}[1] - $Lang::tr{ + $vpnclient + $Lang::tr{ ".($vpnconfighash{$key}[2] eq '%auth-dn' ? "$vpnconfighash{$key}[9]" : ($vpnconfighash{$key}[4] eq 'cert' ? "$vpnconfighash{$key}[2]" : ($vpnconfighash{$key}[8] ne '' ? "$vpnconfighash{$key}[10]" : " ")))." @@ -1256,7 +1259,7 @@ $statustxt = "$Lang::tr{'capsclosed'}";
-   + ".(defined($vpntime)? "$vpntime" : "-")." "; @@ -1335,7 +1338,7 @@ print" $tnet->open('127.0.0.1'); @output = $tnet->cmd(String => 'state', Prompt => '/(END.*\n|ERROR:.*\n)/'); @tustate = split(/\,/, $output[1]); - $ovpntime = &WIO::contime(scalar localtime($tustate[0])); + $ovpntime = &WIO::contime(scalar localtime($tustate[0]), "ovpn"); if (($tustate[1] eq 'CONNECTED')) { $status = "${Header::colourgreen}"; @@ -1356,7 +1359,7 @@ print" if ( $match[1] ne "Common Name" && ($match[1] eq $ovpnconfighash{$key}[2]) ) { $ovpnclt = $match[1]; - $ovpntime = &WIO::contime($match[5]); + $ovpntime = &WIO::contime($match[5], "ovpn"); } if ( $_ =~ /^(\d+\.\d+\.\d+\.\d+),(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(.+)/ ) { @@ -1381,12 +1384,12 @@ print" } print" - $ovpncheck - ".( defined($ovpnrwip)? "$ovpnrwip" : " ")." + ".(defined($ovpncheck)? "$ovpncheck" : "-")." + ".(defined($ovpnrwip)? "$ovpnrwip" : "-")." $text ".($ovpnconfighash{$key}[2] eq '%auth-dn' ? "$ovpnconfighash{$key}[9]" : ($ovpnconfighash{$key}[4] eq 'cert' ? "$ovpnconfighash{$key}[2]": " "))."
$statustxt
- ".(defined($ovpntime)? "$ovpntime" : " ")." + ".(defined($ovpntime)? "$ovpntime" : "-")." "; if ($ovpnconfighash{$key}[25] && $wiosettings{'CLIENTREMARK'} eq 'on') {