public void Listen(DOnReceiveClient onReceiveClient) { ParameterizedThreadStart listenThreadStart = new ParameterizedThreadStart( (obj) => ListenThread(obj as DOnReceiveClient) ); thread = new Thread(listenThreadStart); thread.Start(onReceiveClient); }
private void ListenThread(DOnReceiveClient onReceiveClient) { while (true) { IPEndPoint endPoint = new IPEndPoint(0, 0); byte[] result = socket.Receive(ref endPoint); string endPointIp = endPoint.Address.ToString(); if (Array.Exists(blackList, ip => endPointIp == ip)) { var logger = TunnelierCore.Core.DI.Get <Logger>(); logger.Info($"Client was blocked by black list: {endPointIp.ToString()}"); continue; } onReceiveClient(new ClientMessage(endPoint, result)); } }