Example #1
0
File: cache.go Project: cznic/dns
func (c *Cache) get0(name string) (parts rr.Parts, hit, expired bool) {
	var item rr.Bytes
	if item, hit = c.tree.Get(name).(rr.Bytes); hit {
		parts = item.Unpack().Partition(false)
		expired = tidy(time.Now().Unix()-secs0, parts)
		hit = len(parts) != 0
	}
	return
}
Example #2
0
func TestEnum0(t *testing.T) {
	c := New()
	var hit bool
	var x rr.Bytes
	c.Enum(".", func(path []string, found rr.Bytes) bool {
		x = found
		hit = true
		return false
	})
	if hit {
		t.Fatal(x.Unpack())
	}
}
Example #3
0
File: zone.go Project: cznic/dns
func (c *Compiler) flush() (err error) {
	if len(c.rrs) == 0 {
		return
	}

	var b rr.Bytes
	b.Pack(c.rrs)
	c.rrs = c.rrs[:0]

	n := len(b)
	if err = c.write([]byte{byte(n >> 8), byte(n)}); err != nil {
		return
	}

	return c.write(b)
}