示例#1
0
        public DnsClient CreateClient()
        {
            DnsServerSettings settings = this.Server.Settings;
            DnsClient         client   = new DnsClient(settings.Address, settings.Port);

            return(client);
        }
示例#2
0
        /// <summary>
        /// method to initialize fields utilized by the service
        /// </summary>
        private void InitializeService()
        {
            m_diagnostics.ServiceInitializing();

            // load the settings from the related sections in app.config
            DnsServerSettings dnsServerSettings = DnsServerSettingsSection.GetSection().AsDnsServerSettings();

            if (dnsServerSettings.ResolutionMode == DnsResolutionMode.AuthoritativeResolution)
            {
                AuthoritativeResolutionSettings settings =
                    AuthoritativeResolutionSettingsSection.GetSection().AsAuthoritativeResolutionSettings();
                m_store = new AuthoritativeRecordResolver(settings);
            }
            else if (dnsServerSettings.ResolutionMode == DnsResolutionMode.RecordStorageService)
            {
                ClientSettings recordRetrievalSettings = ClientSettingsSection.GetSection().AsClientSettings();
                m_store = new DnsRecordStorageService(recordRetrievalSettings);
            }
            else
            {
                throw new System.Configuration.ConfigurationErrorsException("Unknown resolution mode");
            }

            // create the DNS Server instance
            m_dnsServer = new DnsServer(m_store, dnsServerSettings);
            //
            // Hook up events for logging/debugging
            //
            m_diagnostics.HookEvents(m_dnsServer);

            m_diagnostics.ServiceInitializingComplete(dnsServerSettings);
        }
示例#3
0
        public Socket CreateTCPSocket()
        {
            DnsServerSettings settings = this.Server.Settings;
            Socket            socket   = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            socket.Connect(settings.Address, settings.Port);
            return(socket);
        }
示例#4
0
        public TestServer(IDnsStore store, DnsServerSettings settings)
        {
            m_settings = settings;

            m_server = new DnsServer(store, settings);
            m_server.UDPResponder.Server.Error += UDPServer_Error;
            m_server.TCPResponder.Server.Error += TCPServer_Error;
            m_server.TCPResponder.Server.ConnectionAccepted += TCP_Accept;
            m_server.TCPResponder.Server.ConnectionClosed   += TCP_Complete;
        }
示例#5
0
 static RetryTester()
 {
     s_failureStore = new FailureStore(TestStore.Default.Store);
     DnsServerSettings settings = new DnsServerSettings();
     settings.Address = "127.0.0.1";
     settings.Port = 5373;
     
     s_failureServer = new TestServer(s_failureStore, settings);
     s_failureServer.Server.Start();
 }
示例#6
0
 public TestServer(IDnsStore store, DnsServerSettings settings)
 {
     m_settings = settings;
     
     m_server = new DnsServer(store, settings);
     m_server.UDPResponder.Server.Error += UDPServer_Error;
     m_server.TCPResponder.Server.Error += TCPServer_Error;
     m_server.TCPResponder.Server.ConnectionAccepted += TCP_Accept;
     m_server.TCPResponder.Server.ConnectionClosed += TCP_Complete;
 }
