Hey i am programming a RDP Bruteforce Protection program for a windows server i own, which even gets attacked after changing the RDP port :/
But i already suffer from logging in console, when there are 2 attacks at mostly same time, the console output "overlaps" like:
Minimalistic code to show what i do basically:
watcher.EventRecordWritten +=
new EventHandler<EventRecordWrittenEventArgs>(EventLogEventRead);
public static async void EventLogEventRead(object obj,
EventRecordWrittenEventArgs arg)
{
if (arg.EventRecord != null)
{
string IP = GetIPFromRecord(arg.EventRecord)
var json = await new HttpClient().GetStringAsync("https://api.ipgeolocationapi.com/geolocate/" + IP);
var jsonDeserialized = new JavaScriptSerializer().Deserialize<dynamic>(json);
string country = jsonDeserialized["name"];
Console.WriteLine("IP:\t" + IP);
Console.WriteLine("Country:\t" + country);
}
else
{
Console.WriteLine("The event instance was null.");
}
}
Full code (without Error Messages Class): Pastebin
So what is the most elegant way to solve such a problem?