Skip to content
Snippets Groups Projects
Commit cc3ca6af 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 d62052e3
No related branches found
No related tags found
1 merge request!455Update branch with changes from master
......@@ -27,7 +27,9 @@
#include <stdio.h> // sprintf
#include "sockwrap.h" // closesocket
#include "trash.h" // filter_ip
#include "scfglib.h" // trashcan_fname
#include "ClientFormUnit.h"
#include "CodeInputFormUnit.h"
void socket_open(void*, BOOL open);
//---------------------------------------------------------------------------
......@@ -87,9 +89,13 @@ void __fastcall TClientForm::CloseSocketMenuItemClick(TObject *Sender)
void __fastcall TClientForm::FilterIpMenuItemClick(TObject *Sender)
{
char str[256];
char fname[MAX_PATH + 1];
int res;
TListItem* ListItem;
TItemStates State;
static uint duration = MainForm->global.login_attempt.filter_duration;
static bool silent;
static char reason[128] = "Abuse";
ListItem=ListView->Selected;
State << isSelected;
......@@ -100,16 +106,42 @@ void __fastcall TClientForm::FilterIpMenuItemClick(TObject *Sender)
AnsiString username = ListItem->SubItems->Strings[1];
AnsiString ip_addr = ListItem->SubItems->Strings[2];
AnsiString hostname = ListItem->SubItems->Strings[3];
wsprintf(str,"Disallow future connections from %s"
,ip_addr);
res=Application->MessageBox(str,"Filter IP?"
,MB_YESNOCANCEL|MB_ICONQUESTION);
if(res==IDCANCEL)
break;
if(res==IDYES)
filter_ip(&MainForm->cfg,prot.c_str(),"abuse",hostname.c_str()
,ip_addr.c_str(),username.c_str(), /* filename: */NULL, /* duration: */0);
Application->CreateForm(__classid(TCodeInputForm), &CodeInputForm);
wsprintf(str,"Disallow future connections from %s?", ip_addr);
CodeInputForm->Caption = str;
CodeInputForm->Label->Caption = "Address Filter Duration";
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;
}
CodeInputForm->Label->Caption = "Reason";
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)
break;
ListItem=ListView->GetNextItem(ListItem,sdAll,State);
......
......@@ -3,40 +3,40 @@ object CodeInputForm: TCodeInputForm
Top = 374
BorderStyle = bsDialog
Caption = 'Parameter Required'
ClientHeight = 73
ClientWidth = 331
ClientHeight = 78
ClientWidth = 356
Color = clBtnFace
ParentFont = True
OldCreateOrder = True
Position = poScreenCenter
OnShow = FormShow
DesignSize = (
331
73)
356
78)
PixelsPerInch = 96
TextHeight = 13
TextHeight = 14
object Bevel1: TBevel
Left = 8
Top = 8
Width = 228
Height = 55
Left = 9
Top = 9
Width = 245
Height = 58
Anchors = [akLeft, akTop, akRight, akBottom]
Shape = bsFrame
end
object Label: TLabel
Left = 13
Top = 26
Width = 105
Height = 20
Left = 20
Top = 18
Width = 113
Height = 22
Alignment = taRightJustify
AutoSize = False
Caption = 'Name/ID/Code'
end
object OKBtn: TButton
Left = 247
Top = 8
Width = 75
Height = 25
Left = 266
Top = 9
Width = 81
Height = 27
Anchors = [akTop, akRight]
Caption = 'OK'
Default = True
......@@ -44,10 +44,10 @@ object CodeInputForm: TCodeInputForm
TabOrder = 0
end
object CancelBtn: TButton
Left = 247
Top = 38
Width = 75
Height = 25
Left = 266
Top = 41
Width = 81
Height = 27
Anchors = [akTop, akRight]
Cancel = True
Caption = 'Cancel'
......@@ -55,20 +55,32 @@ object CodeInputForm: TCodeInputForm
TabOrder = 1
end
object ComboBox: TComboBox
Left = 124
Top = 26
Width = 98
Height = 21
ItemHeight = 13
Left = 140
Top = 16
Width = 105
Height = 22
ItemHeight = 14
Sorted = True
TabOrder = 2
end
object Edit: TEdit
Left = 124
Top = 26
Width = 98
Height = 21
Left = 140
Top = 16
Width = 105
Height = 22
TabOrder = 3
Visible = False
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
/* 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.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
......@@ -15,21 +13,9 @@
* See the GNU General Public License for more details: gpl.txt or *
* 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 *
* 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. *
****************************************************************************/
......@@ -57,6 +43,7 @@ __published:
TLabel *Label;
TComboBox *ComboBox;
TEdit *Edit;
TCheckBox *CheckBox;
void __fastcall FormShow(TObject *Sender);
private:
public:
......
......@@ -187,10 +187,12 @@ void __fastcall TLoginAttemptsForm::RefreshPopupClick(TObject *Sender)
void __fastcall TLoginAttemptsForm::FilterIpMenuItemClick(TObject *Sender)
{
char str[256];
char fname[MAX_PATH + 1];
int res;
TListItem* ListItem;
TItemStates State;
static uint duration;
static uint duration = MainForm->global.login_attempt.filter_duration;
static bool silent;
ListItem=ListView->Selected;
State << isSelected;
......@@ -212,8 +214,14 @@ void __fastcall TLoginAttemptsForm::FilterIpMenuItemClick(TObject *Sender)
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;
delete CodeInputForm;
if(res != mrOk)
break;
......@@ -225,8 +233,10 @@ void __fastcall TLoginAttemptsForm::FilterIpMenuItemClick(TObject *Sender)
Screen->Cursor=crDefault;
if(h!=NULL)
hostname = h->h_name;
filter_ip(&MainForm->cfg, prot.c_str(), (AnsiString(ListItem->Caption) + " CONSECUTIVE FAILED LOGIN ATTEMPTS").c_str(), hostname
,ip_addr.c_str(), username.c_str(), /* filename: */NULL, duration);
filter_ip(&MainForm->cfg, prot.c_str(), (AnsiString(ListItem->Caption) + " " strFailedLoginAttempts).c_str(), hostname
,ip_addr.c_str(), username.c_str()
,trashcan_fname(&MainForm->cfg, silent ? "ip-silent" : "ip", fname, sizeof fname)
,duration);
if(ListView->Selected == NULL)
break;
ListItem=ListView->GetNextItem(ListItem,sdAll,State);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment