support ipv4 DNS resolution
This commit is contained in:
parent
a288e99bda
commit
df90e5947e
@ -120,7 +120,7 @@ func (s *MeshnameServer) handleMeshnameRequest(w dns.ResponseWriter, r *dns.Msg)
|
||||
firstPartLabels := dns.SplitDomainName(firstPart)
|
||||
// define hostname ("subDomain")
|
||||
subDomain = firstPartLabels[len(firstPartLabels)-1]
|
||||
if len(firstPartLabels) == 1 {
|
||||
if len(firstPartLabels) == 1 && q.Qtype == dns.TypeAAAA {
|
||||
s.handleMeshIPRequest(w, r)
|
||||
return
|
||||
}
|
||||
@ -186,30 +186,6 @@ func (s *MeshnameServer) handleMeshIPRequest(w dns.ResponseWriter, r *dns.Msg) {
|
||||
|
||||
for _, q := range r.Question {
|
||||
labels := dns.SplitDomainName(q.Name)
|
||||
|
||||
/* // handle A type properly
|
||||
if q.Qtype == dns.TypeA {
|
||||
answer := new(dns.SOA)
|
||||
answer.Hdr = dns.RR_Header{Name: q.Name, Rrtype: dns.TypeSOA, Class: dns.ClassINET, Ttl: 3600}
|
||||
answer.Ns = "ns1.mesh.kyun.li."
|
||||
answer.Mbox = "ns2.mesh.kyun.li."
|
||||
answer.Serial = 2024061000
|
||||
answer.Refresh = 1200
|
||||
answer.Retry = 180
|
||||
answer.Expire = 1209600
|
||||
answer.Minttl = 600
|
||||
m.SetEdns0(512, false)
|
||||
m.Ns = append(m.Ns, answer)
|
||||
s.log.Debugln(m)
|
||||
continue
|
||||
}
|
||||
*/
|
||||
// resolve only AAAA type
|
||||
if q.Qtype != dns.TypeAAAA || q.Qclass != dns.ClassINET {
|
||||
//s.log.Debugln("Error: invalid resource requested")
|
||||
continue
|
||||
}
|
||||
|
||||
if resolvedAddr, err := IPFromDomain(&labels[0]); err == nil {
|
||||
answer := new(dns.AAAA)
|
||||
answer.Hdr = dns.RR_Header{Name: q.Name, Rrtype: dns.TypeAAAA, Class: dns.ClassINET, Ttl: 3600}
|
||||
|
Loading…
Reference in New Issue
Block a user