From patchwork Mon May 25 09:17:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tremer X-Patchwork-Id: 3127 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) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail01.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 49Vs23548Wz3xQr for ; Mon, 25 May 2020 09:17:47 +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) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail02.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 49Vs212nWdz1SP; Mon, 25 May 2020 09:17:45 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 49Vs2068Thz2yNV; Mon, 25 May 2020 09:17:44 +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 49Vs1y3KT2z2xpX for ; Mon, 25 May 2020 09:17:42 +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 49Vs1x0FmGz1S5; Mon, 25 May 2020 09:17:40 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1590398261; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc; bh=5OGL8bWKcKYm0ejjBLY6b4VwfhEO3qGt9EMiyvIeXtE=; b=JK1H72R9B8Np3xCPTcIEjVPtv+pIsgpiALPh9E2zs09c/8VR9nxbKw4nzYYObWHPlbXccp GFhYKollJoZ1ScAg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1590398261; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc; bh=5OGL8bWKcKYm0ejjBLY6b4VwfhEO3qGt9EMiyvIeXtE=; b=g1EmcAr72wKDD2iO7QkFvVwUXtZrE1GJunGxSgLZ2Bzu8pg/wMGEK/6KRY4E23LWbfjdch gXhOEUyWre1qk8eG8G3eKJhPFHOzSP5M7k8gcUCD6kyBi8bkqpH6zAgh2WsYEnws3Waf9C lvZXwIUx3x05hSXzWyfFV74zVkMbKiHxHXg+Rw4R124GYeDFXFW8xPyqJ2ehr2kotBubJc HMwxtfkYBIr9g28vqnNRlbpQ7hZPlELXcT34sXXAJbEKo1TJOQq6IKlSHHYlEsqdZx6N/y UmrsRSKhPzSrsNIS21i4He3ORaorM4e2YZgw0RkbY/nHwUrcMRuSGVZoArX4Jw== From: Michael Tremer To: development@lists.ipfire.org Subject: [PATCH 1/2] openvpn: Create database schema if not exists Date: Mon, 25 May 2020 10:17:29 +0100 Message-Id: <20200525091730.4059-1-michael.tremer@ipfire.org> Authentication-Results: mail01.ipfire.org; auth=pass smtp.mailfrom=michael.tremer@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: Michael Tremer Errors-To: development-bounces@lists.ipfire.org Sender: "Development" Signed-off-by: Michael Tremer --- html/cgi-bin/logs.cgi/ovpnclients.dat | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/html/cgi-bin/logs.cgi/ovpnclients.dat b/html/cgi-bin/logs.cgi/ovpnclients.dat index 2009990ec..a064893a1 100755 --- a/html/cgi-bin/logs.cgi/ovpnclients.dat +++ b/html/cgi-bin/logs.cgi/ovpnclients.dat @@ -95,6 +95,21 @@ unless ($to_datestring ge $from_datestring) { $errormessage = "$Lang::tr{'error the to date has to be later than the from date'}"; } +# Initialise database +my $cursor = $database_handle->prepare(" + CREATE TABLE IF NOT EXISTS sessions( + common_name TEXT NOT NULL, + connected_at TEXT NOT NULL, + disconnected_at TEXT, + bytes_received INTEGER, + bytes_sent INTEGER + ); + + -- Create index for speeding up searches + CREATE INDEX IF NOT EXISTS sessions_common_name ON sessions(common_name); +"); +$cursor->execute(); + my $database_query = qq( SELECT common_name, SUM(