2011-09-12 04:47:25 +10:00
|
|
|
// DYNAMIC UPDATES
|
|
|
|
//
|
2012-01-17 07:44:49 +11:00
|
|
|
// Dynamic updates reuses the DNS message format, but renames three of
|
2011-09-12 04:47:25 +10:00
|
|
|
// the sections. Question is Zone, Answer is Prerequisite, Authority is
|
|
|
|
// Update, only the Additional is not renamed. See RFC 2136 for the gory details.
|
|
|
|
//
|
|
|
|
// You can set a rather complex set of rules for the existence of absence of
|
|
|
|
// certain resource records or names in a zone to specify if resource records
|
|
|
|
// should be added or removed. The table from RFC 2136 supplemented with the Go
|
|
|
|
// DNS function shows which functions exist to specify the prerequisites.
|
|
|
|
//
|
|
|
|
// 3.2.4 - Table Of Metavalues Used In Prerequisite Section
|
|
|
|
//
|
2012-01-14 21:08:42 +11:00
|
|
|
// CLASS TYPE RDATA Meaning Function
|
|
|
|
// --------------------------------------------------------------
|
|
|
|
// ANY ANY empty Name is in use NameUsed
|
|
|
|
// ANY rrset empty RRset exists (value indep) RRsetUsedNoRdata
|
|
|
|
// NONE ANY empty Name is not in use NameNotUsed
|
|
|
|
// NONE rrset empty RRset does not exist RRsetNotUsed
|
|
|
|
// zone rrset rr RRset exists (value dep) RRsetUsedRdata
|
2011-09-12 04:47:25 +10:00
|
|
|
//
|
|
|
|
// The prerequisite section can also be left empty.
|
2012-01-17 07:44:49 +11:00
|
|
|
// If you have decided on the prerequisites you can tell what RRs should
|
2011-09-12 04:47:25 +10:00
|
|
|
// be added or deleted. The next table shows the options you have and
|
2012-01-17 07:44:49 +11:00
|
|
|
// what functions to call.
|
|
|
|
//
|
2011-09-12 04:47:25 +10:00
|
|
|
// 3.4.2.6 - Table Of Metavalues Used In Update Section
|
|
|
|
//
|
2012-01-14 21:08:42 +11:00
|
|
|
// CLASS TYPE RDATA Meaning Function
|
|
|
|
// ---------------------------------------------------------------
|
|
|
|
// ANY ANY empty Delete all RRsets from name NameDelete
|
|
|
|
// ANY rrset empty Delete an RRset RRsetDelete
|
|
|
|
// NONE rrset rr Delete an RR from RRset RRsetDeleteRR
|
|
|
|
// zone rrset rr Add to an RRset RRsetAddRdata
|
2011-09-12 04:47:25 +10:00
|
|
|
//
|
2011-08-22 22:51:10 +10:00
|
|
|
package dns
|
|
|
|
|
2011-08-22 23:16:24 +10:00
|
|
|
// NameUsed sets the RRs in the prereq section to
|
2011-08-22 22:51:10 +10:00
|
|
|
// "Name is in use" RRs. RFC 2136 section 2.4.4.
|
2011-12-10 06:56:59 +11:00
|
|
|
func (u *Msg) NameUsed(rr []RR) {
|
2011-08-22 23:16:24 +10:00
|
|
|
u.Answer = make([]RR, len(rr))
|
2011-08-22 22:51:10 +10:00
|
|
|
for i, r := range rr {
|
2011-08-22 23:16:24 +10:00
|
|
|
u.Answer[i] = &RR_ANY{Hdr: RR_Header{Name: r.Header().Name, Ttl: 0, Rrtype: TypeANY, Class: ClassANY}}
|
2011-08-22 22:51:10 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-22 23:16:24 +10:00
|
|
|
// NameNotUsed sets the RRs in the prereq section to
|
2011-08-22 22:51:10 +10:00
|
|
|
// "Name is in not use" RRs. RFC 2136 section 2.4.5.
|
2011-12-10 06:56:59 +11:00
|
|
|
func (u *Msg) NameNotUsed(rr []RR) {
|
2011-08-22 23:16:24 +10:00
|
|
|
u.Answer = make([]RR, len(rr))
|
2011-08-22 22:51:10 +10:00
|
|
|
for i, r := range rr {
|
2011-08-22 23:43:52 +10:00
|
|
|
u.Answer[i] = &RR_ANY{Hdr: RR_Header{Name: r.Header().Name, Ttl: 0, Rrtype: TypeANY, Class: ClassNONE}}
|
2011-08-22 22:51:10 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-12 04:47:25 +10:00
|
|
|
// RRsetUsedRdata sets the RRs in the prereq section to
|
2011-08-22 22:51:10 +10:00
|
|
|
// "RRset exists (value dependent -- with rdata)" RRs. RFC 2136 section 2.4.2.
|
2011-12-10 06:56:59 +11:00
|
|
|
func (u *Msg) RRsetUsedRdata(rr []RR) {
|
|
|
|
if len(u.Question) == 0 {
|
2011-09-09 03:41:26 +10:00
|
|
|
panic("empty question section")
|
|
|
|
}
|
2011-08-22 23:16:24 +10:00
|
|
|
u.Answer = make([]RR, len(rr))
|
2011-08-22 22:51:10 +10:00
|
|
|
for i, r := range rr {
|
2011-08-22 23:43:52 +10:00
|
|
|
u.Answer[i] = r
|
2011-12-10 06:56:59 +11:00
|
|
|
u.Answer[i].Header().Class = u.Question[0].Qclass
|
2011-08-22 22:51:10 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-12 04:47:25 +10:00
|
|
|
// RRsetUsedNoRdata sets the RRs in the prereq section to
|
2011-08-22 22:51:10 +10:00
|
|
|
// "RRset exists (value independent -- no rdata)" RRs. RFC 2136 section 2.4.1.
|
2011-12-10 06:56:59 +11:00
|
|
|
func (u *Msg) RRsetUsedNoRdata(rr []RR) {
|
2011-08-22 23:16:24 +10:00
|
|
|
u.Answer = make([]RR, len(rr))
|
2011-08-22 22:51:10 +10:00
|
|
|
for i, r := range rr {
|
2011-08-22 23:43:52 +10:00
|
|
|
u.Answer[i] = r
|
|
|
|
u.Answer[i].Header().Class = ClassANY
|
|
|
|
u.Answer[i].Header().Ttl = 0
|
|
|
|
u.Answer[i].Header().Rdlength = 0
|
2011-08-22 22:51:10 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-22 23:16:24 +10:00
|
|
|
// RRsetNotUsed sets the RRs in the prereq section to
|
2011-08-22 22:51:10 +10:00
|
|
|
// "RRset does not exist" RRs. RFC 2136 section 2.4.3.
|
2011-12-10 06:56:59 +11:00
|
|
|
func (u *Msg) RRsetNotUsed(rr []RR) {
|
2011-08-22 23:16:24 +10:00
|
|
|
u.Answer = make([]RR, len(rr))
|
2011-08-22 22:51:10 +10:00
|
|
|
for i, r := range rr {
|
2011-08-22 23:43:52 +10:00
|
|
|
u.Answer[i] = r
|
|
|
|
u.Answer[i].Header().Class = ClassNONE
|
|
|
|
u.Answer[i].Header().Rdlength = 0
|
|
|
|
u.Answer[i].Header().Ttl = 0
|
2011-08-22 22:51:10 +10:00
|
|
|
}
|
|
|
|
}
|
2011-08-22 23:35:52 +10:00
|
|
|
|
2011-09-12 04:47:25 +10:00
|
|
|
// The table from RFC 2136 supplemented with the Go DNS function.
|
|
|
|
//
|
2011-08-22 23:35:52 +10:00
|
|
|
// 3.4.2.6 - Table Of Metavalues Used In Update Section
|
|
|
|
//
|
2012-01-14 21:08:42 +11:00
|
|
|
// CLASS TYPE RDATA Meaning Function
|
|
|
|
// -----------------------------------------------------------------
|
|
|
|
// ANY ANY empty Delete all RRsets from name NameDelete
|
|
|
|
// ANY rrset empty Delete an RRset RRsetDelete
|
|
|
|
// NONE rrset rr Delete an RR from RRset RRsetDeleteRR
|
|
|
|
// zone rrset rr Add to an RRset RRsetAddRdata
|
2011-09-12 04:47:25 +10:00
|
|
|
|
2012-01-27 08:52:29 +11:00
|
|
|
// RRsetAddRdata creates a dynamic update packet that adds an complete RRset, see RFC 2136 section 2.5.1
|
2011-12-10 06:56:59 +11:00
|
|
|
func (u *Msg) RRsetAddRdata(rr []RR) {
|
|
|
|
if len(u.Question) == 0 {
|
2011-09-09 03:41:26 +10:00
|
|
|
panic("empty question section")
|
|
|
|
}
|
2011-08-22 23:43:52 +10:00
|
|
|
u.Ns = make([]RR, len(rr))
|
|
|
|
for i, r := range rr {
|
|
|
|
u.Ns[i] = r
|
2011-12-10 06:56:59 +11:00
|
|
|
u.Ns[i].Header().Class = u.Question[0].Qclass
|
2011-08-22 23:43:52 +10:00
|
|
|
}
|
2011-08-22 23:35:52 +10:00
|
|
|
}
|
|
|
|
|
2012-01-27 08:52:29 +11:00
|
|
|
// RRsetDelete creates a dynamic update packet that deletes an RRset, see RFC 2136 section 2.5.2
|
2011-12-10 06:56:59 +11:00
|
|
|
func (u *Msg) RRsetDelete(rr []RR) {
|
2011-08-22 23:43:52 +10:00
|
|
|
u.Ns = make([]RR, len(rr))
|
|
|
|
for i, r := range rr {
|
|
|
|
u.Ns[i] = r
|
|
|
|
u.Ns[i].Header().Class = ClassANY
|
|
|
|
u.Ns[i].Header().Rdlength = 0
|
|
|
|
u.Ns[i].Header().Ttl = 0
|
|
|
|
}
|
2011-08-22 23:35:52 +10:00
|
|
|
}
|
|
|
|
|
2012-01-27 08:52:29 +11:00
|
|
|
// NameDelete creates a dynamic update packet that deletes all RRsets of a name, see RFC 2136 section 2.5.3
|
2011-12-10 06:56:59 +11:00
|
|
|
func (u *Msg) NameDelete(rr []RR) {
|
2011-08-22 23:43:52 +10:00
|
|
|
u.Ns = make([]RR, len(rr))
|
|
|
|
for i, r := range rr {
|
|
|
|
u.Ns[i] = &RR_ANY{Hdr: RR_Header{Name: r.Header().Name, Ttl: 0, Rrtype: TypeANY, Class: ClassANY}}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-27 08:52:29 +11:00
|
|
|
// RRsetDeleteRR creates a dynamic update packet deletes RR from the RRSset, see RFC 2136 section 2.5.4
|
2011-12-10 06:56:59 +11:00
|
|
|
func (u *Msg) RRsetDeleteRR(rr []RR) {
|
2011-08-22 23:43:52 +10:00
|
|
|
u.Ns = make([]RR, len(rr))
|
|
|
|
for i, r := range rr {
|
|
|
|
u.Ns[i] = r
|
|
|
|
u.Ns[i].Header().Class = ClassNONE
|
2011-12-06 21:59:28 +11:00
|
|
|
u.Ns[i].Header().Ttl = 0
|
2011-08-22 23:43:52 +10:00
|
|
|
}
|
2011-08-22 23:35:52 +10:00
|
|
|
}
|