Walter.Net.HoneyPot
OnDetecting Event (IHoneyPotPortListner)
Example 
Walter.Net.HoneyPot Assembly > Walter.Net.HoneyPot Namespace > IHoneyPotPortListner Interface : OnDetecting Event
Event that is triggered when a Honey-Pot detection occurs, allowing you to listen to port-related incidents.
Syntax
Event Data

The event handler receives an argument of type DetectingEventArgs containing data related to this event. The following DetectingEventArgs properties provide information specific to this event.

PropertyDescription
Gets the detection.  
Remarks
This event is raised whenever there is an attempt to access a monitored port, enabling the implementation of custom logic for handling such incidents. HoneyPotServerListnerOption.LogDataForAudit needs to be enabled and HoneyPotServerListnerOption.MaximumDataSizeToAccept is likely not exceeded however more data can be read by the system if UDP data us used
Example
using Microsoft.Extensions.DependencyInjection;
using System;
            
public class Example
{
    public static void Main()
    {
        // Configure services
        var serviceProvider = new ServiceCollection()
            .UsePortScannerProtection(option =>
            {
                option.Echo = 7;
                option.IgnoreAfterDetection = IgnoreScope.IPAddressAndPort;
            })
            .BuildServiceProvider();
            
        // Retrieve the port scanner detection service
        var portScannerService = serviceProvider.GetRequiredService<IPortScannerDetectionService>();
            
        // Subscribe to the OnPortAccessDetected event
        portScannerService.OnPortAccessDetected += (sender, e) =>
        {
            Console.WriteLine($"Port access detected: IP={e.IPAddress}, Port={e.Port}");
        };
            
        // Loop over each registered listener and add event handlers for detecting port access
        foreach (var listener in portScannerService.Listeners)
        {
            listener.OnDataReceived += OnDataReceived;
            listener.OnDetecting += OnDetecting;
        }
            
        // Start the service
        portScannerService.Start();
            
        // Additional logic here
    }
            
    private static void OnDataReceived(object sender, DataReceivedEventArgs e)
    {
        Console.WriteLine($"Data received from IP={e.IPAddress}, Port={e.Port}");
    }
            
    private static void OnDetecting(object sender, DetectingEventArgs e)
    {
        Console.WriteLine($"Detecting: IP={e.Detection.IPAddress}, Port={e.Detection.Port}");
    }
}
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also