Skip to content

Commit 52ef6e4

Browse files
authored
release 2.1.5 (#86)
* turning up the version number * avoid runtime change of _syncObject in logger * fixes #87 * fixes #90, Part 2 * fixed a typo * readonly instance member * fixes #91 * #92 added mor text to slow/overheated task warning * #92 also, the gap is a bit low * #92 also, dont spam the event log, write the warning once a day * changed timing method to rule out measurement error #86 * release v2.1.5
1 parent 3279779 commit 52ef6e4

File tree

13 files changed

+91
-35
lines changed

13 files changed

+91
-35
lines changed

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## NEWS
22

3+
### 2022-04-14 release of v.2.1.5 was completed
4+
- fixes a bug where a windows misbehaviour could return 0.0.0.0 as offending IP, thus blocking all subnets
5+
- try to fix a bug where a false positive warning about tasks taking too long are spamming the event logs of EvlWatcher
6+
37
### 2022-01-22 release of v.2.1.4 was completed
48
- basic ipv6 support
59
- certificate was renewed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ It's basically a fail2ban for windows. Its goals are also mainly what we love ab
55
- *no-initial-fucking-around-with-scripts-or-config-files*
66
- *install-and-forget*
77

8-
You can download it [here](https://github.com/devnulli/EvlWatcher/raw/master/Versions/v2/EvlWatcher-v2.1.4-setup.exe) ( v2.1.4 - January 2022 ) .
8+
You can download it [here](https://github.com/devnulli/EvlWatcher/raw/master/Versions/v2/EvlWatcher-v2.1.5-setup.exe) ( v2.1.5 - April 2022 ) .
99

1010
## Also, we love issues!
1111

Source/EvlWatcher/EvlWatcher.WCF/Properties/AssemblyInfo.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
[assembly: AssemblyConfiguration("")]
1111
[assembly: AssemblyCompany("")]
1212
[assembly: AssemblyProduct("EvlWatcher.WCF")]
13-
[assembly: AssemblyCopyright("Copyright © 2021 Michael Schönbauer")]
13+
[assembly: AssemblyCopyright("Copyright © 2022 Michael Schönbauer")]
1414
[assembly: AssemblyTrademark("")]
1515
[assembly: AssemblyCulture("")]
1616

@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("2.1.4.0")]
36-
[assembly: AssemblyFileVersion("2.1.4.0")]
35+
[assembly: AssemblyVersion("2.1.5.0")]
36+
[assembly: AssemblyFileVersion("2.1.5.0")]

Source/EvlWatcher/EvlWatcher/EvlWatcher.cs

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
using System.ServiceProcess;
1717
using System.Text.RegularExpressions;
1818
using System.Threading;
19+
using System.Diagnostics;
1920

2021
namespace EvlWatcher
2122
{
@@ -45,6 +46,7 @@ public class EvlWatcher : ServiceBase, IEvlWatcherService
4546
/// all loaded tasks
4647
/// </summary>
4748
private static readonly List<LogTask> _logTasks = new List<LogTask>();
49+
private static readonly Dictionary<LogTask, DateTime> _logTasksPerfWarningIssued = new Dictionary<LogTask, DateTime>();
4850

4951
/// <summary>
5052
/// adds some extra output
@@ -331,6 +333,7 @@ private void PushBanList()
331333
.Union(_serviceconfiguration.BlacklistAddresses)
332334
.Distinct()
333335
.Where(address => !IsWhiteListed(address))
336+
.Where(address => !address.Equals(IPAddress.Any))
334337
.ToList();
335338

336339
_firewallApi.AdjustIPBanList(banList);
@@ -492,40 +495,48 @@ private void Run()
492495

493496
if (eventsForThisTask.Count > 0)
494497
{
495-
DateTime start = DateTime.Now;
498+
var start = Stopwatch.GetTimestamp();
496499

497500
t.ProvideEvents(eventsForThisTask);
498501

499-
if (DateTime.Now.Subtract(start).TotalMilliseconds > 500)
500-
_logger.Dump($"Warning: Task {t.Name} takes a lot of resources. This can make your server vulnerable to DOS attacks. Try better boosters.", SeverityLevel.Warning);
502+
var end = Stopwatch.GetTimestamp();
503+
504+
if (end - start > 50000000)
505+
{
506+
if (!_logTasksPerfWarningIssued.ContainsKey(t) || DateTime.Now > _logTasksPerfWarningIssued[t].AddHours(24))
507+
{
508+
_logger.Dump($"Warning: Task {t.Name} takes a lot of resources. This can have different reasons, maybe you get a lot of events (problems in domain configuration, stale hidden credentials..), or the event processing is too slow. This can cause EvlWatcher to produce CPU spikes. Try better boosters, or try to find the root problem,", SeverityLevel.Warning);
509+
_logTasksPerfWarningIssued[t] = DateTime.Now;
510+
}
511+
}
501512
}
502513
}
503514
}
504515
}
505516

