feat(lns): add service DNS common accessors
This commit is contained in:
parent
41eeee936c
commit
389c43db76
2 changed files with 140 additions and 0 deletions
100
lns.go
100
lns.go
|
|
@ -352,6 +352,106 @@ func (s *Service) GetCreate(name, nextDomain string, typeBitmap []byte) NSECReco
|
|||
return s.Create(name, nextDomain, typeBitmap)
|
||||
}
|
||||
|
||||
// DefaultTTL returns the reference DNS TTL used for synthesized records.
|
||||
func (s *Service) DefaultTTL() int {
|
||||
return DEFAULT_TTL
|
||||
}
|
||||
|
||||
// GetDefaultTTL is an alias for DefaultTTL.
|
||||
func (s *Service) GetDefaultTTL() int {
|
||||
return s.DefaultTTL()
|
||||
}
|
||||
|
||||
// Dummy returns the zero-length DNS reference buffer.
|
||||
func (s *Service) Dummy() []byte {
|
||||
return DUMMY
|
||||
}
|
||||
|
||||
// GetDummy is an alias for Dummy.
|
||||
func (s *Service) GetDummy() []byte {
|
||||
return s.Dummy()
|
||||
}
|
||||
|
||||
// TypeMapRoot returns the reference type bitmap for the root zone.
|
||||
func (s *Service) TypeMapRoot() []byte {
|
||||
return TYPE_MAP_ROOT
|
||||
}
|
||||
|
||||
// GetTypeMapRoot is an alias for TypeMapRoot.
|
||||
func (s *Service) GetTypeMapRoot() []byte {
|
||||
return s.TypeMapRoot()
|
||||
}
|
||||
|
||||
// TypeMapEmpty returns the reference type bitmap for an empty response.
|
||||
func (s *Service) TypeMapEmpty() []byte {
|
||||
return TYPE_MAP_EMPTY
|
||||
}
|
||||
|
||||
// GetTypeMapEmpty is an alias for TypeMapEmpty.
|
||||
func (s *Service) GetTypeMapEmpty() []byte {
|
||||
return s.TypeMapEmpty()
|
||||
}
|
||||
|
||||
// TypeMapNS returns the reference type bitmap for NS responses.
|
||||
func (s *Service) TypeMapNS() []byte {
|
||||
return TYPE_MAP_NS
|
||||
}
|
||||
|
||||
// GetTypeMapNS is an alias for TypeMapNS.
|
||||
func (s *Service) GetTypeMapNS() []byte {
|
||||
return s.TypeMapNS()
|
||||
}
|
||||
|
||||
// TypeMapTXT returns the reference type bitmap for TXT responses.
|
||||
func (s *Service) TypeMapTXT() []byte {
|
||||
return TYPE_MAP_TXT
|
||||
}
|
||||
|
||||
// GetTypeMapTXT is an alias for TypeMapTXT.
|
||||
func (s *Service) GetTypeMapTXT() []byte {
|
||||
return s.TypeMapTXT()
|
||||
}
|
||||
|
||||
// TypeMapA returns the reference type bitmap for A responses.
|
||||
func (s *Service) TypeMapA() []byte {
|
||||
return TYPE_MAP_A
|
||||
}
|
||||
|
||||
// GetTypeMapA is an alias for TypeMapA.
|
||||
func (s *Service) GetTypeMapA() []byte {
|
||||
return s.TypeMapA()
|
||||
}
|
||||
|
||||
// TypeMapAAAA returns the reference type bitmap for AAAA responses.
|
||||
func (s *Service) TypeMapAAAA() []byte {
|
||||
return TYPE_MAP_AAAA
|
||||
}
|
||||
|
||||
// GetTypeMapAAAA is an alias for TypeMapAAAA.
|
||||
func (s *Service) GetTypeMapAAAA() []byte {
|
||||
return s.TypeMapAAAA()
|
||||
}
|
||||
|
||||
// HSTypes returns the DNS record-type lookup table.
|
||||
func (s *Service) HSTypes() map[string]dnspkg.HSType {
|
||||
return HSTypes
|
||||
}
|
||||
|
||||
// GetHSTypes is an alias for HSTypes.
|
||||
func (s *Service) GetHSTypes() map[string]dnspkg.HSType {
|
||||
return s.HSTypes()
|
||||
}
|
||||
|
||||
// HSTypesByVal returns the reverse DNS record-type lookup table.
|
||||
func (s *Service) HSTypesByVal() map[dnspkg.HSType]string {
|
||||
return HSTypesByVal
|
||||
}
|
||||
|
||||
// GetHSTypesByVal is an alias for HSTypesByVal.
|
||||
func (s *Service) GetHSTypesByVal() map[dnspkg.HSType]string {
|
||||
return s.HSTypesByVal()
|
||||
}
|
||||
|
||||
// NextName returns the canonical successor for a top-level domain name.
|
||||
func (s *Service) NextName(tld string) string {
|
||||
return dnspkg.NextName(tld)
|
||||
|
|
|
|||
40
lns_test.go
40
lns_test.go
|
|
@ -891,6 +891,46 @@ func TestServiceUtilityAliases(t *testing.T) {
|
|||
t.Fatalf("GetPrevName returned %q", got)
|
||||
}
|
||||
|
||||
if svc.DefaultTTL() != DEFAULT_TTL || svc.GetDefaultTTL() != DEFAULT_TTL {
|
||||
t.Fatalf("DefaultTTL getters = %d/%d, want %d", svc.DefaultTTL(), svc.GetDefaultTTL(), DEFAULT_TTL)
|
||||
}
|
||||
|
||||
if len(svc.Dummy()) != 0 || len(svc.GetDummy()) != 0 {
|
||||
t.Fatal("Dummy getters should return the zero-length DNS reference buffer")
|
||||
}
|
||||
|
||||
if !bytes.Equal(svc.TypeMapRoot(), TYPE_MAP_ROOT) || !bytes.Equal(svc.GetTypeMapRoot(), TYPE_MAP_ROOT) {
|
||||
t.Fatal("TypeMapRoot getters should alias the reference bitmap")
|
||||
}
|
||||
|
||||
if !bytes.Equal(svc.TypeMapEmpty(), TYPE_MAP_EMPTY) || !bytes.Equal(svc.GetTypeMapEmpty(), TYPE_MAP_EMPTY) {
|
||||
t.Fatal("TypeMapEmpty getters should alias the reference bitmap")
|
||||
}
|
||||
|
||||
if !bytes.Equal(svc.TypeMapNS(), TYPE_MAP_NS) || !bytes.Equal(svc.GetTypeMapNS(), TYPE_MAP_NS) {
|
||||
t.Fatal("TypeMapNS getters should alias the reference bitmap")
|
||||
}
|
||||
|
||||
if !bytes.Equal(svc.TypeMapTXT(), TYPE_MAP_TXT) || !bytes.Equal(svc.GetTypeMapTXT(), TYPE_MAP_TXT) {
|
||||
t.Fatal("TypeMapTXT getters should alias the reference bitmap")
|
||||
}
|
||||
|
||||
if !bytes.Equal(svc.TypeMapA(), TYPE_MAP_A) || !bytes.Equal(svc.GetTypeMapA(), TYPE_MAP_A) {
|
||||
t.Fatal("TypeMapA getters should alias the reference bitmap")
|
||||
}
|
||||
|
||||
if !bytes.Equal(svc.TypeMapAAAA(), TYPE_MAP_AAAA) || !bytes.Equal(svc.GetTypeMapAAAA(), TYPE_MAP_AAAA) {
|
||||
t.Fatal("TypeMapAAAA getters should alias the reference bitmap")
|
||||
}
|
||||
|
||||
if len(svc.HSTypes()) != len(HSTypes) || len(svc.GetHSTypes()) != len(HSTypes) {
|
||||
t.Fatal("HSTypes getters should alias the reference table")
|
||||
}
|
||||
|
||||
if len(svc.HSTypesByVal()) != len(HSTypesByVal) || len(svc.GetHSTypesByVal()) != len(HSTypesByVal) {
|
||||
t.Fatal("HSTypesByVal getters should alias the reference table")
|
||||
}
|
||||
|
||||
record := svc.Create(".", svc.NextName("."), TYPE_MAP_ROOT)
|
||||
if record.Name != "." {
|
||||
t.Fatalf("Create Name = %q, want %q", record.Name, ".")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue