author | Alberto Bertogli
<albertito@blitiri.com.ar> 2018-04-14 09:36:05 UTC |
committer | Alberto Bertogli
<albertito@blitiri.com.ar> 2018-04-14 09:36:05 UTC |
parent | b491dd3abbf8cd196a8642049178dc8026e997ed |
dnss.go | +3 | -5 |
dnss_test.go | +3 | -3 |
internal/{dnstohttps/https_test.go => httpresolver/json_test.go} | +2 | -3 |
internal/{dnstohttps => httpresolver}/resolver.go | +7 | -7 |
diff --git a/dnss.go b/dnss.go index 7a9ab9d..2ec1f52 100644 --- a/dnss.go +++ b/dnss.go @@ -20,7 +20,7 @@ import ( "sync" "blitiri.com.ar/go/dnss/internal/dnsserver" - "blitiri.com.ar/go/dnss/internal/dnstohttps" + "blitiri.com.ar/go/dnss/internal/httpresolver" "blitiri.com.ar/go/dnss/internal/httpserver" "blitiri.com.ar/go/log" @@ -107,11 +107,9 @@ func main() { var resolver dnsserver.Resolver if *dohMode { - resolver = dnstohttps.NewDoHResolver( - upstream, *httpsClientCAFile) + resolver = httpresolver.NewDoH(upstream, *httpsClientCAFile) } else { - resolver = dnstohttps.NewJSONResolver( - upstream, *httpsClientCAFile) + resolver = httpresolver.NewJSON(upstream, *httpsClientCAFile) } if *enableCache { diff --git a/dnss_test.go b/dnss_test.go index 01a6de1..e4573e3 100644 --- a/dnss_test.go +++ b/dnss_test.go @@ -12,7 +12,7 @@ import ( "testing" "blitiri.com.ar/go/dnss/internal/dnsserver" - "blitiri.com.ar/go/dnss/internal/dnstohttps" + "blitiri.com.ar/go/dnss/internal/httpresolver" "blitiri.com.ar/go/dnss/internal/httpserver" "blitiri.com.ar/go/dnss/internal/testutil" "blitiri.com.ar/go/log" @@ -52,9 +52,9 @@ func Setup(tb testing.TB, mode string) string { var r dnsserver.Resolver if mode == "DoH" { - r = dnstohttps.NewDoHResolver(HTTPSToDNSURL, "") + r = httpresolver.NewDoH(HTTPSToDNSURL, "") } else { - r = dnstohttps.NewJSONResolver(HTTPSToDNSURL, "") + r = httpresolver.NewJSON(HTTPSToDNSURL, "") } dtoh := dnsserver.New(DNSToHTTPSAddr, r, "") go dtoh.ListenAndServe() diff --git a/internal/dnstohttps/https_test.go b/internal/httpresolver/json_test.go similarity index 97% rename from internal/dnstohttps/https_test.go rename to internal/httpresolver/json_test.go index ac5a57e..e4ad0a0 100644 --- a/internal/dnstohttps/https_test.go +++ b/internal/httpresolver/json_test.go @@ -1,5 +1,4 @@ -// Tests for dnss-to-https mode. -package dnstohttps +package httpresolver import ( "flag" @@ -132,7 +131,7 @@ func TestMain(m *testing.M) { fmt.Printf("Failed to parse test http server URL: %v\n", err) os.Exit(1) } - r := NewJSONResolver(srvURL, "") + r := NewJSON(srvURL, "") dth := dnsserver.New(DNSAddr, r, "") go dth.ListenAndServe() diff --git a/internal/dnstohttps/resolver.go b/internal/httpresolver/resolver.go similarity index 93% rename from internal/dnstohttps/resolver.go rename to internal/httpresolver/resolver.go index 233d0c8..426a6c0 100644 --- a/internal/dnstohttps/resolver.go +++ b/internal/httpresolver/resolver.go @@ -1,4 +1,4 @@ -package dnstohttps +package httpresolver import ( "bytes" @@ -22,7 +22,7 @@ import ( ) // httpsResolver implements the dnsserver.Resolver interface by querying a -// server via DNS-over-HTTPS. +// server via DNS over HTTPS. // // It supports two modes: JSON (like https://dns.google.com) and DoH // (https://tools.ietf.org/html/draft-ietf-doh-dns-over-https-05). @@ -47,9 +47,9 @@ func loadCertPool(caFile string) (*x509.CertPool, error) { return pool, nil } -// NewJSONResolver creates a new JSON resolver which uses the given upstream -// URL to resolve queries. -func NewJSONResolver(upstream *url.URL, caFile string) *httpsResolver { +// NewJSON creates a new JSON resolver which uses the given upstream URL to +// resolve queries. +func NewJSON(upstream *url.URL, caFile string) *httpsResolver { return &httpsResolver{ Upstream: upstream, CAFile: caFile, @@ -57,9 +57,9 @@ func NewJSONResolver(upstream *url.URL, caFile string) *httpsResolver { } } -// NewDoHResolver creates a new DoH resolver, which uses the given upstream +// NewDoH creates a new DoH resolver, which uses the given upstream // URL to resolve queries. -func NewDoHResolver(upstream *url.URL, caFile string) *httpsResolver { +func NewDoH(upstream *url.URL, caFile string) *httpsResolver { return &httpsResolver{ Upstream: upstream, CAFile: caFile,