示例#1
0
        private void Dispose()
        {
            _transfer = null;
            _IPRange  = null;

            _firstPacket   = null;
            _connection    = null;
            _connectionUDP = null;

            _connetionRecvBuffer    = null;
            _remoteHeaderSendBuffer = null;

            httpProxyState = null;
        }
示例#2
0
 private void RspHttpHandshakeReceive()
 {
     command = 1; // Set TCP connect command
     if (httpProxyState == null)
     {
         httpProxyState = new HttpPraser();
     }
     if (Util.Utils.isMatchSubNet(((IPEndPoint)_connection.RemoteEndPoint).Address, "127.0.0.0/8"))
     {
         httpProxyState.httpAuthUser = "";
         httpProxyState.httpAuthPass = "";
     }
     else
     {
         httpProxyState.httpAuthUser = _config.authUser;
         httpProxyState.httpAuthPass = _config.authPass;
     }
     for (int i = 1; ; ++i)
     {
         int err = httpProxyState.HandshakeReceive(_firstPacket, _firstPacketLength, ref _remoteHeaderSendBuffer);
         if (err == 1)
         {
             if (HttpHandshakeRecv())
             {
                 break;
             }
         }
         else if (err == 2)
         {
             string dataSend = httpProxyState.Http407();
             byte[] httpData = Encoding.UTF8.GetBytes(dataSend);
             _connection.Send(httpData);
             if (HttpHandshakeRecv())
             {
                 break;
             }
         }
         else if (err == 3 || err == 4)
         {
             Connect();
             break;
         }
         else if (err == 0)
         {
             local_sendback_protocol = "http";
             Connect();
             break;
         }
         else if (err == 500)
         {
             string dataSend = httpProxyState.Http500();
             byte[] httpData = Encoding.UTF8.GetBytes(dataSend);
             _connection.Send(httpData);
             if (HttpHandshakeRecv())
             {
                 break;
             }
         }
         if (i == 3)
         {
             Close();
             break;
         }
     }
 }