Skip to content

Commit 470419d

Browse files
authored
Update UdpTimedSender.cs
1 parent 1bf8d31 commit 470419d

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

EchoTspServer/Services/UdpTimedSender.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Linq;
33
using System.Net;
44
using System.Net.Sockets;
5+
using System.Security.Cryptography;
56
using System.Threading;
67
using EchoServer.Abstractions;
78

@@ -15,7 +16,11 @@ public class UdpTimedSender : IDisposable
1516
private readonly UdpClient _udpClient;
1617
private Timer? _timer;
1718
private ushort _counter = 0;
18-
private readonly Random _random = new Random(); // Створюємо один раз як поле класу
19+
20+
// S2245: Random is used only for generating test data payload, not for any security-sensitive operations
21+
#pragma warning disable S2245
22+
private readonly Random _random = new Random();
23+
#pragma warning restore S2245
1924

2025
public UdpTimedSender(string host, int port, ILogger logger)
2126
{
@@ -37,7 +42,7 @@ private void SendMessageCallback(object? state)
3742
try
3843
{
3944
byte[] samples = new byte[1024];
40-
_random.NextBytes(samples); // Використовуємо поле класу замість локальної змінної
45+
_random.NextBytes(samples);
4146
_counter++;
4247

4348
byte[] msg = (new byte[] { 0x04, 0x84 })

0 commit comments

Comments
 (0)