-
Notifications
You must be signed in to change notification settings - Fork 29
/
Program.cs
28 lines (24 loc) · 840 Bytes
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
using System;
using System.Threading.Tasks;
using WindivertDotnet;
namespace App
{
internal class Program
{
static async Task Main(string[] args)
{
var filter = Filter.True.And(f => f.IsIP && f.IsTcp);
using var divert = new WinDivert(filter, WinDivertLayer.Network);
using var packet = new WinDivertPacket();
using var addr = new WinDivertAddress();
while (true)
{
var recvLength = await divert.RecvAsync(packet, addr);
var result = packet.GetParseResult();
var checkState = packet.CalcChecksums(addr);
var sendLength = await divert.SendAsync(packet, addr);
Console.WriteLine($"{result.Protocol} {recvLength} {sendLength}");
}
}
}
}