mirror of
https://git.hackfreedom.org/mesh.cat/meshname.git
synced 2026-05-22 06:22:32 +00:00
make meshname default, delegate to meship function if appropriate
This commit is contained in:
+11
-4
@@ -61,10 +61,6 @@ func (s *MeshnameServer) Start() error {
|
||||
Net: "udp",
|
||||
NotifyStartedFunc: func() { close(waitStarted) },
|
||||
}
|
||||
for tld, subnet := range s.networks {
|
||||
dns.HandleFunc(tld, s.handleMeshnameRequest)
|
||||
s.log.Debugln("Handling:", tld, subnet)
|
||||
}
|
||||
if s.enableMeshIP {
|
||||
for mtld, subnet := range s.meshipNetworks {
|
||||
//dns.HandleFunc("meship", s.handleMeshIPRequest)
|
||||
@@ -73,6 +69,10 @@ func (s *MeshnameServer) Start() error {
|
||||
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() {
|
||||
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) {
|
||||
s.log.Debugln("== handleMeshnameRequest ==")
|
||||
var remoteLookups = make(map[string][]dns.Question)
|
||||
m := new(dns.Msg)
|
||||
m.SetReply(r)
|
||||
@@ -125,6 +126,11 @@ func (s *MeshnameServer) handleMeshnameRequest(w dns.ResponseWriter, r *dns.Msg)
|
||||
firstPartLabels := dns.SplitDomainName(firstPart)
|
||||
// define hostname ("subDomain")
|
||||
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]
|
||||
@@ -166,6 +172,7 @@ func (s *MeshnameServer) handleMeshnameRequest(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.SetReply(r)
|
||||
s.log.Debugln(r.String())
|
||||
|
||||
Reference in New Issue
Block a user