示例#7
0
        static RetryTester()
        {
            s_failureStore = new FailureStore(TestStore.Default.Store);
            DnsServerSettings settings = new DnsServerSettings();

            settings.Address = "127.0.0.1";
            settings.Port    = 5373;

            s_failureServer = new TestServer(s_failureStore, settings);
            s_failureServer.Server.Start();
        }
        private static void InitRootDnsServer()
        {
            DnsServerSettings settings = new DnsServerSettings();

            settings.Address = "127.0.0.1";
            settings.Port    = 5400;
            settings.TcpServerSettings.MaxOutstandingAccepts = 4;
            settings.TcpServerSettings.MaxActiveRequests     = 16;
            settings.TcpServerSettings.ReceiveTimeout        = 60 * 1000;
            settings.TcpServerSettings.SendTimeout           = 60 * 1000;

            settings.UdpServerSettings.MaxOutstandingAccepts = 4;
            settings.UdpServerSettings.MaxActiveRequests     = 16;
            settings.UdpServerSettings.ReceiveTimeout        = 60 * 1000;
            settings.UdpServerSettings.SendTimeout           = 60 * 1000;

            MemoryStore memoryDnsStore = new MemoryStore();

            DnsRecordTable table = new DnsRecordTable();

            // Address only
            table.Add(new NSRecord("abc.com", "127.0.0.1"));
            table.Add(new AddressRecord("abc.com", "192.200.0.1"));
            table.Add(new AddressRecord("abc.com", "192.200.0.2"));

            // Cert + Address
            table.Add(new NSRecord("redmond.hsgincubator.com", "127.0.0.1"));
            table.Add(new AddressRecord("redmond.hsgincubator.com", "192.210.0.1"));
            table.Add(new CertRecord(new DnsX509Cert(File.ReadAllBytes("metadata\\certificates\\redmond.cer"))));

            // Cert MX + Address
            table.Add(new NSRecord("direct.hisp.com", "127.0.0.1"));
            table.Add(new AddressRecord("direct.hisp.com", "192.220.0.1"));
            table.Add(new MXRecord("direct.hisp.com", "gateway.direct.hisp.com"));


            s_recordTable = table;

            foreach (DnsResourceRecord record in s_recordTable.Records)
            {
                memoryDnsStore.Records.Add(record);
            }

            s_rootDnsServer = new TestServer(memoryDnsStore, settings);
            s_rootDnsServer.Server.Start();
        }
        private static void InitRootDnsServer()
        {   
            DnsServerSettings settings = new DnsServerSettings();
            settings.Address = "127.0.0.1";
            settings.Port = 5400;
            settings.TcpServerSettings.MaxOutstandingAccepts = 4;
            settings.TcpServerSettings.MaxActiveRequests = 16;
            settings.TcpServerSettings.ReceiveTimeout = 60 * 1000;
            settings.TcpServerSettings.SendTimeout = 60 * 1000;

            settings.UdpServerSettings.MaxOutstandingAccepts = 4;
            settings.UdpServerSettings.MaxActiveRequests = 16;
            settings.UdpServerSettings.ReceiveTimeout = 60 * 1000;
            settings.UdpServerSettings.SendTimeout = 60 * 1000;

            MemoryStore memoryDnsStore = new MemoryStore();

            DnsRecordTable table = new DnsRecordTable();
            
            // Address only
            table.Add(new NSRecord("abc.com", "127.0.0.1")); 
            table.Add(new AddressRecord("abc.com", "192.200.0.1"));
            table.Add(new AddressRecord("abc.com", "192.200.0.2"));
            
            // Cert + Address
            table.Add(new NSRecord("redmond.hsgincubator.com", "127.0.0.1"));
            table.Add(new AddressRecord("redmond.hsgincubator.com", "192.210.0.1"));
            table.Add(new CertRecord(new DnsX509Cert(File.ReadAllBytes("metadata\\certificates\\redmond.cer"))));

            // Cert MX + Address
            table.Add(new NSRecord("direct.hisp.com", "127.0.0.1"));
            table.Add(new AddressRecord("direct.hisp.com", "192.220.0.1"));
            table.Add(new MXRecord("direct.hisp.com", "gateway.direct.hisp.com"));
            

            s_recordTable = table;
            
            foreach (DnsResourceRecord record in s_recordTable.Records)
            {
                memoryDnsStore.Records.Add(record); 
            }            

            s_rootDnsServer = new TestServer(memoryDnsStore, settings);             
            s_rootDnsServer.Server.Start();            
        }
示例#10
0
        static TestServer()
        {
            DefaultSettings         = new DnsServerSettings();
            DefaultSettings.Address = "127.0.0.1";
            DefaultSettings.Port    = 5350;
            DefaultSettings.TcpServerSettings.MaxOutstandingAccepts = 4;
            DefaultSettings.TcpServerSettings.MaxActiveRequests     = 16;
            DefaultSettings.TcpServerSettings.ReceiveTimeout        = 60 * 1000;
            DefaultSettings.TcpServerSettings.SendTimeout           = 60 * 1000;

            DefaultSettings.UdpServerSettings.MaxOutstandingAccepts = 4;
            DefaultSettings.UdpServerSettings.MaxActiveRequests     = 16;
            DefaultSettings.UdpServerSettings.ReceiveTimeout        = 60 * 1000;
            DefaultSettings.UdpServerSettings.SendTimeout           = 60 * 1000;

            Default = new TestServer(TestStore.Default.Store);
            Default.Server.Start();
        }
