Ejemplo n.º 1
0
        public async Task ResponseAsync <T>(T response, Type packetType) where T : ISyncRpcResponse
        {
            PacketContainer     container    = _packetFactory.ToPacket(response);
            IRoutingInformation routingInfos = await CheckRouting(packetType);

            await SendAsync(container, routingInfos);
        }
Ejemplo n.º 2
0
        private void openFile()
        {
            DialogResult res = this.openFileDialog1.ShowDialog(this);

            this.packetContainer = null;

            // Dateierweiterung Checken
            if (Path.GetExtension(this.openFileDialog1.FileName).ToLower().Equals(".pcap") && res == DialogResult.OK)
            {
                this.packetContainer = new PacketContainer();
                this.settingsForm.ShowDialog(this);
                this.pcapReader = new FileReader(this.packetContainer, this.settingsForm.GetPort());
                this.pcapReader.ReadPcapFile(this.openFileDialog1.FileName);
            }
            else if (Path.GetExtension(this.openFileDialog1.FileName).ToLower().Equals(".l2ps") && res == DialogResult.OK)
            {
                this.packetContainer = this.deSerialize(this.openFileDialog1.FileName);
            }
            else if (res == DialogResult.OK)
            {
                MessageBox.Show("File not supported");
                return;
            }
            else
            {
                return;
            }

            this.packetContainer.applyFilter();
            this.fillListbox(this.packetContainer.DisplayedPackets);
            this.hexBox1.ByteProvider = null;
        }
Ejemplo n.º 3
0
 private async Task SendAsync(PacketContainer container, IRoutingInformation routingInfos)
 {
     await _client.PublishAsync(builder => builder
                                .WithPayload(_serializer.Serialize(container))
                                .WithTopic(routingInfos.OutgoingTopic)
                                .WithExactlyOnceQoS());
 }
Ejemplo n.º 4
0
        private void serialize(PacketContainer pcon, string filepath)
        {
            XmlSerializer s = new XmlSerializer(typeof(PacketContainer));
            TextWriter    w = new StreamWriter(filepath);

            s.Serialize(w, pcon);
            w.Close();
        }
Ejemplo n.º 5
0
 public Task BroadcastAsync <T>(T packet) where T : IAsyncRpcRequest
 {
     return(Task.Run(() =>
     {
         PacketContainer tmp = _packetFactory.ToPacket(packet);
         Publish(tmp, _broadcastQueueName);
     }));
 }
Ejemplo n.º 6
0
 public FileReader(PacketContainer pc, int port)
 {
     this.port            = port;
     this.packetContainer = pc;
     this.gameSniffer     = new L2GameSniffer();
     this.clientStr       = new L2PacketStream();
     this.serverStr       = new L2PacketStream();
 }
Ejemplo n.º 7
0
        private void Publish(PacketContainer container, string queueName)
        {
            byte[]           messageBytes = Encoding.UTF8.GetBytes(container.ToString());
            IBasicProperties props        = _channel.CreateBasicProperties();

            props.ReplyTo = queueName;
            _channel.BasicPublish(ExchangeName, queueName, props, messageBytes);
        }
