Merge pull request #1014 from safing/fix/doh-failing

Fix DoH base64 encoding
This commit is contained in:
Vladimir Stoilov
2022-12-07 10:11:44 +02:00
committed by GitHub

View File

@@ -70,9 +70,9 @@ func (hr *HTTPSResolver) Query(ctx context.Context, q *Query) (*RRCache, error)
if err != nil { if err != nil {
return nil, err return nil, err
} }
b64dns := base64.RawStdEncoding.EncodeToString(buf) b64dns := base64.RawURLEncoding.EncodeToString(buf)
// Build and execute http reuqest // Build and execute http request
url := &url.URL{ url := &url.URL{
Scheme: "https", Scheme: "https",
Host: hr.resolver.ServerAddress, Host: hr.resolver.ServerAddress,
@@ -94,6 +94,10 @@ func (hr *HTTPSResolver) Query(ctx context.Context, q *Query) (*RRCache, error)
_ = resp.Body.Close() _ = resp.Body.Close()
}() }()
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("http request failed with %s", resp.Status)
}
// Try to read the result // Try to read the result
body, err := io.ReadAll(resp.Body) body, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {