Example #1
0
 public void LogData(byte[] buffer, string sender, int count)
 {
     if (_format != null && _format.Equals("dll"))
     {
         // do dll based logging.
         return;
     }
     writer.LogTransmission(buffer, sender, count);
 }
Example #2
0
        public int ProcessData()
        {
            int ret = SetDecryptor(decrypto.dll);

            if (ret != 0)
            {
                return(ret);
            }
            if (decrypto.format.Equals("json"))
            {
                var    output      = new IntPtr();
                var    output_size = 0;
                string sender      = "";
                reader = new JSONLogWriter();
                reader.Open(decrypto.input, "r");
                Transmissions trans = reader.ReadTransmission();
                foreach (LogEvent e in trans.LogEventList)
                {
                    try
                    {
                        if (e.sender == CLIENT)
                        {
                            sender = "client";
                        }
                        else
                        {
                            sender = "server";
                        }
                        Console.WriteLine("sender: {0} packet: {1} length: {2}", sender, e.count, e.data.Length);
                        Decrypt.Decrypt(e.sender, e.data, e.data.Length, e.count, ref output, ref output_size);
                        byte[] decrypted = new byte[output_size];
                        Marshal.Copy(output, decrypted, 0, output_size);
                        Console.WriteLine("\nAfter decrypt: {0}", Encoding.ASCII.GetString(decrypted));
                        Console.WriteLine("--------------------------------------");
                        if (writer != null)
                        {
                            writer.LogTransmission(decrypted, sender, e.count);
                        }
                    }
                    finally
                    {
                        if (output != IntPtr.Zero)
                        {
                            Marshal.FreeCoTaskMem(output);
                        }
                    }
                }
            }

            return(0);
        }