From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id ACBC870BCC for ; Thu, 30 Sep 2021 14:31:56 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id A324E20132 for ; Thu, 30 Sep 2021 14:31:56 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 3E181200E8 for ; Thu, 30 Sep 2021 14:31:55 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 0B6D044C34 for ; Thu, 30 Sep 2021 14:31:55 +0200 (CEST) From: Oguz Bektas To: pve-devel@lists.proxmox.com Date: Thu, 30 Sep 2021 14:31:47 +0200 Message-Id: <20210930123147.1474241-3-o.bektas@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210930123147.1474241-1-o.bektas@proxmox.com> References: <20210930123147.1474241-1-o.bektas@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 1.139 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH v3 manager 2/2] fix #1065: ui: fail2ban gui for nodes X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Sep 2021 12:31:56 -0000 adds a simple grid for fail2ban options into the node config panel --- v3: * initial patch for gui www/manager6/Makefile | 1 + www/manager6/grid/Fail2banOptions.js | 51 ++++++++++++++++++++++++++++ www/manager6/node/Config.js | 7 ++++ 3 files changed, 59 insertions(+) create mode 100644 www/manager6/grid/Fail2banOptions.js diff --git a/www/manager6/Makefile b/www/manager6/Makefile index 7d491f57..ad9fe58a 100644 --- a/www/manager6/Makefile +++ b/www/manager6/Makefile @@ -74,6 +74,7 @@ JSSRC= \ grid/BackupView.js \ grid/FirewallAliases.js \ grid/FirewallOptions.js \ + grid/Fail2banOptions.js \ grid/FirewallRules.js \ grid/PoolMembers.js \ grid/Replication.js \ diff --git a/www/manager6/grid/Fail2banOptions.js b/www/manager6/grid/Fail2banOptions.js new file mode 100644 index 00000000..5de0c18c --- /dev/null +++ b/www/manager6/grid/Fail2banOptions.js @@ -0,0 +1,51 @@ +Ext.define('PVE.Fail2banOptions', { + extend: 'Proxmox.grid.ObjectGrid', + alias: ['widget.pveFail2banOptions'], + + base_url: undefined, + + initComponent: function() { + var me = this; + + me.rows = {}; + + me.add_boolean_row('enable', gettext("Enable Fail2Ban")); + me.add_integer_row('maxretry', gettext("Max retries")); + me.add_integer_row('bantime', gettext("Minutes to ban")); + + var edit_btn = new Ext.Button({ + text: gettext('Edit'), + disabled: true, + handler: function() { me.run_editor(); }, + }); + + var set_button_status = function() { + var sm = me.getSelectionModel(); + var rec = sm.getSelection()[0]; + + if (!rec) { + edit_btn.disable(); + return; + } + var rowdef = me.rows[rec.data.key]; + edit_btn.setDisabled(!rowdef.editor); + }; + + Ext.apply(me, { + url: "/api2/json" + me.base_url, + tbar: [edit_btn], + editorConfig: { + url: "/api2/extjs" + me.base_url, + }, + listeners: { + itemdblclick: me.run_editor, + selectionchange: set_button_status, + }, + }); + + me.callParent(); + me.on('activate', me.rstore.startUpdate); + me.on('destroy', me.rstore.stopUpdate); + me.on('deactivate', me.rstore.stopUpdate); + }, +}); diff --git a/www/manager6/node/Config.js b/www/manager6/node/Config.js index 68f80391..9dbe8d0c 100644 --- a/www/manager6/node/Config.js +++ b/www/manager6/node/Config.js @@ -276,6 +276,13 @@ Ext.define('PVE.node.Config', { base_url: '/nodes/' + nodename + '/firewall/options', fwtype: 'node', itemId: 'firewall-options', + }, + { + xtype: 'pveFail2banOptions', + iconCls: 'fa fa-legal', + title: gettext('Fail2ban'), + base_url: '/nodes/' + nodename + '/firewall/fail2ban', + itemId: 'fail2ban-options', }); } -- 2.30.2