make meshname default, delegate to meship function if appropriate
This commit is contained in:
parent
1919aed4e6
commit
9f31f76d02
@ -61,10 +61,6 @@ func (s *MeshnameServer) Start() error {
|
|||||||
Net: "udp",
|
Net: "udp",
|
||||||
NotifyStartedFunc: func() { close(waitStarted) },
|
NotifyStartedFunc: func() { close(waitStarted) },
|
||||||
}
|
}
|
||||||
for tld, subnet := range s.networks {
|
|
||||||
dns.HandleFunc(tld, s.handleMeshnameRequest)
|
|
||||||
s.log.Debugln("Handling:", tld, subnet)
|
|
||||||
}
|
|
||||||
if s.enableMeshIP {
|
if s.enableMeshIP {
|
||||||
for mtld, subnet := range s.meshipNetworks {
|
for mtld, subnet := range s.meshipNetworks {
|
||||||
//dns.HandleFunc("meship", s.handleMeshIPRequest)
|
//dns.HandleFunc("meship", s.handleMeshIPRequest)
|
||||||
@ -73,6 +69,10 @@ func (s *MeshnameServer) Start() error {
|
|||||||
s.log.Debugln("Handling as meship:", mtld, subnet)
|
s.log.Debugln("Handling as meship:", mtld, subnet)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for tld, subnet := range s.networks {
|
||||||
|
dns.HandleFunc(tld, s.handleMeshnameRequest)
|
||||||
|
s.log.Debugln("Handling:", tld, subnet)
|
||||||
|
}
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
if err := s.dnsServer.ListenAndServe(); err != nil {
|
if err := s.dnsServer.ListenAndServe(); err != nil {
|
||||||
@ -90,6 +90,7 @@ func (s *MeshnameServer) Start() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *MeshnameServer) handleMeshnameRequest(w dns.ResponseWriter, r *dns.Msg) {
|
func (s *MeshnameServer) handleMeshnameRequest(w dns.ResponseWriter, r *dns.Msg) {
|
||||||
|
s.log.Debugln("== handleMeshnameRequest ==")
|
||||||
var remoteLookups = make(map[string][]dns.Question)
|
var remoteLookups = make(map[string][]dns.Question)
|
||||||
m := new(dns.Msg)
|
m := new(dns.Msg)
|
||||||
m.SetReply(r)
|
m.SetReply(r)
|
||||||
@ -125,6 +126,11 @@ func (s *MeshnameServer) handleMeshnameRequest(w dns.ResponseWriter, r *dns.Msg)
|
|||||||
firstPartLabels := dns.SplitDomainName(firstPart)
|
firstPartLabels := dns.SplitDomainName(firstPart)
|
||||||
// define hostname ("subDomain")
|
// define hostname ("subDomain")
|
||||||
subDomain = firstPartLabels[len(firstPartLabels)-1]
|
subDomain = firstPartLabels[len(firstPartLabels)-1]
|
||||||
|
s.log.Debugln(tld, domainParts, firstPart, firstPartLabels, subDomain)
|
||||||
|
if len(firstPartLabels) == 1 {
|
||||||
|
s.handleMeshIPRequest(w, r)
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//subDomain := labels[len(labels)-2]
|
//subDomain := labels[len(labels)-2]
|
||||||
@ -166,6 +172,7 @@ func (s *MeshnameServer) handleMeshnameRequest(w dns.ResponseWriter, r *dns.Msg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *MeshnameServer) handleMeshIPRequest(w dns.ResponseWriter, r *dns.Msg) {
|
func (s *MeshnameServer) handleMeshIPRequest(w dns.ResponseWriter, r *dns.Msg) {
|
||||||
|
s.log.Debugln("== handleMeshIPRequest ==")
|
||||||
m := new(dns.Msg)
|
m := new(dns.Msg)
|
||||||
m.SetReply(r)
|
m.SetReply(r)
|
||||||
s.log.Debugln(r.String())
|
s.log.Debugln(r.String())
|
||||||
|
Loading…
Reference in New Issue
Block a user