gtsocial-umbx

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

update.go (3181B)


      1 package dns
      2 
      3 // NameUsed sets the RRs in the prereq section to
      4 // "Name is in use" RRs. RFC 2136 section 2.4.4.
      5 func (u *Msg) NameUsed(rr []RR) {
      6 	if u.Answer == nil {
      7 		u.Answer = make([]RR, 0, len(rr))
      8 	}
      9 	for _, r := range rr {
     10 		u.Answer = append(u.Answer, &ANY{Hdr: RR_Header{Name: r.Header().Name, Ttl: 0, Rrtype: TypeANY, Class: ClassANY}})
     11 	}
     12 }
     13 
     14 // NameNotUsed sets the RRs in the prereq section to
     15 // "Name is in not use" RRs. RFC 2136 section 2.4.5.
     16 func (u *Msg) NameNotUsed(rr []RR) {
     17 	if u.Answer == nil {
     18 		u.Answer = make([]RR, 0, len(rr))
     19 	}
     20 	for _, r := range rr {
     21 		u.Answer = append(u.Answer, &ANY{Hdr: RR_Header{Name: r.Header().Name, Ttl: 0, Rrtype: TypeANY, Class: ClassNONE}})
     22 	}
     23 }
     24 
     25 // Used sets the RRs in the prereq section to
     26 // "RRset exists (value dependent -- with rdata)" RRs. RFC 2136 section 2.4.2.
     27 func (u *Msg) Used(rr []RR) {
     28 	if len(u.Question) == 0 {
     29 		panic("dns: empty question section")
     30 	}
     31 	if u.Answer == nil {
     32 		u.Answer = make([]RR, 0, len(rr))
     33 	}
     34 	for _, r := range rr {
     35 		hdr := r.Header()
     36 		hdr.Class = u.Question[0].Qclass
     37 		hdr.Ttl = 0
     38 		u.Answer = append(u.Answer, r)
     39 	}
     40 }
     41 
     42 // RRsetUsed sets the RRs in the prereq section to
     43 // "RRset exists (value independent -- no rdata)" RRs. RFC 2136 section 2.4.1.
     44 func (u *Msg) RRsetUsed(rr []RR) {
     45 	if u.Answer == nil {
     46 		u.Answer = make([]RR, 0, len(rr))
     47 	}
     48 	for _, r := range rr {
     49 		h := r.Header()
     50 		u.Answer = append(u.Answer, &ANY{Hdr: RR_Header{Name: h.Name, Ttl: 0, Rrtype: h.Rrtype, Class: ClassANY}})
     51 	}
     52 }
     53 
     54 // RRsetNotUsed sets the RRs in the prereq section to
     55 // "RRset does not exist" RRs. RFC 2136 section 2.4.3.
     56 func (u *Msg) RRsetNotUsed(rr []RR) {
     57 	if u.Answer == nil {
     58 		u.Answer = make([]RR, 0, len(rr))
     59 	}
     60 	for _, r := range rr {
     61 		h := r.Header()
     62 		u.Answer = append(u.Answer, &ANY{Hdr: RR_Header{Name: h.Name, Ttl: 0, Rrtype: h.Rrtype, Class: ClassNONE}})
     63 	}
     64 }
     65 
     66 // Insert creates a dynamic update packet that adds an complete RRset, see RFC 2136 section 2.5.1.
     67 func (u *Msg) Insert(rr []RR) {
     68 	if len(u.Question) == 0 {
     69 		panic("dns: empty question section")
     70 	}
     71 	if u.Ns == nil {
     72 		u.Ns = make([]RR, 0, len(rr))
     73 	}
     74 	for _, r := range rr {
     75 		r.Header().Class = u.Question[0].Qclass
     76 		u.Ns = append(u.Ns, r)
     77 	}
     78 }
     79 
     80 // RemoveRRset creates a dynamic update packet that deletes an RRset, see RFC 2136 section 2.5.2.
     81 func (u *Msg) RemoveRRset(rr []RR) {
     82 	if u.Ns == nil {
     83 		u.Ns = make([]RR, 0, len(rr))
     84 	}
     85 	for _, r := range rr {
     86 		h := r.Header()
     87 		u.Ns = append(u.Ns, &ANY{Hdr: RR_Header{Name: h.Name, Ttl: 0, Rrtype: h.Rrtype, Class: ClassANY}})
     88 	}
     89 }
     90 
     91 // RemoveName creates a dynamic update packet that deletes all RRsets of a name, see RFC 2136 section 2.5.3
     92 func (u *Msg) RemoveName(rr []RR) {
     93 	if u.Ns == nil {
     94 		u.Ns = make([]RR, 0, len(rr))
     95 	}
     96 	for _, r := range rr {
     97 		u.Ns = append(u.Ns, &ANY{Hdr: RR_Header{Name: r.Header().Name, Ttl: 0, Rrtype: TypeANY, Class: ClassANY}})
     98 	}
     99 }
    100 
    101 // Remove creates a dynamic update packet deletes RR from a RRSset, see RFC 2136 section 2.5.4
    102 func (u *Msg) Remove(rr []RR) {
    103 	if u.Ns == nil {
    104 		u.Ns = make([]RR, 0, len(rr))
    105 	}
    106 	for _, r := range rr {
    107 		h := r.Header()
    108 		h.Class = ClassNONE
    109 		h.Ttl = 0
    110 		u.Ns = append(u.Ns, r)
    111 	}
    112 }