Fix generation of records for the origin

This commit is contained in:
nemunaire 2021-01-22 14:49:39 +01:00
parent 40e0dfeb9f
commit fa647c7a4b
2 changed files with 10 additions and 6 deletions

View file

@ -471,18 +471,18 @@ func getServiceRecords(opts *config.Options, req *RequestResources, body io.Read
} }
} }
svc := req.Zone.FindSubdomainService(req.Ps.ByName("subdomain"), serviceid) subdomain := req.Ps.ByName("subdomain")
if subdomain == "" {
subdomain = "@"
}
svc := req.Zone.FindSubdomainService(subdomain, serviceid)
if svc == nil { if svc == nil {
return APIErrorResponse{ return APIErrorResponse{
err: errors.New("Service not found"), err: errors.New("Service not found"),
} }
} }
subdomain := req.Ps.ByName("subdomain")
if subdomain == "" {
subdomain = "@"
}
var ret []serviceRecord var ret []serviceRecord
for _, rr := range svc.GenRRs(subdomain, 3600, req.Domain.DomainName) { for _, rr := range svc.GenRRs(subdomain, 3600, req.Domain.DomainName) {
ret = append(ret, serviceRecord{ ret = append(ret, serviceRecord{

View file

@ -113,6 +113,10 @@ func (z *Zone) FindService(id []byte) (string, *ServiceCombined) {
} }
func (z *Zone) findSubdomainService(subdomain string, id []byte) (int, *ServiceCombined) { func (z *Zone) findSubdomainService(subdomain string, id []byte) (int, *ServiceCombined) {
if subdomain == "@" {
subdomain = ""
}
if services, ok := z.Services[subdomain]; ok { if services, ok := z.Services[subdomain]; ok {
for k, svc := range services { for k, svc := range services {
if bytes.Equal(svc.Id, id) { if bytes.Equal(svc.Id, id) {