Don't do special case of aliases. Treat them only in frontend part.
This commit is contained in:
parent
04e4c1d46a
commit
c6e64d64a3
|
@ -76,7 +76,7 @@ func analyzeDomain(opts *config.Options, domain *happydns.Domain, body io.Reader
|
|||
}
|
||||
}
|
||||
|
||||
services, aliases, defaultTTL, err := svcs.AnalyzeZone(domain.DomainName, zone)
|
||||
services, defaultTTL, err := svcs.AnalyzeZone(domain.DomainName, zone)
|
||||
if err != nil {
|
||||
return APIErrorResponse{
|
||||
err: err,
|
||||
|
@ -85,7 +85,6 @@ func analyzeDomain(opts *config.Options, domain *happydns.Domain, body io.Reader
|
|||
|
||||
return APIResponse{
|
||||
response: map[string]interface{}{
|
||||
"aliases": aliases,
|
||||
"services": services,
|
||||
"defaultTTL": defaultTTL,
|
||||
},
|
||||
|
|
|
@ -108,7 +108,6 @@ func getZoneSubdomain(opts *config.Options, domain *happydns.Domain, zone *happy
|
|||
subdomain := strings.TrimSuffix(ps.ByName("subdomain"), "@")
|
||||
return APIResponse{
|
||||
response: map[string]interface{}{
|
||||
"aliases": zone.Aliases[subdomain],
|
||||
"services": zone.Services[subdomain],
|
||||
},
|
||||
}
|
||||
|
@ -188,7 +187,7 @@ func importZone(opts *config.Options, domain *happydns.Domain, body io.Reader) R
|
|||
}
|
||||
}
|
||||
|
||||
services, aliases, defaultTTL, err := svcs.AnalyzeZone(domain.DomainName, zone)
|
||||
services, defaultTTL, err := svcs.AnalyzeZone(domain.DomainName, zone)
|
||||
if err != nil {
|
||||
return APIErrorResponse{
|
||||
err: err,
|
||||
|
@ -198,7 +197,6 @@ func importZone(opts *config.Options, domain *happydns.Domain, body io.Reader) R
|
|||
myZone := &happydns.Zone{
|
||||
IdAuthor: domain.IdUser,
|
||||
DefaultTTL: defaultTTL,
|
||||
Aliases: aliases,
|
||||
Services: services,
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
<template>
|
||||
<div v-if="!isLoading" class="pt-3">
|
||||
<h-subdomain-item v-for="(dn, index) in sortedDomains" :key="index" :dn="dn" :origin="domain.domain" :services="services" :zone-services="myServices.services[dn]===undefined?[]:myServices.services[dn]" :aliases="myServices.aliases[dn]===undefined?[]:myServices.aliases[dn]" :zone-meta="zoneMeta" @updateMyServices="updateMyServices($event)" @addSubdomain="addSubdomain()" @addNewAlias="addNewAlias($event)" @addNewService="addNewService($event)" />
|
||||
<h-subdomain-item v-for="(dn, index) in sortedDomains" :key="index" :dn="dn" :origin="domain.domain" :services="services" :zone-services="myServices.services[dn]===undefined?[]:myServices.services[dn]" :aliases="aliases[dn]===undefined?[]:aliases[dn]" :zone-meta="zoneMeta" @updateMyServices="updateMyServices($event)" @addSubdomain="addSubdomain()" @addNewAlias="addNewAlias($event)" @addNewService="addNewService($event)" />
|
||||
|
||||
<b-modal id="modal-addSvc" :size="modal && modal.step === 2 ? 'lg' : ''" @ok="handleModalSvcOk">
|
||||
<template v-slot:modal-title>
|
||||
|
@ -105,6 +105,23 @@ export default {
|
|||
},
|
||||
|
||||
computed: {
|
||||
aliases () {
|
||||
var ret = {}
|
||||
|
||||
for (const dn in this.myServices.services) {
|
||||
this.myServices.services[dn].forEach(function (svc) {
|
||||
if (svc._svctype === 'svcs.CNAME') {
|
||||
if (!ret[svc.Service.Target]) {
|
||||
ret[svc.Service.Target] = []
|
||||
}
|
||||
ret[svc.Service.Target].push(dn)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return ret
|
||||
},
|
||||
|
||||
isLoading () {
|
||||
return this.myServices == null && this.zoneMeta === undefined && this.services == null
|
||||
},
|
||||
|
|
|
@ -49,7 +49,6 @@ type Zone struct {
|
|||
CommitMsg *string `json:"commit_message,omitempty"`
|
||||
CommitDate *time.Time `json:"commit_date,omitempty"`
|
||||
Published *time.Time `json:"published,omitempty"`
|
||||
Aliases map[string][]string `json:"aliases"`
|
||||
Services map[string][]*ServiceCombined `json:"services"`
|
||||
}
|
||||
|
||||
|
|
|
@ -108,20 +108,8 @@ func specialalias_analyze(a *Analyzer) error {
|
|||
func alias_analyze(a *Analyzer) error {
|
||||
for _, record := range a.searchRR(AnalyzerRecordFilter{Type: dns.TypeCNAME}) {
|
||||
if cname, ok := record.(*dns.CNAME); ok {
|
||||
var newrr happydns.Service
|
||||
|
||||
if _, ok := a.services[cname.Target]; ok {
|
||||
a.aliases[cname.Target] = append(a.aliases[cname.Target], record.Header().Name)
|
||||
// Don't add extra domain in list if CNAME is the only one listed for it
|
||||
if _, ok := a.services[record.Header().Name]; ok {
|
||||
newrr = &CNAME{
|
||||
Target: cname.Target,
|
||||
}
|
||||
}
|
||||
} else {
|
||||
newrr = &CNAME{
|
||||
Target: cname.Target,
|
||||
}
|
||||
newrr := &CNAME{
|
||||
Target: strings.TrimSuffix(cname.Target, "."+a.origin),
|
||||
}
|
||||
|
||||
a.useRR(record, cname.Header().Name, newrr)
|
||||
|
|
|
@ -47,7 +47,6 @@ type Analyzer struct {
|
|||
origin string
|
||||
zone []dns.RR
|
||||
services map[string][]*happydns.ServiceCombined
|
||||
aliases map[string][]string
|
||||
defaultTTL uint32
|
||||
}
|
||||
|
||||
|
@ -145,14 +144,13 @@ func getMostUsedTTL(zone []dns.RR) uint32 {
|
|||
return max
|
||||
}
|
||||
|
||||
func AnalyzeZone(origin string, zone []dns.RR) (svcs map[string][]*happydns.ServiceCombined, aliases map[string][]string, defaultTTL uint32, err error) {
|
||||
func AnalyzeZone(origin string, zone []dns.RR) (svcs map[string][]*happydns.ServiceCombined, defaultTTL uint32, err error) {
|
||||
defaultTTL = getMostUsedTTL(zone)
|
||||
|
||||
a := Analyzer{
|
||||
origin: origin,
|
||||
zone: zone,
|
||||
services: map[string][]*happydns.ServiceCombined{},
|
||||
aliases: map[string][]string{},
|
||||
defaultTTL: defaultTTL,
|
||||
}
|
||||
|
||||
|
@ -195,7 +193,5 @@ func AnalyzeZone(origin string, zone []dns.RR) (svcs map[string][]*happydns.Serv
|
|||
}})
|
||||
}
|
||||
|
||||
aliases = a.aliases
|
||||
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue