<commit_before>package dns

// Create a notify request packet.
func (dns *Msg) SetNotifyRequest(z string, class uint16) {
	dns.MsgHdr.Opcode = OpcodeNotify
	dns.MsgHdr.Authoritative = true
	dns.MsgHdr.Id = Id()
	dns.Question = make([]Question, 1)
	dns.Question[0] = Question{z, TypeSOA, class}
}

// Create a notify reply packet.
func (dns *Msg) SetNotifyReply(z string, class, id uint16) {
	dns.MsgHdr.Opcode = OpcodeNotify
	dns.MsgHdr.Authoritative = true
	dns.MsgHdr.Response = true
	dns.MsgHdr.Id = id
	dns.Question = make([]Question, 1)
	dns.Question[0] = Question{z, TypeSOA, class}
}

// Is a dns msg a valid notify packet?
func (dns *Msg) IsNotify() bool {
	ok := dns.MsgHdr.Opcode == OpcodeNotify
	if len(dns.Question) == 0 {
		ok = false
	}
	ok = ok && dns.Question[0].Qclass == ClassINET
	ok = ok && dns.Question[0].Qtype == TypeSOA
	return ok
}

func (dns *Msg) SetIxfrRequest(z string, class uint16, serial uint32) {
	dns.Question = make([]Question, 1)
	dns.Ns = make([]RR, 1)
	s := new(RR_SOA)
	s.Hdr = RR_Header{z, TypeSOA, class, DefaultTtl, 0}
	s.Serial = serial

	dns.Question[0] = Question{z, TypeIXFR, class}
        dns.Ns[0] = s
}

func (dns *Msg) SetAxfrRequest(z string, class uint16) {
	dns.Question = make([]Question, 1)
	dns.Question[0] = Question{z, TypeAXFR, class}
}

// IsIxfr/IsAxfr?
<commit_msg>nicer api<commit_after>package dns

// Create a notify packet.
func (dns *Msg) SetNotify(z string, class uint16) {
	dns.MsgHdr.Opcode = OpcodeNotify
	dns.MsgHdr.Authoritative = true
	dns.MsgHdr.Id = Id()
	dns.Question = make([]Question, 1)
	dns.Question[0] = Question{z, TypeSOA, class}
}

// Is a dns msg a valid notify packet?
func (dns *Msg) IsNotify() bool {
	ok := dns.MsgHdr.Opcode == OpcodeNotify
	if len(dns.Question) == 0 {
		ok = false
	}
	ok = ok && dns.Question[0].Qclass == ClassINET
	ok = ok && dns.Question[0].Qtype == TypeSOA
	return ok
}

// Create a dns msg suitable for requesting an ixfr.
func (dns *Msg) SetIxfr(z string, class uint16, serial uint32) {
	dns.Question = make([]Question, 1)
	dns.Ns = make([]RR, 1)
	s := new(RR_SOA)
	s.Hdr = RR_Header{z, TypeSOA, class, DefaultTtl, 0}
	s.Serial = serial

	dns.Question[0] = Question{z, TypeIXFR, class}
        dns.Ns[0] = s
}

// Create a dns msg suitable for requesting an axfr.
func (dns *Msg) SetAxfr(z string, class uint16) {
	dns.Question = make([]Question, 1)
	dns.Question[0] = Question{z, TypeAXFR, class}
}

// IsIxfr/IsAxfr?

{'fraction_non_alphanumeric': 0.14831552999178307, 'fraction_numerical': 0.018077239112571898, 'mean_word_length': 3.889558232931727, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3973871', 'n_tokens_mistral': 1021, 'n_tokens_neox': 990, 'n_words': 254}