506-
List<IPAddress> blackList = new List<IPAddress>();
517+
List<IPAddress> polledTempBansOfThisCycle = new List<IPAddress>();
518+
List<IPAddress> polledPermaBansOfThisCycle = new List<IPAddress>();
507519

508520
//let the tasks poll which ips they want to have blocked / or permanently banned
509521
foreach (LogTask t in _logTasks)
510522
{
511523
if (t is IPBlockingLogTask ipTask)
512524
{
513-
SetPermanentBanInternal(ipTask.GetPermaBanVictims().ToArray());
514-
515-
List<IPAddress> blockedIPs = ipTask.GetTempBanVictims();
525+
List<IPAddress> polledTempBansOfThisTask = ipTask.GetTempBanVictims();
526+
List<IPAddress> polledPermaBansOfThisTask = ipTask.GetPermaBanVictims();
516527

517-
_logger.Dump($"Polled {t.Name} and got {blockedIPs.Count} temporary and {_serviceconfiguration.BlacklistAddresses.Count()} permanent ban(s)", SeverityLevel.Verbose);
528+
_logger.Dump($"Polled {t.Name} and got {polledTempBansOfThisTask.Count} temporary and {polledPermaBansOfThisTask.Count()} permanent ban(s)", SeverityLevel.Verbose);
518529

519-
foreach (IPAddress blockedIP in blockedIPs)
520-
if (!blackList.Contains(blockedIP))
521-
blackList.Add(blockedIP);
530+
polledPermaBansOfThisCycle.AddRange(polledPermaBansOfThisTask.Where(ip => !polledPermaBansOfThisCycle.Contains(ip)).ToList());
531+
polledTempBansOfThisCycle.AddRange(polledTempBansOfThisTask.Where(ip => !polledTempBansOfThisCycle.Contains(ip)).ToList());
522532
}
523533
}
524534

525535
_logger.Dump($"\r\n-----Cycle complete, sleeping {_serviceconfiguration.EventLogInterval} s......\r\n", SeverityLevel.Debug);
526-
527-
_lastPolledTempBans = blackList;
528536

537+
SetPermanentBanInternal(polledPermaBansOfThisCycle.ToArray(), pushBanList: false);
538+
_lastPolledTempBans = polledTempBansOfThisCycle;
539+
529540
PushBanList();
530541
}
531542
catch (Exception executionException)
@@ -570,12 +581,13 @@ private void Run()
570581
}
571582
}
572583

573-
private void SetPermanentBanInternal(IPAddress[] addressList)
584+
private void SetPermanentBanInternal(IPAddress[] addressList, bool pushBanList=true)
574585
{
575586
foreach (IPAddress address in addressList)
576587
_serviceconfiguration.AddBlackListAddress(address);
577588

578-
PushBanList();
589+
if (pushBanList)
590+
PushBanList();
579591
}
580592

581593

Source/EvlWatcher/EvlWatcher/EvlWatcher.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@
127127
</ItemGroup>
128128
<ItemGroup>
129129
<Content Include="config.xml">
130-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
130+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
131131
<SubType>Designer</SubType>
132132
</Content>
133133
<Content Include="license.txt">