示例#11
0
        static TestServer()
        {
            DefaultSettings = new DnsServerSettings();
            DefaultSettings.Address = "127.0.0.1";
            DefaultSettings.Port = 5353;
            DefaultSettings.TcpServerSettings.MaxOutstandingAccepts = 4;
            DefaultSettings.TcpServerSettings.MaxActiveRequests = 16;
            DefaultSettings.TcpServerSettings.ReceiveTimeout = 60 * 1000;
            DefaultSettings.TcpServerSettings.SendTimeout= 60 * 1000;
            
            DefaultSettings.UdpServerSettings.MaxOutstandingAccepts = 4;
            DefaultSettings.UdpServerSettings.MaxActiveRequests = 16;
            DefaultSettings.UdpServerSettings.ReceiveTimeout = 60 * 1000;
            DefaultSettings.UdpServerSettings.SendTimeout = 60 * 1000;

            Default = new TestServer(TestStore.Default.Store);
            Default.Server.Start();
        }
        private static void InitAuthoritativeResolver()
        {
            // Setup the authoritative resolver.
            // Primary name server is on 127.0.0.1:5400.  
            AuthoritativeResolutionSettings settings = new AuthoritativeResolutionSettings()
            {
                Cache = true,
                DnsResolutionPort = 5400, // perform DNS resolutions on 5400
                PrimaryNameServer = new DnsIPEndpointSettings[] { new DnsIPEndpointSettings("127.0.0.1", 5400) },
                TimeoutMilliseconds = 30000
            };

            // Create the authoritative resolver. 
            AuthoritativeRecordResolver resolver = new AuthoritativeRecordResolver(settings);

            // Setup DNS server to host the authoritative resolver at 127.0.0.1:5401
            DnsServerSettings dnsServerSettings = new DnsServerSettings();
            dnsServerSettings.Address = "127.0.0.1";
            dnsServerSettings.Port = 5401;

            s_authoritativeResolverServer = new TestServer(resolver, dnsServerSettings);            
            s_authoritativeResolverServer.Server.Start();
        }
示例#13
0
        private static void InitAuthoritativeResolver()
        {
            // Setup the authoritative resolver.
            // Primary name server is on 127.0.0.1:5400.
            AuthoritativeResolutionSettings settings = new AuthoritativeResolutionSettings()
            {
                Cache               = true,
                DnsResolutionPort   = 5400, // perform DNS resolutions on 5400
                PrimaryNameServer   = new DnsIPEndpointSettings[] { new DnsIPEndpointSettings("127.0.0.1", 5400) },
                TimeoutMilliseconds = 30000
            };

            // Create the authoritative resolver.
            AuthoritativeRecordResolver resolver = new AuthoritativeRecordResolver(settings);

            // Setup DNS server to host the authoritative resolver at 127.0.0.1:5401
            DnsServerSettings dnsServerSettings = new DnsServerSettings();

            dnsServerSettings.Address = "127.0.0.1";
            dnsServerSettings.Port    = 5401;

            s_authoritativeResolverServer = new TestServer(resolver, dnsServerSettings);
            s_authoritativeResolverServer.Server.Start();
        }
示例#14
0
 internal void ServiceInitializingComplete(DnsServerSettings settings)
 {
     this.WriteEvent(string.Format(
                         "Service initialized successfully. ResolutionMode={0}",
                         settings.ResolutionMode));
 }
示例#15
0
 internal void ServiceInitializingComplete(DnsServerSettings settings)
 {
     this.WriteEvent(string.Format(
         "Service initialized successfully. ResolutionMode={0}", 
         settings.ResolutionMode));
 }