コード例 #1
0
        public void Run(params string[] args)
        {
            PhoneSystem ps     = PhoneSystem.Root;
            String      filter = null;

            if (args.Length > 1)
            {
                filter = args[1];
            }
            BlackList a       = new BlackList();
            DateTime  startAt = DateTime.Now;

            FillBlacklist(a);
            Console.WriteLine("Added entries. time elabpsed {0}", DateTime.Now - startAt);
            startAt = DateTime.Now;
            for (int i = 0; i < 10000; i++)
            {
                if (a.Checker.IsBlackListed("10.172.0.103") == 0)
                {
                    Console.Write('X');
                }
                else
                {
                    Console.Write('.');
                }
                if (a.Checker.IsBlackListed("192.168.4.254") == 0)
                {
                    Console.Write('X');
                }
                else
                {
                    Console.Write('.');
                }
            }
            Console.WriteLine("Checked 20000 times. time elabpsed {0}", DateTime.Now - startAt);
            while (true)
            {
                if (a.Checker.IsBlackListed("10.172.0.103") == 0)
                {
                    Console.Write('X');
                }
                else
                {
                    Console.Write('.');
                }
                if (a.Checker.IsBlackListed("192.168.1.83") == 0)
                {
                    Console.Write('X');
                }
                else
                {
                    Console.Write('.');
                }
                Thread.Sleep(1000);
            }
        }
コード例 #2
0
 void FillBlacklist(BlackList a)
 {
     byte[] addrbytes = new byte[] { 192, 168, 0, 0 };
     for (byte i = 1; i < 5; i++)
     {
         addrbytes[2] = i;
         for (byte j = 1; j < 255; j++)
         {
             addrbytes[3] = j;
             a.InsertOrUpdateEntry(String.Format("{0}.{1}.{2}.{3}", addrbytes[0], addrbytes[1], addrbytes[2], addrbytes[3]), "255.255.255.0", new TimeSpan(0, 30, 0), "Test blocking");
         }
         Console.Write('.');
     }
     Console.WriteLine();
 }