예제 #1
0
파일: xfr.go 프로젝트: elazarl/godns
func handleXfrOut(d *dns.Conn, i *dns.Msg) os.Error {
	if i.IsAxfr() {
		fmt.Printf("Incoming Axfr request seen\n")
		if i.Question[0].Name == Zone.name {
			fmt.Printf("Matches current zone\n")
			if !Zone.correct {
				fmt.Printf("Zone was not deemed correct\n")
				if err := d.WriteMsg(i); err != nil {
					return err
				}
				return nil
			} else {
				fmt.Printf("Zone was correct\n")
			}

			m := make(chan *dns.Xfr)
			e := make(chan os.Error)
			go d.XfrWrite(i, m, e)
			for j := 0; j < Zone.size; j++ {
				select {
				case m <- &dns.Xfr{Add: true, RR: Zone.rrs[j]}: //
				case err := <-e:
					return err
				}
			}
			close(m)
		} else {
			fmt.Printf("No matching zone found\n")
			if err := d.WriteMsg(i); err != nil {
				return err
			}
		}
	}
	return nil
}
예제 #2
0
파일: xfr.go 프로젝트: elazarl/godns
func handleNotify(d *dns.Conn, i *dns.Msg) os.Error {
	if i.IsNotify() {
		fmt.Printf("Incoming notify seen\n")
		q := new(dns.Msg)
		q.SetReply(i)
		err := d.WriteMsg(q)
		if err != nil {
			return err
		}
		err = handleXfrIn(i)
		if err != nil {
			return err
		}
	}
	return nil
}