コード例 #1
0
ファイル: DNSService.cs プロジェクト: xf86cfg/synch
        private void ConfigureService()
        {
            _masterFile = new MasterFile();
            var soaoptions = new StartOfAuthorityResourceRecord.Options()
            {
                SerialNumber      = GenerateSerialNumber(),
                RefreshInterval   = new TimeSpan(0, 0, _options.Value.RefreshInterval),
                RetryInterval     = new TimeSpan(0, 0, _options.Value.RetryInterval),
                ExpireInterval    = new TimeSpan(0, 0, _options.Value.ExpireInterval),
                MinimumTimeToLive = new TimeSpan(0, 0, _options.Value.MinTTL)
            };
            var domain = new Domain(_options.Value.Domain);
            var soa    = new StartOfAuthorityResourceRecord(
                domain, domain, domain, soaoptions, new TimeSpan(0, 0, _options.Value.TTL));

            _masterFile.Add(soa);
            var record = new IPAddressResourceRecord(
                new Domain(GetRecordFqdn()), IPAddress.Parse(_options.Value.TargetNormal), new TimeSpan(0, 0, _options.Value.RecordTtl));

            _masterFile.Add(record);
            _server            = new DnsServer(_masterFile, _options.Value.Forwarder);
            _server.Listening += ServerListening;
            _server.Responded += ServerResponded;
            _server.Errored   += ServerErrored;
        }