From patchwork Sat Jan 16 15:37:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matthias Fischer X-Patchwork-Id: 3805 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 RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4DJ2Gw1Vc0z3wsQ for ; Sat, 16 Jan 2021 15:37:12 +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 4DJ2Gs74Qsz4lX; Sat, 16 Jan 2021 15:37:09 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4DJ2Gs2yyCz2xs0; Sat, 16 Jan 2021 15:37:09 +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) server-digest SHA384 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4DJ2Gr06WMz2xhR for ; Sat, 16 Jan 2021 15:37:08 +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) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4DJ2Gp1zmrzMl; Sat, 16 Jan 2021 15:37:06 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1610811426; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=tbc4J40aGJyHwz4laZEBm7gv3mFHDPMM45D8wvrHxSY=; b=o4GzuNBL6fGgaQZXFfKgwp8LeT8f1B5FtmzKTIJ9RhM5E5T+THhgYbctlLf8Y6qI+RehUx e6Bist9NAFV5cVDw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1610811426; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=tbc4J40aGJyHwz4laZEBm7gv3mFHDPMM45D8wvrHxSY=; b=BZYeGRJz8ubHs8Ve2/oc45ydYu648td5QWHQ+4o1WmIrlw3w4K6pG5ZuJ7eNVnpQWTwAtA gMG5ZvcBJuyRU+W66fE5Z03R8nCSjVrSNZ7t4bvIuW4Fl+Glv/kLtRUB4XCIAiUKKwRur4 TGeBHW8CRDt1KH6qUhC/IzXjxD6l52CIRagXCYtB2BtPIp4Ulsib+9EGvYKmE9NUihepXN aWbkeQisCO6RfHKldnbywbYEZfcjTxblLpZCryV7wSGETblqNIYABIvIsoGEIVQIHNKxFy akVnIH0qAXhqvx3hTkc8vNT8KC+ESwqrbPWWM+cc8wiCMKf8fLmqKmZS388Xiw== From: Matthias Fischer To: development@lists.ipfire.org Subject: [PATCH] New package: IPTraffic 0.8.1 Date: Sat, 16 Jan 2021 16:37:01 +0100 Message-Id: <20210116153701.22285-1-matthias.fischer@ipfire.org> MIME-Version: 1.0 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: , Errors-To: development-bounces@lists.ipfire.org Sender: "Development" From: Frank Mainz Please note: This is a port of the old 'IPTraffics' addon from ipcop to ipfire done by RadioCarbon (Frank Mainz). He asked me to publish this for him - ALL programming work was done by him. I'm only the MITM. Description: With the add-on “IPTraffic” you can determine the traffic of a computer based on its IP address. Only the traffic between IPFire and the client to be monitored can be determined. The display is shown once as a tabular overview and additionally a statistical graphic can be called up for each client over the period of the last hour, day, week, month and year. Signed-off-by: Matthias Fischer --- config/rootfiles/packages/iptraffic | 22 ++++++ lfs/iptraffic | 108 ++++++++++++++++++++++++++++ make.sh | 1 + src/paks/iptraffic/install.sh | 40 +++++++++++ src/paks/iptraffic/uninstall.sh | 28 ++++++++ src/paks/iptraffic/update.sh | 26 +++++++ 6 files changed, 225 insertions(+) create mode 100644 config/rootfiles/packages/iptraffic create mode 100644 lfs/iptraffic create mode 100644 src/paks/iptraffic/install.sh create mode 100644 src/paks/iptraffic/uninstall.sh create mode 100644 src/paks/iptraffic/update.sh diff --git a/config/rootfiles/packages/iptraffic b/config/rootfiles/packages/iptraffic new file mode 100644 index 000000000..b860cd9aa --- /dev/null +++ b/config/rootfiles/packages/iptraffic @@ -0,0 +1,22 @@ +etc/fcron.minutely/update-iptraffic +srv/web/ipfire/html/images/iptraffic +srv/web/ipfire/cgi-bin/iptraffic.cgi +srv/web/ipfire/html/images/iptraffic/addblue.gif +srv/web/ipfire/html/images/iptraffic/addfaint.gif +srv/web/ipfire/html/images/iptraffic/addgray.gif +srv/web/ipfire/html/images/iptraffic/addgreen.gif +srv/web/ipfire/html/images/iptraffic/addorange.gif +srv/web/ipfire/html/images/iptraffic/addred.gif +srv/web/ipfire/html/images/iptraffic/blue.png +srv/web/ipfire/html/images/iptraffic/graph.png +srv/web/ipfire/html/images/iptraffic/gray.png +srv/web/ipfire/html/images/iptraffic/green.png +srv/web/ipfire/html/images/iptraffic/orange.png +srv/web/ipfire/html/images/iptraffic/red.png +srv/web/ipfire/html/images/iptraffic/square-green.png +srv/web/ipfire/html/images/iptraffic/square-red.png +srv/web/ipfire/html/images/iptraffic/square-yellow.png +usr/local/bin/iptraffic.pl +var/ipfire/addon-lang/iptraffic.de.pl +var/ipfire/addon-lang/iptraffic.en.pl +var/ipfire/menu.d/EX-iptraffic.menu diff --git a/lfs/iptraffic b/lfs/iptraffic new file mode 100644 index 000000000..e390863aa --- /dev/null +++ b/lfs/iptraffic @@ -0,0 +1,108 @@ +############################################################################### +# # +# IPFire.org - A linux based firewall # +# Copyright (C) 2007-2020 IPFire Team # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################### + +############################################################################### +# Definitions +############################################################################### + +include Config + +VER = 0.8.1 + +THISAPP = iptraffic-$(VER) +DL_FILE = $(THISAPP).tar.gz +DL_FROM = $(URL_IPFIRE) +DIR_APP = $(DIR_SRC)/$(THISAPP) +TARGET = $(DIR_INFO)/$(THISAPP) +PAK_VER = 1 +PROG = iptraffic + +DEPS = "" + +############################################################################### +# Top-level Rules +############################################################################### + +objects = $(DL_FILE) + +$(DL_FILE) = $(DL_FROM)/$(DL_FILE) + +$(DL_FILE)_MD5 = cdf6de9830737907dff4112a69f517bb + +install : $(TARGET) + +check : $(patsubst %,$(DIR_CHK)/%,$(objects)) + +download :$(patsubst %,$(DIR_DL)/%,$(objects)) + +md5 : $(subst %,%_MD5,$(objects)) + +dist: + $(PAK) + +############################################################################### +# Downloading, checking, md5sum +############################################################################### + +$(patsubst %,$(DIR_CHK)/%,$(objects)) : + @$(CHECK) + +$(patsubst %,$(DIR_DL)/%,$(objects)) : + @$(LOAD) + +$(subst %,%_MD5,$(objects)) : + @$(MD5) + +############################################################################### +# Installation Details +############################################################################### + +$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) + @$(PREBUILD) + @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar zxf $(DIR_DL)/$(DL_FILE) + + # Install GUI + install -v -m 755 $(DIR_SRC)/srv/web/ipfire/cgi-bin/iptraffic.cgi \ + /srv/web/ipfire/cgi-bin/iptraffic.cgi + + # Install images + -mkdir -p /srv/web/ipfire/html/images/iptraffic + install -v -m 644 $(DIR_SRC)/srv/web/ipfire/html/images/iptraffic/* \ + /srv/web/ipfire/html/images/iptraffic/ + + # Install iptraffic script + install -v -m 755 $(DIR_SRC)/usr/local/bin/iptraffic.pl \ + /usr/local/bin/iptraffic.pl + + # Create symlink for one minute updates + ln -sf /usr/local/bin/iptraffic.pl \ + /etc/fcron.minutely/update-iptraffic + + # Install language files + install -v -m 004 $(DIR_SRC)/var/ipfire/addon-lang/iptraffic.*.pl \ + /var/ipfire/addon-lang/ + + # Install menu entry + install -v -m 644 $(DIR_SRC)/var/ipfire/menu.d/EX-iptraffic.menu \ + /var/ipfire/menu.d/EX-iptraffic.menu + chown nobody.nobody /var/ipfire/menu.d/EX-iptraffic.menu + + @rm -rf $(DIR_APP) + @$(POSTBUILD) diff --git a/make.sh b/make.sh index a9db53edf..267e1b09a 100755 --- a/make.sh +++ b/make.sh @@ -1654,6 +1654,7 @@ buildipfire() { lfsmake2 ncdu lfsmake2 lshw lfsmake2 socat + lfsmake2 iptraffic } buildinstaller() { diff --git a/src/paks/iptraffic/install.sh b/src/paks/iptraffic/install.sh new file mode 100644 index 000000000..a9f857784 --- /dev/null +++ b/src/paks/iptraffic/install.sh @@ -0,0 +1,40 @@ +#!/bin/bash +############################################################################ +# # +# This file is part of the IPFire Firewall. # +# # +# IPFire is free software; you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation; either version 2 of the License, or # +# (at your option) any later version. # +# # +# IPFire is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with IPFire; if not, write to the Free Software # +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +# # +# Copyright (C) 2020 IPFire-Team . # +# # +############################################################################ +# +. /opt/pakfire/lib/functions.sh +extract_files + +mkdir -p /srv/web/ipfire/html/graphs/iptraffic +mkdir -p /var/log/iptraffic +mkdir -p /var/log/rrd/iptraffic + +touch /var/log/iptraffic/iptraffic.db + +restore_backup ${NAME} + +chown -R nobody.nobody /var/log/iptraffic +chown -R nobody.nobody /var/log/rrd/iptraffic +chown root.nobody /usr/local/bin/iptraffic.pl +chown nobody.nobody /var/ipfire/menu.d/EX-iptraffic.menu + +/usr/local/bin/update-lang-cache diff --git a/src/paks/iptraffic/uninstall.sh b/src/paks/iptraffic/uninstall.sh new file mode 100644 index 000000000..dac570c05 --- /dev/null +++ b/src/paks/iptraffic/uninstall.sh @@ -0,0 +1,28 @@ +#!/bin/bash +############################################################################ +# # +# This file is part of the IPFire Firewall. # +# # +# IPFire is free software; you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation; either version 2 of the License, or # +# (at your option) any later version. # +# # +# IPFire is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with IPFire; if not, write to the Free Software # +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +# # +# Copyright (C) 2007 IPFire-Team . # +# # +############################################################################ +# +. /opt/pakfire/lib/functions.sh + +remove_files + +/usr/local/bin/update-lang-cache diff --git a/src/paks/iptraffic/update.sh b/src/paks/iptraffic/update.sh new file mode 100644 index 000000000..89c40d0d7 --- /dev/null +++ b/src/paks/iptraffic/update.sh @@ -0,0 +1,26 @@ +#!/bin/bash +############################################################################ +# # +# This file is part of the IPFire Firewall. # +# # +# IPFire is free software; you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation; either version 2 of the License, or # +# (at your option) any later version. # +# # +# IPFire is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with IPFire; if not, write to the Free Software # +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +# # +# Copyright (C) 2007 IPFire-Team . # +# # +############################################################################ +# +. /opt/pakfire/lib/functions.sh +./uninstall.sh +./install.sh