Resolver: find local resolver instead of harcoded one

This commit is contained in:
nemunaire 2020-05-07 13:55:57 +02:00
parent 9d1ae96043
commit cffcb16116
2 changed files with 14 additions and 2 deletions

View File

@ -35,6 +35,7 @@ import (
"encoding/json"
"errors"
"io"
"math/rand"
"time"
"github.com/julienschmidt/httprouter"
@ -63,6 +64,17 @@ func runResolver(_ *config.Options, u *happydns.User, _ httprouter.Params, body
}
}
if urr.Resolver == "Local" {
cConf, err := dns.ClientConfigFromFile("/etc/resolv.conf")
if err != nil {
return APIErrorResponse{
err: err,
}
}
urr.Resolver = cConf.Servers[rand.Intn(len(cConf.Servers))]
}
client := dns.Client{Timeout: time.Second * 5}
m := new(dns.Msg)

View File

@ -110,9 +110,9 @@ export default {
return {
request_pending: false,
existing_types: ['ANY', 'A', 'AAAA', 'NS', 'SRV', 'MX', 'TXT'],
existing_resolvers: ['192.168.0.254', '1.1.1.1', '8.8.8.8', '9.9.9.9'],
existing_resolvers: ['Local', '1.1.1.1', '8.8.8.8', '9.9.9.9'],
form: {
resolver: '192.168.0.254',
resolver: 'Local',
type: 'ANY'
},
show_responses: [],