예제 #1
0
        static void UpdateProxyLogAndGrid()
        {
            Response[] DequedResponses;
            lock (ProxyResponseQ)
            {
                DequedResponses = ProxyResponseQ.ToArray();
                ProxyResponseQ.Clear();
            }

            List <Response> Responses = new List <Response>();

            foreach (Response Res in DequedResponses)
            {
                try
                {
                    if (Res == null)
                    {
                        IronException.Report("Null Response DeQed from Proxy Response Q", "Null Response DeQed from Proxy Response Q");
                        continue;
                    }
                    Res.StoredHeadersString = Res.GetHeadersAsString();
                    if (Res.IsBinary)
                    {
                        Res.StoredBinaryBodyString = Res.BinaryBodyString;
                    }
                    Responses.Add(Res);
                }
                catch (Exception Exp)
                {
                    IronException.Report("Error preparing Response for UI & DB Update", Exp.Message, Exp.StackTrace);
                }
            }

            Response[]      DequedOriginalResponses;
            List <Response> OriginalResponses = new List <Response>();

            lock (ProxyOriginalResponseQ)
            {
                DequedOriginalResponses = ProxyOriginalResponseQ.ToArray();
                ProxyOriginalResponseQ.Clear();
            }
            foreach (Response Res in DequedOriginalResponses)
            {
                try
                {
                    if (Res == null)
                    {
                        IronException.Report("Null Response DeQed from Original Proxy Response Q", "Null Response DeQed from Original Proxy Response Q");
                        continue;
                    }
                    Res.StoredHeadersString = Res.GetHeadersAsString();
                    if (Res.IsBinary)
                    {
                        Res.StoredBinaryBodyString = Res.BinaryBodyString;
                    }
                    OriginalResponses.Add(Res);
                }
                catch (Exception Exp)
                {
                    IronException.Report("Error preparing Original Response for UI & DB Update", Exp.Message, Exp.StackTrace);
                }
            }
            Response[]      DequedEditedResponses;
            List <Response> EditedResponses = new List <Response>();

            lock (ProxyEditedResponseQ)
            {
                DequedEditedResponses = ProxyEditedResponseQ.ToArray();
                ProxyEditedResponseQ.Clear();
            }
            foreach (Response Res in DequedEditedResponses)
            {
                try
                {
                    if (Res == null)
                    {
                        IronException.Report("Null Response DeQed from Edited Proxy Response Q", "Null Response DeQed from Edited Proxy Response Q");
                        continue;
                    }
                    Res.StoredHeadersString = Res.GetHeadersAsString();
                    if (Res.IsBinary)
                    {
                        Res.StoredBinaryBodyString = Res.BinaryBodyString;
                    }
                    EditedResponses.Add(Res);
                }
                catch (Exception Exp)
                {
                    IronException.Report("Error preparing Edited Response for UI & DB Update", Exp.Message, Exp.StackTrace);
                }
            }

            Request[]      DequedRequests;
            List <Request> Requests = new List <Request>();

            lock (ProxyRequestQ)
            {
                DequedRequests = ProxyRequestQ.ToArray();
                ProxyRequestQ.Clear();
            }
            foreach (Request Req in DequedRequests)
            {
                try
                {
                    if (Req == null)
                    {
                        IronException.Report("Null Request DeQed from Proxy Request Q", "Null Request DeQed from Proxy Request Q");
                        continue;
                    }
                    Req.StoredFile          = Req.File;
                    Req.StoredParameters    = Req.GetParametersString();
                    Req.StoredHeadersString = Req.GetHeadersAsString();
                    if (Req.IsBinary)
                    {
                        Req.StoredBinaryBodyString = Req.BinaryBodyString;
                    }
                    Urls.Add(GetUrlForList(Req));
                    Requests.Add(Req);
                }
                catch (Exception Exp)
                {
                    IronException.Report("Error preparing Proxy Request for UI & DB Update", Exp.Message, Exp.StackTrace);
                }
            }

            Request[]      DequedOriginalRequests;
            List <Request> OriginalRequests = new List <Request>();

            lock (ProxyOriginalRequestQ)
            {
                DequedOriginalRequests = ProxyOriginalRequestQ.ToArray();
                ProxyOriginalRequestQ.Clear();
            }
            foreach (Request Req in DequedOriginalRequests)
            {
                try
                {
                    if (Req == null)
                    {
                        IronException.Report("Null Request DeQed from Proxy Original Request Q", "Null Request DeQed from Proxy Original Request Q");
                        continue;
                    }
                    Req.StoredFile          = Req.File;
                    Req.StoredParameters    = Req.GetParametersString();
                    Req.StoredHeadersString = Req.GetHeadersAsString();
                    if (Req.IsBinary)
                    {
                        Req.StoredBinaryBodyString = Req.BinaryBodyString;
                    }
                    Urls.Add(GetUrlForList(Req));
                    OriginalRequests.Add(Req);
                }
                catch (Exception Exp)
                {
                    IronException.Report("Error preparing Original Request for UI & DB Update", Exp.Message, Exp.StackTrace);
                }
            }

            Request[]      DequedEditedRequests;
            List <Request> EditedRequests = new List <Request>();

            lock (ProxyEditedRequestQ)
            {
                DequedEditedRequests = ProxyEditedRequestQ.ToArray();
                ProxyEditedRequestQ.Clear();
            }
            foreach (Request Req in DequedEditedRequests)
            {
                try
                {
                    if (Req == null)
                    {
                        IronException.Report("Null Request DeQed from Proxy Edited Request Q", "Null Request DeQed from Proxy Edited Request Q");
                        continue;
                    }
                    Req.StoredFile          = Req.File;
                    Req.StoredParameters    = Req.GetParametersString();
                    Req.StoredHeadersString = Req.GetHeadersAsString();
                    if (Req.IsBinary)
                    {
                        Req.StoredBinaryBodyString = Req.BinaryBodyString;
                    }
                    Urls.Add(GetUrlForList(Req));
                    EditedRequests.Add(Req);
                }
                catch (Exception Exp)
                {
                    IronException.Report("Error preparing Edited Request for UI & DB Update", Exp.Message, Exp.StackTrace);
                }
            }

            List <Session> IronSessions = new List <Session>();

            if (Requests.Count > 0 || Responses.Count > 0 || OriginalRequests.Count > 0 || OriginalResponses.Count > 0 || EditedRequests.Count > 0 || EditedResponses.Count > 0)
            {
                IronDB.LogProxyMessages(IronSessions, Requests, Responses, OriginalRequests, OriginalResponses, EditedRequests, EditedResponses);
            }
            if (Requests.Count > 0 | Responses.Count > 0)
            {
                IronUI.UpdateProxyLogGrid(Requests, Responses);
            }

            Response[][] DequedResponseArrs;
            lock (ProxyResponseListQ)
            {
                DequedResponseArrs = ProxyResponseListQ.ToArray();
                ProxyResponseListQ.Clear();
            }

            List <Response[]> ResponseArrs = new List <Response[]>();

            foreach (Response[] ResArr in DequedResponseArrs)
            {
                try
                {
                    if (ResArr.Length == 2)
                    {
                        if (ResArr[1] == null)
                        {
                            IronException.Report("Null Response DeQed from Proxy Response Q", "Null Response DeQed from Proxy Response Q");
                            continue;
                        }

                        if (ResArr[0] != null)
                        {
                            ResArr[0].StoredHeadersString = ResArr[0].GetHeadersAsString();
                            if (ResArr[0].IsBinary)
                            {
                                ResArr[0].StoredBinaryBodyString = ResArr[0].BinaryBodyString;
                            }
                        }
                        ResArr[1].StoredHeadersString = ResArr[1].GetHeadersAsString();
                        if (ResArr[1].IsBinary)
                        {
                            ResArr[1].StoredBinaryBodyString = ResArr[1].BinaryBodyString;
                        }

                        ResponseArrs.Add(ResArr);
                    }
                }
                catch (Exception Exp)
                {
                    IronException.Report("Error preparing Response for UI & DB Update", Exp.Message, Exp.StackTrace);
                }
            }

            Request[][]      DequedRequestArrs;
            List <Request[]> RequestArrs = new List <Request[]>();

            lock (ProxyRequestListQ)
            {
                DequedRequestArrs = ProxyRequestListQ.ToArray();
                ProxyRequestListQ.Clear();
            }
            foreach (Request[] ReqArr in DequedRequestArrs)
            {
                try
                {
                    if (ReqArr.Length == 2)
                    {
                        if (ReqArr[1] == null)
                        {
                            IronException.Report("Null Request DeQed from Proxy Request Q", "Null Request DeQed from Proxy Request Q");
                            continue;
                        }
                        if (ReqArr[0] != null)
                        {
                            ReqArr[0].StoredFile          = ReqArr[0].File;
                            ReqArr[0].StoredParameters    = ReqArr[0].GetParametersString();
                            ReqArr[0].StoredHeadersString = ReqArr[0].GetHeadersAsString();
                            if (ReqArr[0].IsBinary)
                            {
                                ReqArr[0].StoredBinaryBodyString = ReqArr[0].BinaryBodyString;
                            }
                            Urls.Add(GetUrlForList(ReqArr[0]));
                        }
                        ReqArr[1].StoredFile          = ReqArr[1].File;
                        ReqArr[1].StoredParameters    = ReqArr[1].GetParametersString();
                        ReqArr[1].StoredHeadersString = ReqArr[1].GetHeadersAsString();
                        if (ReqArr[1].IsBinary)
                        {
                            ReqArr[1].StoredBinaryBodyString = ReqArr[1].BinaryBodyString;
                        }
                        Urls.Add(GetUrlForList(ReqArr[1]));

                        RequestArrs.Add(ReqArr);
                    }
                }
                catch (Exception Exp)
                {
                    IronException.Report("Error preparing Proxy Request for UI & DB Update", Exp.Message, Exp.StackTrace);
                }
            }

            if (RequestArrs.Count > 0 || ResponseArrs.Count > 0)
            {
                IronDB.LogProxyMessages(RequestArrs, ResponseArrs);
                IronUI.UpdateProxyLogGridWithArrs(RequestArrs, ResponseArrs);
            }
        }
예제 #2
0
        static void UpdateProbeLogAndGrid()
        {
            Response[] DequedResponses;
            lock (ProbeResponseQ)
            {
                DequedResponses = ProbeResponseQ.ToArray();
                ProbeResponseQ.Clear();
            }
            List <Response> Responses = new List <Response>();

            foreach (Response Res in DequedResponses)
            {
                try
                {
                    if (Res == null)
                    {
                        IronException.Report("Null Response DeQed from Probe Response Q", "Null Response DeQed from Probe Response Q");
                        continue;
                    }
                    Res.StoredHeadersString = Res.GetHeadersAsString();
                    if (Res.IsBinary)
                    {
                        Res.StoredBinaryBodyString = Res.BinaryBodyString;
                    }
                    Responses.Add(Res);
                }
                catch (Exception Exp)
                {
                    IronException.Report("Error preparing Probe Response for UI & DB Update", Exp.Message, Exp.StackTrace);
                }
            }

            Request[] DequedRequests;
            lock (ProbeRequestQ)
            {
                DequedRequests = ProbeRequestQ.ToArray();
                ProbeRequestQ.Clear();
            }
            List <Request> Requests = new List <Request>();

            foreach (Request Req in DequedRequests)
            {
                try
                {
                    if (Req == null)
                    {
                        IronException.Report("Null Request DeQed from Probe Request Q", "Null Request DeQed from Probe Request Q");
                        continue;
                    }
                    Req.StoredFile          = Req.File;
                    Req.StoredParameters    = Req.GetParametersString();
                    Req.StoredHeadersString = Req.GetHeadersAsString();
                    if (Req.IsBinary)
                    {
                        Req.StoredBinaryBodyString = Req.BinaryBodyString;
                    }
                    Requests.Add(Req);
                }
                catch (Exception Exp)
                {
                    IronException.Report("Error preparing Probe Request for UI & DB Update", Exp.Message, Exp.StackTrace);
                }
            }

            List <Session> IronSessions = new List <Session>();

            if (Requests.Count > 0 || Responses.Count > 0)
            {
                IronDB.LogProbeMessages(IronSessions, Requests, Responses);
                IronUI.UpdateProbeLogGrid(Requests, Responses);
            }
        }
예제 #3
0
        static void UpdateOtherSourceLogAndGrid()
        {
            Response[] DequedResponses;
            lock (OtherSourceResponseQ)
            {
                DequedResponses = OtherSourceResponseQ.ToArray();
                OtherSourceResponseQ.Clear();
            }
            List <Response> Responses = new List <Response>();

            foreach (Response Res in DequedResponses)
            {
                try
                {
                    if (Res == null)
                    {
                        IronException.Report("Null Response DeQed from Other Source Response Q", "Null Response DeQed from Other Source Response Q");
                        continue;
                    }
                    Res.StoredHeadersString = Res.GetHeadersAsString();
                    if (Res.IsBinary)
                    {
                        Res.StoredBinaryBodyString = Res.BinaryBodyString;
                    }
                    Responses.Add(Res);
                }
                catch (Exception Exp)
                {
                    IronException.Report("Error preparing Other Source Response for UI & DB Update", Exp.Message, Exp.StackTrace);
                }
            }

            Request[] DequedRequests;
            lock (OtherSourceRequestQ)
            {
                DequedRequests = OtherSourceRequestQ.ToArray();
                OtherSourceRequestQ.Clear();
            }
            List <Request> Requests = new List <Request>();

            foreach (Request Req in DequedRequests)
            {
                try
                {
                    if (Req == null)
                    {
                        IronException.Report("Null Request DeQed from Other Source Request Q", "Null Request DeQed from Other Source Request Q");
                        continue;
                    }
                    Req.StoredFile          = Req.File;
                    Req.StoredParameters    = Req.GetParametersString();
                    Req.StoredHeadersString = Req.GetHeadersAsString();
                    if (Req.IsBinary)
                    {
                        Req.StoredBinaryBodyString = Req.BinaryBodyString;
                    }
                    Requests.Add(Req);
                }
                catch (Exception Exp)
                {
                    IronException.Report("Error preparing Other Source Request for UI & DB Update", Exp.Message, Exp.StackTrace);
                }
            }

            List <Session> IronSessions = new List <Session>();
            Dictionary <string, List <Request> >  SourceSpecificRequestList  = new Dictionary <string, List <Request> >();
            Dictionary <string, List <Response> > SourceSpecificResponseList = new Dictionary <string, List <Response> >();

            if (Requests.Count > 0 || Responses.Count > 0)
            {
                foreach (Request Req in Requests)
                {
                    if (!SourceSpecificRequestList.ContainsKey(Req.Source))
                    {
                        SourceSpecificRequestList[Req.Source] = new List <Request>();
                    }
                    if (!SourceSpecificResponseList.ContainsKey(Req.Source))
                    {
                        SourceSpecificResponseList[Req.Source] = new List <Response>();
                    }
                    SourceSpecificRequestList[Req.Source].Add(Req);
                }
                foreach (Response Res in Responses)
                {
                    if (!SourceSpecificResponseList.ContainsKey(Res.Source))
                    {
                        SourceSpecificResponseList[Res.Source] = new List <Response>();
                    }
                    if (!SourceSpecificRequestList.ContainsKey(Res.Source))
                    {
                        SourceSpecificRequestList[Res.Source] = new List <Request>();
                    }
                    SourceSpecificResponseList[Res.Source].Add(Res);
                }

                foreach (string Source in SourceSpecificRequestList.Keys)
                {
                    IronDB.LogOtherSourceMessages(IronSessions, SourceSpecificRequestList[Source], SourceSpecificResponseList[Source], Source);
                }
                List <Request>  OtherSourceRequests  = new List <Request>();
                List <Response> OtherSourceResponses = new List <Response>();
                if (SourceSpecificRequestList.ContainsKey(IronLog.SelectedOtherSource))
                {
                    OtherSourceRequests  = SourceSpecificRequestList[IronLog.SelectedOtherSource];
                    OtherSourceResponses = SourceSpecificResponseList[IronLog.SelectedOtherSource];
                }

                IronUI.UpdateOtherSourceLogGrid(OtherSourceRequests, OtherSourceResponses, IronLog.SelectedOtherSource, new List <string>(SourceSpecificRequestList.Keys));
            }
        }