///<summary>Called when the HTTP query has been sent to the remote host.</summary>
 ///<param name="ar">The result of the asynchronous operation.</param>
 private void OnQuerySent(IAsyncResult ar)
 {
     try
     {
         if (DestinationSocket.EndSend(ar) == -1)
         {
             Dispose();
             return;
         }
         if (OnQuerySentEnd != null)
         {
             OnQuerySentEnd.Invoke(DestinationSocket, this);
         }
         if (Cancel)
         {
             SendCancelledResponse();
             return;
         }
         StartRelay();
     }
     catch
     {
         Dispose();
     }
 }
Exemple #2
0
        protected void OnRemoteSent(IAsyncResult ar)
        {
            try {
                int Ret = DestinationSocket.EndSend(ar);
                if (Ret > 0)
                {
                    //Capture mostly HTTPS

                    long kaas = is_FullRequest(Buffer, Ret, true, true);

                    if (GOT_ENTIRE_HEADER)
                    {
                        recordedlen += kaas;
                    }
                    Copy(Buffer, 0, postcontent, (int)copyspot, Ret);
                    copyspot += Ret;
                    toggleReq = false;
                    if (GOT_ENTIRE_HEADER && recordedlen >= CURRENTLEN)
                    {
                        capture_to_others(postcontent, (int)copyspot, true);
                        toggleReq         = true;
                        recordedlen       = 0;
                        copyspot          = 0;
                        GOT_ENTIRE_HEADER = false;
                    }


                    ClientSocket.BeginReceive(Buffer, 0, Buffer.Length, SocketFlags.None, new AsyncCallback(this.OnClientReceive), ClientSocket);
                    return;
                }
            } catch {}
            try{
                Dispose();
            } catch {}
        }
Exemple #3
0
 ///<summary>Called when we have sent data to the remote host.<br>When all the data has been sent, we will start receiving again from the local client.</br></summary>
 ///<param name="ar">The result of the asynchronous operation.</param>
 protected void OnRemoteSent(IAsyncResult ar)
 {
     try {
         int Ret = DestinationSocket.EndSend(ar);
         if (Ret > 0)
         {
             ClientSocket.BeginReceive(Buffer, 0, Buffer.Length, SocketFlags.None, new AsyncCallback(this.OnClientReceive), ClientSocket);
             return;
         }
     } catch {}
     Dispose();
 }
Exemple #4
0
 private void OnQuerySent(IAsyncResult ar)
 {
     try {
         if (DestinationSocket.EndSend(ar) == -1)
         {
             Dispose();
             return;
         }
         StartRelay();
     } catch {
         Dispose();
     }
 }
Exemple #5
0
 ///<summary>Called when an FTP command has been successfully sent to the FTP server.</summary>
 ///<param name="ar">The result of the asynchronous operation.</param>
 private void OnCommandSent(IAsyncResult ar)
 {
     try {
         if (DestinationSocket.EndSend(ar) <= 0)
         {
             Dispose();
             return;
         }
         ClientSocket.BeginReceive(Buffer, 0, Buffer.Length, SocketFlags.None, new AsyncCallback(this.OnReceiveCommand), ClientSocket);
     } catch {
         Dispose();
     }
 }
Exemple #6
0
 public void OnRemoteSent(IAsyncResult ar)
 {
     try
     {
         if (DestinationSocket.EndSend(ar) > 0 && ClientSocket != null)
         {
             ClientSocket.BeginReceive(Buffer, 0, Buffer.Length, SocketFlags.None, OnClientReceive, ClientSocket);
         }
     }
     catch { Dispose(); }
     //finally
     //{
     //    Dispose();
     //}
 }
Exemple #7
0
 private void OnQuerySent(IAsyncResult ar)
 {
     try
     {
         if (DestinationSocket.EndSend(ar) == -1)
         {
             Dispose();
             return;
         }
         StartRelay();
     }
     catch (Exception ex)
     {
         Log.Write(MethodInfo.GetCurrentMethod(), ex);
         Dispose();
     }
 }
 private void OnQuerySent(IAsyncResult ar)
 {
     try
     {
         if (DestinationSocket != null && DestinationSocket.EndSend(ar) == -1)
         {
             Dispose();
         }
         else
         {
             StartRelay();
         }
     }
     catch
     {
         Dispose();
     }
 }
Exemple #9
0
        ///<summary>Called when we have sent data to the remote host.<br>When all the data has been sent, we will start receiving again from the local client.</br></summary>
        ///<param name="ar">The result of the asynchronous operation.</param>
        protected void OnRemoteSent(IAsyncResult ar)
        {
            try
            {
                int Ret = DestinationSocket.EndSend(ar);
                if (Ret > 0)
                {
                    ClientSocket.BeginReceive(Buffer, 0, Buffer.Length, SocketFlags.None, new AsyncCallback(this.OnClientReceive), ClientSocket);

                    if (CompleteSendBuffer.Length > 0)
                    {
                        if (OnDataReceived != null)
                        {
                            try
                            {
                                OnDataReceived(CompleteSendBuffer, CompleteReadBuffer);
                            }
                            catch (Exception)
                            {
                            }
                        }

                        CompleteReadBuffer = string.Empty;
                        CompleteSendBuffer = string.Empty;
                        Dispose();
                        return;
                    }
                    else
                    {
                        CompleteSendBuffer += System.Text.Encoding.ASCII.GetString(Buffer, 0, Buffer.Length);
                    }
                    return;
                }
            }
            catch { }
            Dispose();
        }
Exemple #10
0
        ///<summary>Called when we have sent data to the remote host.<br>When all the data has been sent, we will start receiving again from the local client.</br></summary>
        ///<param name="ar">The result of the asynchronous operation.</param>
        protected void OnRemoteSent(IAsyncResult ar)
        {
            lock (_bufferLock)
            {
                try
                {
                    if (DestinationSocket == null)
                    {
                        return;
                    }

                    int Ret = DestinationSocket.EndSend(ar);
                    if (Ret > 0)
                    {
                        if (OnRemoteSentEnd != null)
                        {
                            //OnRemoteSentEnd.BeginInvoke(DestinationSocket, this, _cachedClientBufferHeaders, _cachedClientBuffer, false, null, null);
                            OnRemoteSentEnd.Invoke(DestinationSocket, this, _cachedClientBufferHeaders, _cachedClientBuffer.Count == 0 ? null : _cachedClientBuffer, false);
                        }
                        if (!Cancel)
                        {
                            ClientSocket.BeginReceive(Buffer, 0, Buffer.Length, SocketFlags.None, new AsyncCallback(OnClientReceive), ClientSocket);
                        }
                        else
                        {
                            Dispose();
                        }
                        return;
                    }
                }
                catch
                {
                }
                Dispose();
            }
        }