Пример #1
0
        private static void Main(string[] args)
        {
            Console.CancelKeyPress += Console_CancelKeyPress;

            _zoneProvider = new APZoneProvider();
            _zoneResolver = new SmartZoneResolver();
            _dnsServer = new DnsServer();
            _httpServer = new HttpServer();

            _zoneResolver.SubscribeTo(_zoneProvider);

            _zoneProvider.Initialize("d:\\data\\machineinfo.csv", ".foo.bar");
            _dnsServer.Initialize(_zoneResolver);
            _httpServer.Initialize("http://+:8080/");
            _httpServer.OnProcessRequest += _httpServer_OnProcessRequest;
            _httpServer.OnHealthProbe += _httpServer_OnHealthProbe;

            _zoneProvider.Start();
            _dnsServer.Start();
            _httpServer.Start();

            _exit.WaitOne();

            _httpServer.Stop();
            _dnsServer.Stop();
            _zoneProvider.Stop();

            _exitTimeout.Set();
        }
Пример #2
0
        private static void Main(string[] args)
        {
            Console.CancelKeyPress += Console_CancelKeyPress;

            _zoneProvider = new APZoneProvider();
            _zoneResolver = new SmartZoneResolver();
            _dnsServer    = new DnsServer();
            _httpServer   = new HttpServer();

            _zoneResolver.SubscribeTo(_zoneProvider);

            _zoneProvider.Initialize("d:\\data\\machineinfo.csv", ".foo.bar");
            _dnsServer.Initialize(_zoneResolver);
            _httpServer.Initialize("http://+:8080/");
            _httpServer.OnProcessRequest += _httpServer_OnProcessRequest;
            _httpServer.OnHealthProbe    += _httpServer_OnHealthProbe;

            _zoneProvider.Start();
            _dnsServer.Start();
            _httpServer.Start();

            _exit.WaitOne();

            _httpServer.Stop();
            _dnsServer.Stop();
            _zoneProvider.Stop();

            _exitTimeout.Set();
        }
Пример #3
0
        /// <summary>
        /// DNS Server entrypoint
        /// </summary>
        /// <param name="configFile">Fully qualified configuration filename</param>
        /// <param name="cts">Cancellation Token Source</param>
        public static void Run(string configFile, CancellationToken ct)
        {
            if (!File.Exists(configFile))
            {
                throw new FileNotFoundException(null, configFile);
            }

            IConfiguration configuration = new ConfigurationBuilder()
                                           .AddJsonFile(configFile, true, true)
                                           .Build();

            var appConfig = configuration.Get <Config.AppConfig>();

            container.Bind <ZoneProvider.BaseZoneProvider>().To(ByName(appConfig.Server.Zone.Provider));
            var zoneProviderConfig = configuration.GetSection("zoneprovider");

            _zoneProvider = container.Get <ZoneProvider.BaseZoneProvider>();
            _zoneProvider.Initialize(zoneProviderConfig, appConfig.Server.Zone.Name);

            _zoneResolver = new SmartZoneResolver();
            _zoneResolver.SubscribeTo(_zoneProvider);

            _dnsServer = new DnsServer(appConfig.Server.DnsListener.Port);

            _httpServer = new HttpServer();

            _dnsServer.Initialize(_zoneResolver);

            _zoneProvider.Start(ct);
            _dnsServer.Start(ct);

            if (appConfig.Server.WebServer.Enabled)
            {
                _httpServer.Initialize(string.Format("http://+:{0}/", appConfig.Server.WebServer.Port));
                _httpServer.OnProcessRequest += _httpServer_OnProcessRequest;
                _httpServer.OnHealthProbe    += _httpServer_OnHealthProbe;
                _httpServer.Start(ct);
            }

            ct.WaitHandle.WaitOne();
        }