From patchwork Tue Apr 28 16:04:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephan Feddersen X-Patchwork-Id: 3024 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 49BRL95Cz3z3xQy for ; Tue, 28 Apr 2020 16:04:49 +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 49BRL66zBCz24k; Tue, 28 Apr 2020 16:04:46 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 49BRL64yYVz2yTF; Tue, 28 Apr 2020 16:04:46 +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 49BRL45nRdz2xmp for ; Tue, 28 Apr 2020 16:04:44 +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 49BRL372P4z1vv; Tue, 28 Apr 2020 16:04:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1588089884; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc; bh=svWqSc6qzFmc8rR1olFcK5TCjOx5RM88y/ccA0J4Ktg=; b=ceVQKsSOpHjS+dSbkc3Q0QzB/kmf0DQa3EheFDG9B0AldkEt2SWUcnhAXqJRH0ZJiFWaaI Nd+/wFhRnKdw5JO+wFqbaJuacyC7BmTDLx5d5a6ZWhMsYSTDLD8Vv3/vyu4cw+H0zusgYk /zs1fmmqP9ylgUs/ejKEpFspL3DfD4lKniMXjpKCIazpfgl9QyC68qQ+wDVyD0oZorwt8A ACt5bj0ikrxP8bXBGcBrV3E6yQ0k4qU6ZEi7lKQ4BtYVsfSTFmgaTkHYxqgaPG7280JxGp SxfBLX85LSyiwPsiBKhTzUvL4v6MChOrjBWBsNyQ6wmHxX2L7UeuHvT+FqGCwg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1588089884; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc; bh=svWqSc6qzFmc8rR1olFcK5TCjOx5RM88y/ccA0J4Ktg=; b=ZfXEez2NXbh6kv5P5rRvmuepEknO/EurgcSXYAn9UU6ZfD97pAvFH9gGUtaOegdYfwcBOT BUDP2tHfx4b2c+BQ== From: Stephan Feddersen To: development@lists.ipfire.org Subject: [PATCH] WIO: wio-lib.pl - Patch Bug 12284 - IPSec Connected since information was added Date: Tue, 28 Apr 2020 18:04:33 +0200 Message-Id: <20200428160433.8398-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-lib.pl | 46 +++++++++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 13 deletions(-) diff --git a/src/wio/wio-lib.pl b/src/wio/wio-lib.pl index bbaf0bf4a..1ff7cfacc 100644 --- a/src/wio/wio-lib.pl +++ b/src/wio/wio-lib.pl @@ -3,7 +3,7 @@ ############################################################################### # # # IPFire.org - A linux based firewall # -# Copyright (C) 2017-2018 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: 2017/07/11 21:32:23 +# Version: 2020/26/04 19:35:23 # # This wio-lib.pl is based on the Code from the IPCop WIO Addon # and is extremly adapted to work with IPFire. @@ -47,10 +47,8 @@ require '/var/ipfire/lang.pl'; my $mailfile = "${General::swroot}/dma/mail.conf"; my %mail = (); -&General::readhash($mailfile, \%mail); -my $redactive = "/var/ipfire/red/active"; -my $msg = ''; +&General::readhash($mailfile, \%mail); ############################################################################################################################ @@ -59,7 +57,7 @@ sub getdyndnsip { my $host = $_[1]; my @fetchip = (); - if ( -e $redactive ) { + if ( -e "/var/ipfire/red/active" ) { @fetchip = gethostbyname($host); if ( defined($fetchip[0]) ) { @@ -75,17 +73,37 @@ sub getdyndnsip { ############################################################################################################################ sub contime { - my $str = $_[0]; + chomp(my $str = $_[0]); + chomp(my $vpn = $_[1]); + my %m = (); @m{qw/Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec/} = (0 .. 11); - if ( $str =~ /^\w{3}\ ([a-zA-Z]+)\ (\d{1,2})\ (\d{2})\:(\d{2})\:(\d{2}) (\d{4})$/ || - $str =~ /^\w{3}\ ([a-zA-Z]+)\ (\d{1})\ (\d{2})\:(\d{2})\:(\d{2}) (\d{4})$/ ) - { - my $past = timelocal($5, $4, $3, $2, $m{$1}, $6); - my $now = time; + my $totalsecs = ''; + + if ( $vpn eq 'ipsec' ) { + my @temp = split (/ /, $str); + + if ( $temp[1] eq 'seconds' ) { + $totalsecs = $temp[0]; + } + + if ( $temp[1] eq 'minutes' ) { + $totalsecs = $temp[0] * 60; + } + } - my $totalsecs = $now - $past; + if ( $vpn eq 'ovpn' ) { + if ( $str =~ /^\w{3}\ ([a-zA-Z]+)\ (\d{1,2})\ (\d{2})\:(\d{2})\:(\d{2}) (\d{4})$/ || + $str =~ /^\w{3}\ ([a-zA-Z]+)\ (\d{1})\ (\d{2})\:(\d{2})\:(\d{2}) (\d{4})$/ ) + { + my $past = timelocal($5, $4, $3, $2, $m{$1}, $6); + my $now = time; + $totalsecs = $now - $past; + } + } + + if ( $totalsecs ne '' ) { my $days = int($totalsecs / 86400); my $totalhours = int($totalsecs / 3600); my $hours = $totalhours % 24; @@ -126,6 +144,8 @@ sub statustime { ############################################################################################################################ sub mailsender { + my $msg = ''; + $msg = MIME::Lite->new( From => $mail{'SENDER'}, To => $mail{'RECIPIENT'},