Source/EvlWatcher/EvlWatcher/Logging/DefaultLogger.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ namespace EvlWatcher.Logging
88
{
99
internal class DefaultLogger : ILogger
1010
{
11-
private object _syncObject = new object();
11+
private readonly object _syncObject = new object();
1212
public SeverityLevel LogLevel { get; set; } = SeverityLevel.Warning;
1313

1414
private int ConsoleHistoryMaxCount { get; set; } = 1000;
15-
private IList<LogEntry> ConsoleHistory { get; set; } = new List<LogEntry>();
15+
private IList<LogEntry> ConsoleHistory { get; } = new List<LogEntry>();
1616

1717
private void ManageConsoleHistory(string message, SeverityLevel severity, DateTime date)
1818
{

Source/EvlWatcher/EvlWatcher/NSIS/make.nsi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Name "EvlWatcher"
22

33
; The file to write
44
Icon EvlWatcher.ico
5-
OutFile "EvlWatcher-v2.1.4-setup.exe"
5+
OutFile "EvlWatcher-v2.1.5-setup.exe"
66

77
; The default installation directory
88
InstallDir $PROGRAMFILES\EvlWatcher

Source/EvlWatcher/EvlWatcher/Properties/AssemblyInfo.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
[assembly: AssemblyConfiguration("")]
1010
[assembly: AssemblyCompany("Michael Schönbauer")]
1111
[assembly: AssemblyProduct("EvlWatcher")]
12-
[assembly: AssemblyCopyright("2021 Michael Schönbauer")]
12+
[assembly: AssemblyCopyright("2022 Michael Schönbauer")]
1313
[assembly: AssemblyTrademark("")]
1414
[assembly: AssemblyCulture("")]
1515

@@ -28,5 +28,5 @@
2828
// Build Number
2929
// Revision
3030
//
31-
[assembly: AssemblyVersion("2.1.4.0")]
32-
[assembly: AssemblyFileVersion("2.1.4.0")]
31+
[assembly: AssemblyVersion("2.1.5.0")]
32+
[assembly: AssemblyFileVersion("2.1.5.0")]

Source/EvlWatcher/EvlWatcher/config.xml

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,13 @@
3131
3600
3232
</LockTime>
3333

34-
<!-- this is used for rules that only need new events for evaluating. If you dont know what this does, leave it set to false-->
34+
<!-- this is used for rules that only need new events for evaluating.
35+
- If you dont know what this does, leave it set to false
36+
37+
- If you set this to true, it means that the task will only receive events it has not already received
38+
39+
- If you set this to false, it means that the task will receive all events of its timeframe, everytime it is polled
40+
(e.g. task gets events provided until they fall out of the timeframe)-->
3541
<OnlyNew>
3642
False
3743
</OnlyNew>
@@ -81,7 +87,13 @@
8187
3600
8288
</LockTime>
8389

84-
<!-- this is used for rules that only need new events for evaluating. If you dont know what this does, leave it set to false-->
90+
<!-- this is used for rules that only need new events for evaluating.
91+
- If you dont know what this does, leave it set to false
92+
93+
- If you set this to true, it means that the task will only receive events it has not already received
94+
95+
- If you set this to false, it means that the task will receive all events of its timeframe, everytime it is polled
96+
(e.g. task gets events provided until they fall out of the timeframe)-->
8597
<OnlyNew>
8698
False
8799
</OnlyNew>
@@ -130,7 +142,13 @@
130142
3600
131143
</LockTime>
132144

133-
<!-- this is used for rules that only need new events for evaluating. If you dont know what this does, leave it set to false-->
145+
<!-- this is used for rules that only need new events for evaluating.
146+
- If you dont know what this does, leave it set to false
147+
148+
- If you set this to true, it means that the task will only receive events it has not already received
149+
150+
- If you set this to false, it means that the task will receive all events of its timeframe, everytime it is polled
151+
(e.g. task gets events provided until they fall out of the timeframe)-->
134152
<OnlyNew>
135153
False
136154
</OnlyNew>
@@ -177,10 +195,18 @@
177195
<LockTime>
178196
3600
179197
</LockTime>
180-
<!-- this is used for rules that only need new events for evaluating. If you dont know what this does, leave it set to false-->
198+
199+
<!-- this is used for rules that only need new events for evaluating.
200+
- If you dont know what this does, leave it set to false
201+
202+
- If you set this to true, it means that the task will only receive events it has not already received
203+
204+
- If you set this to false, it means that the task will receive all events of its timeframe, everytime it is polled
205+
(e.g. task gets events provided until they fall out of the timeframe)-->
181206
<OnlyNew>
182207
False
183208
</OnlyNew>
209+
184210
<!-- this is the timeframe (in seconds) to be inspected-->
185211
<EventAge>
186212
120
@@ -217,7 +243,14 @@
217243
<LockTime>
218244
3600
219245
</LockTime>
220-
<!-- this is used for rules that only need new events for evaluating. If you dont know what this does, leave it set to false-->
246+
247+
<!-- this is used for rules that only need new events for evaluating.
248+
- If you dont know what this does, leave it set to false
249+
250+
- If you set this to true, it means that the task will only receive events it has not already received
251+
252+
- If you set this to false, it means that the task will receive all events of its timeframe, everytime it is polled
253+
(e.g. task gets events provided until they fall out of the timeframe)-->
221254
<OnlyNew>
222255
False
223256
</OnlyNew>

Source/EvlWatcherConsole/EvlWatcherConsole/Properties/AssemblyInfo.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
[assembly: AssemblyConfiguration("")]
1111
[assembly: AssemblyCompany("")]
1212
[assembly: AssemblyProduct("EvlWatcherConsole")]
13-
[assembly: AssemblyCopyright("2020 Michael Schönbauer")]
13+
[assembly: AssemblyCopyright("2022 Michael Schönbauer")]
1414
[assembly: AssemblyTrademark("")]
1515
[assembly: AssemblyCulture("")]
1616

@@ -49,5 +49,5 @@
4949
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
5050
// übernehmen, indem Sie "*" eingeben:
5151
// [assembly: AssemblyVersion("1.0.*")]
52-
[assembly: AssemblyVersion("2.1.4.0")]
53-
[assembly: AssemblyFileVersion("2.1.4.0")]
52+
[assembly: AssemblyVersion("2.1.5.0")]
53+
[assembly: AssemblyFileVersion("2.1.5.0")]

0 commit comments

Comments
 (0)