Пример #1
0
        public static void Main(string[] args)
        {
            LoadLogConfig();
            log.Info("Main");

            log.Info("Init cache");
            CacheLiveStorage.CoreCache             = new Models.Cache();
            CacheLiveStorage.CoreCache.CustomLists = new List <Models.CacheCustomList>();
            CacheLiveStorage.CoreCache.Domains     = new List <Models.CacheDomain>();
            CacheLiveStorage.CoreCache.IPRanges    = new List <Models.CacheIPRange>();
            CacheLiveStorage.CoreCache.Policies    = new List <Models.CachePolicy>();
            CacheLiveStorage.UdpCache = new System.Collections.Concurrent.ConcurrentDictionary <string, Models.CacheIPRange>();

            //log.Info("Run shell script");
            //RunScriptIfExists();

            log.Info("Starting UDP Server");
            UdpServer.Listen();

            log.Info("Starting CoreClient Updater");
            CoreClient.Start();

            var listener    = new Listener();
            var kresUpdater = new KresUpdater();

            log.Info("Starting Knot-Resolver Updater");
            kresUpdater.Start(listener);

            //listener.Listen();

            //log.Info("Starting Public HTTP Listener");
            //var publiclistener = new PublicListener();
            //publiclistener.Listen();

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
            {
                var host = new WebHostBuilder()
                           .UseKestrel(options =>
                {
                    options.Listen(IPAddress.Any, 443, listenOptions =>
                                   listenOptions.UseHttps("sinkhole.pfx", "P@ssw0rd"));
                    options.Listen(IPAddress.Any, 80);
                })
                           .UseContentRoot(Directory.GetCurrentDirectory())
                           .UseIISIntegration()
                           .UseStartup <Startup>()
                           .Build();

                host.Run();
            }
            else
            {
                var host = new WebHostBuilder()
                           .UseKestrel(options =>
                {
                    options.Listen(IPAddress.Any, 443, listenOptions =>
                                   listenOptions.UseHttps("sinkhole.pfx", "P@ssw0rd"));
                    options.Listen(IPAddress.Any, 80);
                })
                           .UseContentRoot(Directory.GetCurrentDirectory())
                           .UseIISIntegration()
                           .UseStartup <Startup>()
                           .Build();

                host.Run();
            }
        }
Пример #2
0
        public static void Main(string[] args)
        {
            //DatLoader.Load(@"c:\var\whalebone\data\57895c20-9a60-42f0-8564-306cb7b844a8.dat");

            LoadLogConfig();
            log.Info("Main");

            log.Info("Init passive dns enricher");
            var pe = new PassiveDNSEnricher();

            pe.Listen();

            log.Info("Init cache");
            CacheLiveStorage.CoreCache             = new Models.Cache();
            CacheLiveStorage.CoreCache.CustomLists = new List <Models.CacheCustomList>();
            CacheLiveStorage.CoreCache.Domains     = new List <Models.CacheDomain>();
            CacheLiveStorage.CoreCache.IPRanges    = new List <Models.CacheIPRange>();
            CacheLiveStorage.CoreCache.Policies    = new List <Models.CachePolicy>();
            CacheLiveStorage.UdpCache = new System.Collections.Concurrent.ConcurrentDictionary <string, Models.CacheIPRange>();

            //log.Info("Run shell script");
            //RunScriptIfExists();

            //CoreClient.TestCoreCache(@"c:\var\whalebone\data\540_resolver_cache.bin", "seznam.cz");

            log.Info("Starting UDP Server");
            UdpServer.Listen();

            log.Info("Starting CoreClient Updater");
            CoreClient.Start();

            var listener    = new Listener();
            var kresUpdater = new KresUpdater();

            log.Info("Starting Knot-Resolver Updater");
            kresUpdater.Start(listener);

            //comment back in to enable custom API
            log.Info("Starting custom API");
            listener.Listen();

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
            {
                var host = new WebHostBuilder()
                           .UseKestrel(options =>
                {
                    options.Listen(IPAddress.Any, 443, listenOptions =>
                                   listenOptions.UseHttps("sinkhole.pfx", "P@ssw0rd"));
                    options.Listen(IPAddress.Any, 80);
                })
                           .UseContentRoot(Directory.GetCurrentDirectory())
                           .UseIISIntegration()
                           .UseStartup <Startup>()
                           .Build();

                host.Run();
            }
            else
            {
                var host = new WebHostBuilder()
                           .UseKestrel(options =>
                {
                    options.Listen(IPAddress.Any, 443, listenOptions =>
                                   listenOptions.UseHttps("sinkhole.pfx", "P@ssw0rd"));
                    options.Listen(IPAddress.Any, 8080);
                })
                           .UseContentRoot(Directory.GetCurrentDirectory())
                           .UseIISIntegration()
                           .UseStartup <Startup>()
                           .Build();

                host.Run();
            }
        }