Add identifier to services' records
This commit is contained in:
parent
c44a227419
commit
0e15ed3fdc
|
@ -45,7 +45,7 @@ type Service interface {
|
||||||
|
|
||||||
type ServiceType struct {
|
type ServiceType struct {
|
||||||
Type string `json:"_svctype"`
|
Type string `json:"_svctype"`
|
||||||
Id int64 `json:"_id,omitempty"`
|
Id []byte `json:"_id,omitempty"`
|
||||||
OwnerId int64 `json:"_ownerid,omitempty"`
|
OwnerId int64 `json:"_ownerid,omitempty"`
|
||||||
Domain string `json:"_domain"`
|
Domain string `json:"_domain"`
|
||||||
Ttl uint32 `json:"_ttl"`
|
Ttl uint32 `json:"_ttl"`
|
||||||
|
|
|
@ -32,7 +32,9 @@
|
||||||
package svcs
|
package svcs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/sha1"
|
||||||
"errors"
|
"errors"
|
||||||
|
"io"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
@ -104,12 +106,16 @@ func (a *Analyzer) useRR(rr dns.RR, domain string, svc happydns.Service) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hash := sha1.New()
|
||||||
|
io.WriteString(hash, rr.String())
|
||||||
|
|
||||||
var ttl uint32 = 0
|
var ttl uint32 = 0
|
||||||
if rr.Header().Ttl != a.defaultTTL {
|
if rr.Header().Ttl != a.defaultTTL {
|
||||||
ttl = rr.Header().Ttl
|
ttl = rr.Header().Ttl
|
||||||
}
|
}
|
||||||
|
|
||||||
a.services[domain] = append(a.services[domain], &happydns.ServiceCombined{svc, happydns.ServiceType{
|
a.services[domain] = append(a.services[domain], &happydns.ServiceCombined{svc, happydns.ServiceType{
|
||||||
|
Id: hash.Sum(nil),
|
||||||
Type: reflect.Indirect(reflect.ValueOf(svc)).Type().String(),
|
Type: reflect.Indirect(reflect.ValueOf(svc)).Type().String(),
|
||||||
Domain: domain,
|
Domain: domain,
|
||||||
Ttl: ttl,
|
Ttl: ttl,
|
||||||
|
@ -170,8 +176,14 @@ func AnalyzeZone(origin string, zone []dns.RR) (svcs map[string][]*happydns.Serv
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
domain := strings.TrimSuffix(strings.TrimSuffix(record.Header().Name, "."+a.origin), a.origin)
|
||||||
|
|
||||||
|
hash := sha1.New()
|
||||||
|
io.WriteString(hash, record.String())
|
||||||
|
|
||||||
orphan := &Orphan{record.String()[strings.LastIndex(record.Header().String(), "\tIN\t")+4:]}
|
orphan := &Orphan{record.String()[strings.LastIndex(record.Header().String(), "\tIN\t")+4:]}
|
||||||
svcs[record.Header().Name] = append(svcs[record.Header().Name], &happydns.ServiceCombined{orphan, happydns.ServiceType{
|
svcs[record.Header().Name] = append(svcs[record.Header().Name], &happydns.ServiceCombined{orphan, happydns.ServiceType{
|
||||||
|
Id: hash.Sum(nil),
|
||||||
Type: reflect.Indirect(reflect.ValueOf(orphan)).Type().String(),
|
Type: reflect.Indirect(reflect.ValueOf(orphan)).Type().String(),
|
||||||
Domain: origin,
|
Domain: origin,
|
||||||
Ttl: record.Header().Ttl,
|
Ttl: record.Header().Ttl,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user