Example #1
0
        public override void AddZoneRecord(string zoneName, DnsRecord record)
        {
            try
            {
                string name = record.RecordName;
                if (String.IsNullOrEmpty(name))
                {
                    name = ".";
                }

                if (record.RecordType == DnsRecordType.A)
                {
                    ps.Add_DnsServerResourceRecordA(zoneName, name, record.RecordData);
                }
                else if (record.RecordType == DnsRecordType.AAAA)
                {
                    ps.Add_DnsServerResourceRecordAAAA(zoneName, name, record.RecordData);
                }
                else if (record.RecordType == DnsRecordType.CNAME)
                {
                    ps.Add_DnsServerResourceRecordCName(zoneName, name, record.RecordData);
                }
                else if (record.RecordType == DnsRecordType.MX)
                {
                    ps.Add_DnsServerResourceRecordMX(zoneName, name, record.RecordData, (ushort)record.MxPriority);
                }
                else if (record.RecordType == DnsRecordType.NS)
                {
                    ps.Add_DnsServerResourceRecordNS(zoneName, name, record.RecordData);
                }
                else if (record.RecordType == DnsRecordType.TXT)
                {
                    ps.Add_DnsServerResourceRecordTXT(zoneName, name, record.RecordData);
                }
                else if (record.RecordType == DnsRecordType.SRV)
                {
                    ps.Add_DnsServerResourceRecordSRV(zoneName, name, record.RecordData, (ushort)record.SrvPort, (ushort)record.SrvPriority, (ushort)record.SrvWeight);
                }
                else if (record.RecordType == DnsRecordType.CAA)
                {
                    ps.Add_DnsServerResourceRecordCAA(zoneName, name, record.RecordData);
                }
                else
                {
                    throw new Exception("Unknown record type");
                }
            }
            catch (Exception ex)
            {
                // log exception
                Log.WriteError(ex);
            }
        }