Ejemplo n.º 8
0
        public void Send(PacketContainer <T> packetContainer)
        {
            _sendQueue.Enqueue(packetContainer);

            if (Interlocked.CompareExchange(ref _sending, 1, 0) == 0)
            {
                SendImpl();
            }
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Stellt eine Klasse da die das Sniffen von Packets regelt
 /// </summary>
 /// <param name="pc">Der PacketContainer dem die Packete hinzugefügt werden sollen</param>
 /// <param name="port">Der Port auf den der TCPStreamAssembler horchen soll</param>
 public SnifferControl(PacketContainer pc, int port)
 {
     this.port            = port;
     this.packetContainer = pc;
     this.gameSniffer     = new L2GameSniffer();
     this.clientStr       = new L2PacketStream();
     this.serverStr       = new L2PacketStream();
     // TODO: wenn keine devices gefunden wurden, Meldung
 }
Ejemplo n.º 10
0
        public async Task ResponseAsync <T>(T response, Type packetType) where T : IIpcResponse
        {
            PacketContainer container = _packetFactory.ToPacket <T>(response);

#if DEBUG
            _log.Debug($"[SENT] Packet [{container.Type}]");
#endif
            IRoutingInformation routingInfos = await CheckRouting(packetType);
            await SendAsync(container, routingInfos);
        }
Ejemplo n.º 11
0
        private async Task SendAsync(PacketContainer container)
        {
            IRoutingInformation infos = await CheckRouting(container.Type);

            await _client.PublishAsync(builder =>
                                       builder
                                       .WithPayload(_serializer.Serialize(container))
                                       .WithTopic(infos.IncomingTopic)
                                       .WithExactlyOnceQoS()
                                       );
        }
Ejemplo n.º 12
0
        public FilterForm(PacketContainer pc, KnownPackets kp)
        {
            InitializeComponent();
            this.pc = pc;
            this.kp = kp;

            if (pc != null)
            {
                this.refresh();
            }
        }
Ejemplo n.º 13
0
        public string Serialize()
        {
            PacketContainer cont = new PacketContainer()
            {
                type    = (int)type,
                data    = data,
                created = ServerTime.GetCurrentUnixTimestampMillis()
            };

            return(JsonConvert.SerializeObject(cont));
        }
Ejemplo n.º 14
0
        private async Task SendAsync <T>(PacketContainer container)
        {
            IRoutingInformation infos = GetRoutingInformations <T>();

            MessageSent.WithLabels(_options.ClientOptions.ClientId, infos.Topic).Inc();
            await _client.PublishAsync(builder =>
                                       builder
                                       .WithPayload(_serializer.Serialize(container))
                                       .WithTopic(infos.Topic)
                                       .WithExactlyOnceQoS()
                                       );

            Console.WriteLine("Sent message to topic : " + infos.Topic);
        }
Ejemplo n.º 15
0
        public async Task <T> RequestAsync <T>(ISyncRpcRequest packet) where T : class, ISyncRpcResponse
        {
            // add packet to requests
            PendingRequest request = _requestFactory.Create(packet);

            if (!_pendingRequests.TryAdd(packet.Id, request))
            {
                return(null);
            }

            // create the packet container
            PacketContainer container = _packetFactory.ToPacket(packet.GetType(), packet);

            Publish(container, _requestQueueName);

            ISyncRpcResponse tmp = await request.Response.Task;

            return(tmp as T);
        }
Ejemplo n.º 16
0
        public async Task <TResponse> RequestAsync <TResponse>(IIpcRequest packet) where TResponse : class, IIpcResponse
        {
            // add packet to requests
            PendingRequest request = _requestFactory.Create(packet);

            if (!_pendingRequests.TryAdd(packet.Id, request))
            {
                return(null);
            }

            // create the packet container
            PacketContainer container = _packetFactory.ToPacket(packet.GetType(), packet);

            await SendAsync(container);

            IIpcResponse tmp = await request.Response.Task;

            return(tmp as TResponse);
        }
Ejemplo n.º 17
0
        private void toolStripButtonNewCapture_Click(object sender, EventArgs e)
        {
            this.packetContainer = new PacketContainer();
            this.sniffer         = new SnifferControl(this.packetContainer, this.devicesForm.GetPort());
            this.sniffer.Init(this.devicesForm.GetDevice(), ("port " + this.devicesForm.GetPort()));
            this.sniffer.Start();
            this.fillListbox(this.packetContainer.DisplayedPackets);
            this.toolStripButtonStopCatpure.Enabled = true;
            this.toolStripButtonNewCapture.Enabled  = false;
            this.toolStripButtonListDevices.Enabled = false;
            this.toolStripButtonOpenFile.Enabled    = false;
            this.openToolStripMenuItem.Enabled      = false;

            this.hexBox1.ByteProvider = null;

            // Event Anmelden
            this.sniffer.NewPacketArrived += new SnifferControl.NewPacketHandler(packethandler_onPacketAdded);
            this.sniffer.OnSynRecived     += new SnifferControl.SynRecivedEventHandler(sniffer_OnSynRecived);
            this.sniffer.OnFinRecived     += new SnifferControl.FinRecivedEventHandler(sniffer_OnFinRecived);
            this.ChangeStatusLabel("Waiting for Connection", Color.Black);
        }
Ejemplo n.º 18
0
        public Task BroadcastAsync <T>(T packet) where T : IAsyncRpcRequest
        {
            PacketContainer container = _packetFactory.ToPacket(packet);

            return(SendAsync <T>(container));
        }
Ejemplo n.º 19
0
        public Task BroadcastAsync <T>(T packet) where T : IIpcPacket
        {
            PacketContainer container = _packetFactory.ToPacket(typeof(T), packet);

            return(SendAsync(container));
        }