Fix generation of records for the origin
This commit is contained in:
parent
40e0dfeb9f
commit
fa647c7a4b
12
api/zones.go
12
api/zones.go
|
@ -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 {
|
||||
return APIErrorResponse{
|
||||
err: errors.New("Service not found"),
|
||||
}
|
||||
}
|
||||
|
||||
subdomain := req.Ps.ByName("subdomain")
|
||||
if subdomain == "" {
|
||||
subdomain = "@"
|
||||
}
|
||||
|
||||
var ret []serviceRecord
|
||||
for _, rr := range svc.GenRRs(subdomain, 3600, req.Domain.DomainName) {
|
||||
ret = append(ret, serviceRecord{
|
||||
|
|
|
@ -113,6 +113,10 @@ func (z *Zone) FindService(id []byte) (string, *ServiceCombined) {
|
|||
}
|
||||
|
||||
func (z *Zone) findSubdomainService(subdomain string, id []byte) (int, *ServiceCombined) {
|
||||
if subdomain == "@" {
|
||||
subdomain = ""
|
||||
}
|
||||
|
||||
if services, ok := z.Services[subdomain]; ok {
|
||||
for k, svc := range services {
|
||||
if bytes.Equal(svc.Id, id) {
|
||||
|
|
Loading…
Reference in New Issue