Skip to content
Snippets Groups Projects
Commit 6d17e01b authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Add prompting for silent-IP filtering and reason for filtering from ClientForm

There's a hidden checkbox on the CodeInputForm now (explaining why the edit/
combo box is now moved up).
parent 46d7b67d
No related branches found
No related tags found
No related merge requests found
...@@ -27,7 +27,9 @@ ...@@ -27,7 +27,9 @@
#include <stdio.h> // sprintf #include <stdio.h> // sprintf
#include "sockwrap.h" // closesocket #include "sockwrap.h" // closesocket
#include "trash.h" // filter_ip #include "trash.h" // filter_ip
#include "scfglib.h" // trashcan_fname
#include "ClientFormUnit.h" #include "ClientFormUnit.h"
#include "CodeInputFormUnit.h"
void socket_open(void*, BOOL open); void socket_open(void*, BOOL open);
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
...@@ -87,9 +89,13 @@ void __fastcall TClientForm::CloseSocketMenuItemClick(TObject *Sender) ...@@ -87,9 +89,13 @@ void __fastcall TClientForm::CloseSocketMenuItemClick(TObject *Sender)
void __fastcall TClientForm::FilterIpMenuItemClick(TObject *Sender) void __fastcall TClientForm::FilterIpMenuItemClick(TObject *Sender)
{ {
char str[256]; char str[256];
char fname[MAX_PATH + 1];
int res; int res;
TListItem* ListItem; TListItem* ListItem;
TItemStates State; TItemStates State;
static uint duration = MainForm->global.login_attempt.filter_duration;
static bool silent;
static char reason[128] = "Abuse";
ListItem=ListView->Selected; ListItem=ListView->Selected;
State << isSelected; State << isSelected;
...@@ -101,15 +107,41 @@ void __fastcall TClientForm::FilterIpMenuItemClick(TObject *Sender) ...@@ -101,15 +107,41 @@ void __fastcall TClientForm::FilterIpMenuItemClick(TObject *Sender)
AnsiString ip_addr = ListItem->SubItems->Strings[2]; AnsiString ip_addr = ListItem->SubItems->Strings[2];
AnsiString hostname = ListItem->SubItems->Strings[3]; AnsiString hostname = ListItem->SubItems->Strings[3];
wsprintf(str,"Disallow future connections from %s" Application->CreateForm(__classid(TCodeInputForm), &CodeInputForm);
,ip_addr); wsprintf(str,"Disallow future connections from %s?", ip_addr);
res=Application->MessageBox(str,"Filter IP?" CodeInputForm->Caption = str;
,MB_YESNOCANCEL|MB_ICONQUESTION); CodeInputForm->Label->Caption = "Address Filter Duration";
if(res==IDCANCEL) CodeInputForm->Edit->Visible = true;
CodeInputForm->Edit->Text = duration ? duration_to_vstr(duration, str, sizeof str) : "Infinite";
CodeInputForm->Edit->Hint = "'Infinite' or number of Seconds/Minutes/Hours/Days/Weeks/Years";
CodeInputForm->Edit->ShowHint = true;
CodeInputForm->CheckBox->Visible = true;
CodeInputForm->CheckBox->Caption = "Silent Filter";
CodeInputForm->CheckBox->Checked = silent;
CodeInputForm->CheckBox->Hint = "No messages logged when blocking this client";
CodeInputForm->CheckBox->ShowHint = true;
res = CodeInputForm->ShowModal();
duration = parse_duration(CodeInputForm->Edit->Text.c_str());
silent = CodeInputForm->CheckBox->Checked;
if(res != mrOk) {
delete CodeInputForm;
break; break;
if(res==IDYES) }
filter_ip(&MainForm->cfg,prot.c_str(),"abuse",hostname.c_str() CodeInputForm->Label->Caption = "Reason";
,ip_addr.c_str(),username.c_str(), /* filename: */NULL, /* duration: */0); CodeInputForm->Edit->Text = reason;
CodeInputForm->Edit->Hint = "The cause or rationale for the filter";
CodeInputForm->CheckBox->Visible = false;
res = CodeInputForm->ShowModal();
SAFECOPY(reason, CodeInputForm->Edit->Text.c_str());
delete CodeInputForm;
if(res != mrOk)
break;
filter_ip(&MainForm->cfg,prot.c_str()
,reason
,hostname.c_str()
,ip_addr.c_str(),username.c_str()
,trashcan_fname(&MainForm->cfg, silent ? "ip-silent" : "ip", fname, sizeof fname)
,duration);
if(ListView->Selected == NULL) if(ListView->Selected == NULL)
break; break;
ListItem=ListView->GetNextItem(ListItem,sdAll,State); ListItem=ListView->GetNextItem(ListItem,sdAll,State);
......
...@@ -3,40 +3,40 @@ object CodeInputForm: TCodeInputForm ...@@ -3,40 +3,40 @@ object CodeInputForm: TCodeInputForm
Top = 374 Top = 374
BorderStyle = bsDialog BorderStyle = bsDialog
Caption = 'Parameter Required' Caption = 'Parameter Required'
ClientHeight = 73 ClientHeight = 78
ClientWidth = 331 ClientWidth = 356
Color = clBtnFace Color = clBtnFace
ParentFont = True ParentFont = True
OldCreateOrder = True OldCreateOrder = True
Position = poScreenCenter Position = poScreenCenter
OnShow = FormShow OnShow = FormShow
DesignSize = ( DesignSize = (
331 356
73) 78)
PixelsPerInch = 96 PixelsPerInch = 96
TextHeight = 13 TextHeight = 14
object Bevel1: TBevel object Bevel1: TBevel
Left = 8 Left = 9
Top = 8 Top = 9
Width = 228 Width = 245
Height = 55 Height = 58
Anchors = [akLeft, akTop, akRight, akBottom] Anchors = [akLeft, akTop, akRight, akBottom]
Shape = bsFrame Shape = bsFrame
end end
object Label: TLabel object Label: TLabel
Left = 13 Left = 20
Top = 26 Top = 18
Width = 105 Width = 113
Height = 20 Height = 22
Alignment = taRightJustify Alignment = taRightJustify
AutoSize = False AutoSize = False
Caption = 'Name/ID/Code' Caption = 'Name/ID/Code'
end end
object OKBtn: TButton object OKBtn: TButton
Left = 247 Left = 266
Top = 8 Top = 9
Width = 75 Width = 81
Height = 25 Height = 27
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
Caption = 'OK' Caption = 'OK'
Default = True Default = True
...@@ -44,10 +44,10 @@ object CodeInputForm: TCodeInputForm ...@@ -44,10 +44,10 @@ object CodeInputForm: TCodeInputForm
TabOrder = 0 TabOrder = 0
end end
object CancelBtn: TButton object CancelBtn: TButton
Left = 247 Left = 266
Top = 38 Top = 41
Width = 75 Width = 81
Height = 25 Height = 27
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
Cancel = True Cancel = True
Caption = 'Cancel' Caption = 'Cancel'
...@@ -55,20 +55,32 @@ object CodeInputForm: TCodeInputForm ...@@ -55,20 +55,32 @@ object CodeInputForm: TCodeInputForm
TabOrder = 1 TabOrder = 1
end end
object ComboBox: TComboBox object ComboBox: TComboBox
Left = 124 Left = 140
Top = 26 Top = 16
Width = 98 Width = 105
Height = 21 Height = 22
ItemHeight = 13 ItemHeight = 14
Sorted = True Sorted = True
TabOrder = 2 TabOrder = 2
end end
object Edit: TEdit object Edit: TEdit
Left = 124 Left = 140
Top = 26 Top = 16
Width = 98 Width = 105
Height = 21 Height = 22
TabOrder = 3 TabOrder = 3
Visible = False Visible = False
end end
object CheckBox: TCheckBox
Left = 169
Top = 44
Width = 74
Height = 17
Alignment = taLeftJustify
BiDiMode = bdLeftToRight
Caption = 'CheckBox'
ParentBiDiMode = False
TabOrder = 4
Visible = False
end
end end
/* Synchronet Control Panel (GUI Borland C++ Builder Project for Win32) */ /* Synchronet Control Panel (GUI Borland C++ Builder Project for Win32) */
/* $Id: CodeInputFormUnit.h,v 1.4 2018/07/24 01:11:28 rswindell Exp $ */
/**************************************************************************** /****************************************************************************
* @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
...@@ -15,21 +13,9 @@ ...@@ -15,21 +13,9 @@
* See the GNU General Public License for more details: gpl.txt or * * See the GNU General Public License for more details: gpl.txt or *
* http://www.fsf.org/copyleft/gpl.html * * http://www.fsf.org/copyleft/gpl.html *
* * * *
* Anonymous FTP access to the most recent released source is available at *
* ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net *
* *
* Anonymous CVS access to the development source and modification history *
* is available at cvs.synchro.net:/cvsroot/sbbs, example: *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs login *
* (just hit return, no password is necessary) *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs checkout src *
* *
* For Synchronet coding style and modification guidelines, see * * For Synchronet coding style and modification guidelines, see *
* http://www.synchro.net/source.html * * http://www.synchro.net/source.html *
* * * *
* You are encouraged to submit any modifications (preferably in Unix diff *
* format) via e-mail to mods@synchro.net *
* *
* Note: If this box doesn't appear square, then you need to fix your tabs. * * Note: If this box doesn't appear square, then you need to fix your tabs. *
****************************************************************************/ ****************************************************************************/
...@@ -57,6 +43,7 @@ __published: ...@@ -57,6 +43,7 @@ __published:
TLabel *Label; TLabel *Label;
TComboBox *ComboBox; TComboBox *ComboBox;
TEdit *Edit; TEdit *Edit;
TCheckBox *CheckBox;
void __fastcall FormShow(TObject *Sender); void __fastcall FormShow(TObject *Sender);
private: private:
public: public:
......
...@@ -187,10 +187,12 @@ void __fastcall TLoginAttemptsForm::RefreshPopupClick(TObject *Sender) ...@@ -187,10 +187,12 @@ void __fastcall TLoginAttemptsForm::RefreshPopupClick(TObject *Sender)
void __fastcall TLoginAttemptsForm::FilterIpMenuItemClick(TObject *Sender) void __fastcall TLoginAttemptsForm::FilterIpMenuItemClick(TObject *Sender)
{ {
char str[256]; char str[256];
char fname[MAX_PATH + 1];
int res; int res;
TListItem* ListItem; TListItem* ListItem;
TItemStates State; TItemStates State;
static uint duration; static uint duration = MainForm->global.login_attempt.filter_duration;
static bool silent;
ListItem=ListView->Selected; ListItem=ListView->Selected;
State << isSelected; State << isSelected;
...@@ -212,8 +214,14 @@ void __fastcall TLoginAttemptsForm::FilterIpMenuItemClick(TObject *Sender) ...@@ -212,8 +214,14 @@ void __fastcall TLoginAttemptsForm::FilterIpMenuItemClick(TObject *Sender)
CodeInputForm->Edit->Text = duration ? duration_to_vstr(duration, str, sizeof str) : "Infinite"; CodeInputForm->Edit->Text = duration ? duration_to_vstr(duration, str, sizeof str) : "Infinite";
CodeInputForm->Edit->Hint = "'Infinite' or number of Seconds/Minutes/Hours/Days/Weeks/Years"; CodeInputForm->Edit->Hint = "'Infinite' or number of Seconds/Minutes/Hours/Days/Weeks/Years";
CodeInputForm->Edit->ShowHint = true; CodeInputForm->Edit->ShowHint = true;
CodeInputForm->CheckBox->Visible = true;
CodeInputForm->CheckBox->Caption = "Silent Filter";
CodeInputForm->CheckBox->Checked = silent;
CodeInputForm->CheckBox->Hint = "No messages logged when blocking this client";
CodeInputForm->CheckBox->ShowHint = true;
res = CodeInputForm->ShowModal(); res = CodeInputForm->ShowModal();
duration = parse_duration(CodeInputForm->Edit->Text.c_str()); duration = parse_duration(CodeInputForm->Edit->Text.c_str());
silent = CodeInputForm->CheckBox->Checked;
delete CodeInputForm; delete CodeInputForm;
if(res != mrOk) if(res != mrOk)
break; break;
...@@ -225,8 +233,10 @@ void __fastcall TLoginAttemptsForm::FilterIpMenuItemClick(TObject *Sender) ...@@ -225,8 +233,10 @@ void __fastcall TLoginAttemptsForm::FilterIpMenuItemClick(TObject *Sender)
Screen->Cursor=crDefault; Screen->Cursor=crDefault;
if(h!=NULL) if(h!=NULL)
hostname = h->h_name; hostname = h->h_name;
filter_ip(&MainForm->cfg, prot.c_str(), (AnsiString(ListItem->Caption) + " CONSECUTIVE FAILED LOGIN ATTEMPTS").c_str(), hostname filter_ip(&MainForm->cfg, prot.c_str(), (AnsiString(ListItem->Caption) + " " strFailedLoginAttempts).c_str(), hostname
,ip_addr.c_str(), username.c_str(), /* filename: */NULL, duration); ,ip_addr.c_str(), username.c_str()
,trashcan_fname(&MainForm->cfg, silent ? "ip-silent" : "ip", fname, sizeof fname)
,duration);
if(ListView->Selected == NULL) if(ListView->Selected == NULL)
break; break;
ListItem=ListView->GetNextItem(ListItem,sdAll,State); ListItem=ListView->GetNextItem(ListItem,sdAll,State);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment