internal static void UpdateSession(Session session)
 {
     if (OnUpdateSession != null)
     {
         OnUpdateSession(session);
     }
 }
 internal static Socket CreateConnectedSocket(IPAddress[] destIPs, int port, Session session)
 {
     Socket socket = null;
     bool flag = false;
     Stopwatch stopwatch = Stopwatch.StartNew();
     Exception exception = null;
     foreach (IPAddress address in destIPs)
     {
         try
         {
             socket = new Socket(address.AddressFamily, SocketType.Stream, ProtocolType.Tcp)
             {
                 NoDelay = true
             };
             socket.Connect(address, port);
             session.HostIP = address.ToString();
             session.Flags["x-hostIP"] = session.HostIP;
             flag = true;
             break;
         }
         catch (Exception exception2)
         {
             exception = exception2;
             session.Flags["x-DNS-Failover"] = session.Flags["x-DNS-Failover"] + "+1";
         }
     }
     session.Timers.ServerConnected = DateTime.Now;
     session.Timers.TCPConnectTime = (int)stopwatch.ElapsedMilliseconds;
     if (!flag)
     {
         throw exception;
     }
     return socket;
 }
 internal ClientChatter(Session oSession, string sData)
 {
     this.m_session = oSession;
     this.Headers = Parser.ParseRequest(sData);
     if ((this.Headers != null) && ("CONNECT" == this.m_headers.HTTPMethod))
     {
         this.m_session.isTunnel = true;
     }
 }
 internal ServerChatter(Session oSession, string sHeaders)
 {
     this._lngLastChunkInfoOffset = -1L;
     this.m_session = oSession;
     this._inHeaders = Parser.ParseResponse(sHeaders);
 }
 internal ServerChatter(Session oSession)
 {
     this._lngLastChunkInfoOffset = -1L;
     this.m_session = oSession;
     this.m_responseData = new MemoryStream(0x4000);
 }
Пример #6
0
 internal static bool IsChunkedBodyComplete(Session m_session, MemoryStream oData, long iStartAtOffset, out long outStartOfLatestChunk, out long outEndOfEntity)
 {
     long num = iStartAtOffset;
     outStartOfLatestChunk = num;
     outEndOfEntity = -1L;
     while (num < oData.Length)
     {
         outStartOfLatestChunk = num;
         oData.Position = num;
         byte[] buffer = new byte[0x20];
         oData.Read(buffer, 0, buffer.Length);
         string sInput = Encoding.ASCII.GetString(buffer);
         int index = sInput.IndexOf("\r\n", StringComparison.Ordinal);
         if (index > -1)
         {
             num += index + 2;
             sInput = sInput.Substring(0, index);
         }
         else
         {
             return false;
         }
         index = sInput.IndexOf(';');
         if (index > -1)
         {
             sInput = sInput.Substring(0, index);
         }
         int iOutput = 0;
         if (!TryHexParse(sInput, out iOutput))
         {
             return true;
         }
         if (iOutput == 0)
         {
             oData.Position = num;
             bool flag = true;
             bool flag2 = false;
             for (int i = oData.ReadByte(); i != -1; i = oData.ReadByte())
             {
                 int num5 = i;
                 if (num5 != 10)
                 {
                     if (num5 != 13)
                     {
                         goto Label_010C;
                     }
                     flag2 = true;
                 }
                 else if (flag2)
                 {
                     if (flag)
                     {
                         outEndOfEntity = oData.Position;
                         oData.Position = oData.Length;
                         return true;
                     }
                     flag = true;
                     flag2 = false;
                 }
                 else
                 {
                     flag2 = false;
                     flag = false;
                 }
                 continue;
             Label_010C:
                 flag2 = false;
                 flag = false;
             }
             return false;
         }
         num += iOutput + 2;
     }
     oData.Position = oData.Length;
     return false;
 }
 internal ClientChatter(Session oSession)
 {
     this.m_session = oSession;
 }
Пример #8
0
        public static void CreateAndExecute(object param)
        {
            ClientPipe clientPipe = new ClientPipe((Socket)param);
            Session session = new Session(clientPipe, null);

            session.Execute();
        }
Пример #9
0
        internal void UpdateSession(Session session)
        {
            try
            {
                lock (lvSessions)
                {
                    sessions.Insert(0, session);
                    //  sessions.Add(session);

                    ListViewItem lvi = new ListViewItem();

                    lvi.Text = (lvSessions.Items.Count+1).ToString();

                    // FullUrl
                    lvi.SubItems.Add(session.Host);
                    lvi.SubItems.Add(session.Request.Headers.RequestPath);
                    lvi.SubItems.Add(session.Request.Headers.HTTPMethod);
                    lvi.SubItems.Add(session.LocalProcessName);

                    this.lvSessions.Items.Insert(0, lvi);
                }
            }
            catch {

            }
            /*
            this.textBox1.Text = session.Request.headers.HTTPMethod + " "
                 + (session.Request.headers.Exists("Host") ? session.Request.headers["Host"] : "")  + " "
                 + session.Request.headers.HTTPVersion + "\r\n" + this.textBox1.Text;  */
        }