Exemplo n.º 1
0
        internal bool AddClient( TLSClient Client )
        {
            if( Client == null )
              return false;

            Clients[ClientsLast] = Client;
            ClientsLast++;

            if( ClientsLast >= Clients.Length )
              {
              try
              {
              Array.Resize( ref Clients, Clients.Length + 512 );
              }
              catch
            {
            return false;
            }
              }

            // ShowStatus( "Added client at: " + ClientsLast.ToString() );
            return true;
        }
Exemplo n.º 2
0
        /*
        private void FillAllIncomingLines()
          {
          if( ClientsLast <= 0 )
        return;

          for( int Count = 0; Count < ClientsLast; Count++ )
        {
        if( Clients[Count] == null ) // This should never happen but...
          continue;

        // It doesn't need to get any more lines from the client once
        // processing for the message has started.

        if( Clients[Count].GetProcessingStarted())
          continue;

        if( Clients[Count].IsShutDown())
          continue;

        // This can close down the connection on the client if it
        // decides it's getting bad data or for some other reason.
        Clients[Count].FillIncomingLines();
        }
          }
          */
        private void QueueConnectedClient()
        {
            // MForm.ShowStatus( "Top of QueueConnectedClient()." );
            if( !IsEnabled )
              return;

            if( !Listener.Pending())
              return;

            TLSClient NewClient = null;

            try
            {
            TcpClient Client = Listener.AcceptTcpClient();

            // IPAddress.Parse(
            IPEndPoint EndPt = (IPEndPoint)(Client.Client.RemoteEndPoint);
            string Address = EndPt.Address.ToString();
            // int PortNum = EndPt.Port;
            Address = Address.Trim();

            MForm.NetStats.AddToPort443Count( Address );

            if( MForm.NetStats.IsBlockedAddress( Address ))
              {
              Client.Close(); // Disconnect this guy.
              return;
              }

            // See if it needs to update the DNS.
            StartSendingForDns( Address );

            NewClient = new TLSClient( MForm, Client, Address );
            // ShowStatus( "Queue Remote Address: " + Address );
            AddClient( NewClient );

            }
            catch( Exception Except )
              {
              ShowStatus( "Exception in QueueConnectedClient():\r\n" + Except.Message );

              if( NewClient != null )
            {
            // It could be in the Clients array, but it will get removed
            // if it is, since it's shut down.
            NewClient.FreeEverything();
            }
              }
        }