Exemplo n.º 1
0
        // This is unnecessary in managed code if this is all it does, since it will
        // be set to zeros.
        private IPStatusRec MakeNewStatusRec()
        {
            IPStatusRec StatusRec = new IPStatusRec();
            StatusRec.TimeIndex = 0;
            StatusRec.Port80Count = 0;
            StatusRec.Port443Count = 0;
            StatusRec.SentText = "";
            StatusRec.HackerCount = 0;
            StatusRec.TimedOutCount = 0;
            StatusRec.BadWebPageCount = 0;
            StatusRec.GoodWebRequestCount = 0;
            StatusRec.Referer = "";
            StatusRec.UserAgent = "";
            StatusRec.HostName = "";
            StatusRec.LastHostNameUpdate = 0;
            StatusRec.GetPublicKeyCount = 0;
            StatusRec.TotalGetPublicKeyCount = 0;
            StatusRec.ConfirmBillingCount = 0;
            StatusRec.TotalConfirmBillingCount = 0;

            return StatusRec;
        }
Exemplo n.º 2
0
        internal bool ReadFromFile()
        {
            IPsDictionary.Clear();
            RefererDictionary.Clear();
            UserAgentDictionary.Clear();

            string FileName = MForm.GetDataDirectory() + "NetStats.txt";
            // ECTime RecTime = new ECTime();

            try
            {
            string Line;
            using( StreamReader SReader = new StreamReader( FileName  ))
              {
              while( SReader.Peek() >= 0 )
            {
            Line = SReader.ReadLine();
            if( Line == null )
              continue;

            // Keep the tabs here.
            // Line = Line.Trim();
            if( Line.Length < 3 )
              continue;

            if( !Line.Contains( "\t" ))
              continue;

            string[] SplitS = Line.Split( new Char[] { '\t' } );
            if( SplitS.Length < 23 )
              continue;

            string Key = SplitS[0].Trim();
            if( Key.Length < 7 ) // 1.2.3.4
              continue;

            IPStatusRec StatusRec = new IPStatusRec();
            try
            {
            int Field = 3;
            StatusRec.TimeIndex = (ulong)Int64.Parse( SplitS[Field].Trim() );
            Field++;
            StatusRec.HackerCount = Int32.Parse( SplitS[Field].Trim() );
            Field++;
            StatusRec.TimedOutCount = Int32.Parse( SplitS[Field].Trim() );
            Field++;
            StatusRec.GoodWebRequestCount = Int32.Parse( SplitS[Field].Trim() );
            Field++;
            StatusRec.TotalGoodWebRequestCount = Int32.Parse( SplitS[Field].Trim() );
            Field++;
            StatusRec.Port80Count = Int32.Parse( SplitS[Field].Trim() );
            Field++;
            StatusRec.Port443Count = Int32.Parse( SplitS[Field].Trim() );
            Field++;
            StatusRec.Referer = SplitS[Field].Trim();
            Field++;
            StatusRec.UserAgent = SplitS[Field].Trim();
            Field++;
            StatusRec.HostName = SplitS[Field].Trim();
            Field++;
            StatusRec.LastHostNameUpdate = (ulong)Int64.Parse( SplitS[Field].Trim() );
            Field++;
            StatusRec.BadWebPageCount = Int32.Parse( SplitS[Field].Trim() );
            // Field++;

            }
            catch( Exception )
              {
              continue;
              }

            IPsDictionary[Key] = StatusRec;
            }
              }

            return true;

            }
            catch( Exception Except )
              {
              MForm.ShowStatus( "Could not read the NetStats file." + "\r\n" + Except.Message );
              return false;
              }
        }