예제 #1
0
 static void DebugPrint()
 {
     foreach (IP iP in IPManager.GetInstance().Values)
     {
         Console.WriteLine("Ip: " + iP + " count: " + iP.Count);
     }
 }
예제 #2
0
        static void Main(string[] args)
        {
#if DEBUG
            DebugPrint();
#endif
            Logger l = Logger.GetINSTANCE();
            if (Debug())
            {
                l.LogRun();
            }
            if (!IsAdmin())
            {
                l.LogMissingAdmin();
                l.Close();
                Environment.Exit(0);
            }

            WhitelistSection           wlSection = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None).Sections["whitelistSection"] as WhitelistSection;
            WhitelistElementCollection wlColl    = wlSection.Whitelisted;
            List <IPrange>             whitelist = new List <IPrange>();
            foreach (WhitelistElement element in wlColl)
            {
                whitelist.Add(new IPrange(element.IP, element.Range, 0, false));
            }

            FileSettingSection           fsSection = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None).Sections["fileSettingsSection"] as FileSettingSection;
            FileSettingElementCollection fsColl    = fsSection.FileSettings;
            foreach (FileSettingElement element in fsColl)
            {
                FileReader.ReadFolder(element);
                if (Debug())
                {
                    Console.WriteLine("{0}: {1}", element.RuleName, element.ReadPath);
                }
            }



#if DEBUG
            DebugPrint();
            //FirewallManager.BlockIPs(IPManager.GetInstance().Values, whitelist);
            Console.ReadKey();
#else
            if (Debug())
            {
                DebugPrint();
            }
            FirewallManager.BlockIPs(IPManager.GetInstance().Values, whitelist);
#endif
            l.Close();
        }