Beispiel #1
0
        private void OnConnected(IAsyncResult ar)
        {
            try
            {
                DestinationSocket.EndConnect(ar);
                string rq;
                if (HttpRequestType.ToUpper().Equals("CONNECT"))
                { //HTTPS
                    rq = HttpVersion + " 200 Connection established\r\nProxy-Agent: DoctorProxy Proxy Server\r\n\r\n";
                    ClientSocket.BeginSend(Encoding.ASCII.GetBytes(rq), 0, rq.Length, SocketFlags.None, new AsyncCallback(this.OnOkSent), ClientSocket);
                }
                else
                { //Normal HTTP
                    rq = RebuildQuery();

                    //اینجا لاگ کن
                    DestinationSocket.BeginSend(Encoding.ASCII.GetBytes(rq), 0, rq.Length, SocketFlags.None, new AsyncCallback(this.OnQuerySent), DestinationSocket);
                }
            }
            catch (Exception ex)
            {
                Log.Write(MethodInfo.GetCurrentMethod(), ex);
                Dispose();
            }
        }
        private void OnConnected(IAsyncResult ar)
        {
            try
            {
                if (DestinationSocket == null)
                {
                    return;
                }

                string str;
                DestinationSocket.EndConnect(ar);
                if (HttpRequestType.ToUpper().Equals("CONNECT"))
                {
                    if (ClientSocket != null)
                    {
                        str = HttpVersion + " 200 Connection established\r\n\r\n";
                        ClientSocket.BeginSend(Encoding.ASCII.GetBytes(str), 0, str.Length, SocketFlags.None, OnOkSent,
                                               ClientSocket);
                    }
                }
                else
                {
                    str = RebuildQuery();
                    DestinationSocket.BeginSend(Encoding.ASCII.GetBytes(str), 0, str.Length, SocketFlags.None,
                                                OnQuerySent, DestinationSocket);
                }
            }
            catch
            {
                Dispose();
            }
        }
Beispiel #3
0
 ///<summary>Called when the socket is connected to the remote host.</summary>
 ///<remarks>When the socket is connected to the remote host, the PortMapClient begins relaying traffic between the host and the client, until one of them closes the connection.</remarks>
 ///<param name="ar">The result of the asynchronous operation.</param>
 private void OnConnected(IAsyncResult ar)
 {
     try {
         DestinationSocket.EndConnect(ar);
         StartRelay();
     } catch {
         Dispose();
     }
 }
Beispiel #4
0
 ///<summary>Called when we send TYPE command.</summary>
 ///<param name="ar">The result of the asynchronous operation.</param>
 private void OnPasvConnected(IAsyncResult ar)
 {
     try
     {
         DestinationSocket.EndConnect(ar);
         string rq = "TYPE I\r\n";
         DestinationFtpSocket.BeginSend(Encoding.ASCII.GetBytes(rq), 0, rq.Length, SocketFlags.None, new AsyncCallback(this.OnTypeQuerySent), DestinationFtpSocket);
     }
     catch
     {
         Dispose();
     }
 }
Beispiel #5
0
 ///<summary>Called when we're connected to the data port of the remote FTP server.</summary>
 ///<param name="ar">The result of the asynchronous operation.</param>
 private void OnPasvConnected(IAsyncResult ar)
 {
     try {
         DestinationSocket.EndConnect(ar);
         ListenSocket = new Socket(IPAddress.Any.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
         ListenSocket.Bind(new IPEndPoint(IPAddress.Any, 0));
         ListenSocket.Listen(1);
         ListenSocket.BeginAccept(new AsyncCallback(this.OnPasvAccept), ListenSocket);
         Parent.SendCommand("227 Entering Passive Mode (" + Listener.GetLocalInternalIP().ToString().Replace('.', ',') + "," + Math.Floor(((IPEndPoint)ListenSocket.LocalEndPoint).Port / 256d).ToString() + "," + (((IPEndPoint)ListenSocket.LocalEndPoint).Port % 256).ToString() + ").\r\n");
     } catch {
         Dispose();
     }
 }
Beispiel #6
0
 ///<summary>Called when we're connected to the remote FTP server.</summary>
 ///<param name="ar">The result of the asynchronous operation.</param>
 private void OnRemoteConnected(IAsyncResult ar)
 {
     try {
         DestinationSocket.EndConnect(ar);
         ClientSocket.BeginReceive(Buffer, 0, Buffer.Length, SocketFlags.None, new AsyncCallback(this.OnReceiveCommand), ClientSocket);
         if (User.Equals(""))
         {
             DestinationSocket.BeginReceive(RemoteBuffer, 0, RemoteBuffer.Length, SocketFlags.None, new AsyncCallback(this.OnReplyReceived), DestinationSocket);
         }
         else
         {
             DestinationSocket.BeginReceive(RemoteBuffer, 0, RemoteBuffer.Length, SocketFlags.None, new AsyncCallback(this.OnIgnoreReply), DestinationSocket);
         }
     } catch {
         Dispose();
     }
 }
Beispiel #7
0
 private void OnConnected(IAsyncResult ar)
 {
     try {
         DestinationSocket.EndConnect(ar);
         string rq;
         if (HttpRequestType.ToUpper().Equals("CONNECT"))           //HTTPS
         {
             rq = HttpVersion + " 200 Connection established\r\nProxy-Agent: xProxy Server\r\n\r\n";
             ClientSocket.BeginSend(Encoding.ASCII.GetBytes(rq), 0, rq.Length, SocketFlags.None, new AsyncCallback(this.OnOkSent), ClientSocket);
         }
         else             //Normal HTTP
         {
             rq = RebuildQuery();
             DestinationSocket.BeginSend(Encoding.ASCII.GetBytes(rq), 0, rq.Length, SocketFlags.None, new AsyncCallback(this.OnQuerySent), DestinationSocket);
         }
     } catch {
         Dispose();
     }
 }
        ///<summary>Called when we're connected to the requested remote host.</summary>
        ///<param name="ar">The result of the asynchronous operation.</param>
        private void OnConnected(IAsyncResult ar)
        {
            try
            {
                DestinationSocket.EndConnect(ar);

                if (OnConnectedEnd != null)
                {
                    OnConnectedEnd.Invoke(DestinationSocket, this);
                }
                if (Cancel)
                {
                    SendCancelledResponse();
                    return;
                }

                string rq;
                if (HttpRequestType.ToUpper().Equals("CONNECT"))
                {
                    //HTTPS
                    rq = HttpVersion + " 200 Connection established\r\nProxy-Agent: arachnode.net Proxy Server\r\n\r\n";
                    ClientSocket.BeginSend(Encoding.ASCII.GetBytes(rq), 0, rq.Length, SocketFlags.None, new AsyncCallback(OnOkSent), ClientSocket);
                }
                else
                {
                    //Normal HTTP
                    rq = RebuildQuery();
                    Console.WriteLine(rq);
                    DestinationSocket.BeginSend(Encoding.ASCII.GetBytes(rq), 0, rq.Length, SocketFlags.None, new AsyncCallback(OnQuerySent), DestinationSocket);
                }
            }
            catch
            {
                Dispose();
            }
        }