-
-
Notifications
You must be signed in to change notification settings - Fork 74
Description
Description of the bug
The current makeRequest method attempts to automatically complete the user-provided DoH server address into the standard /dns-query?dns=
path.
However, the original code has an issue:
if (!u.pathname) url += '/dns-query?dns={query}';
the condition u.pathname == ''
will never be true
, because in Node.js the pathname
of a URL object is always at least /
and never an empty string. As a result, the auto-completion logic never actually takes effect.
When a developer provides 1.1.1.1
, the expected request should be: https://1.1.1.1/dns-query?dns=<query>
But when a developer provides some-doh-server.example.com
, we cannot be sure whether the intended request is: https://some-doh-server.example.com/dns-query?dns=<query>
or https://some-doh-server.example.com?dns=<query>
Since the RFC4648 DoH specification does not mandate that the path must be /dns-query
, the latter form is also valid. In this situation, we must not automatically rewrite a URL whose pathname is /
into /dns-query
, as this could break the endpoint explicitly chosen by the developer.
In addition, according to RFC4648#4.1
The DNS query is included in a single variable named “dns” in the
query component of the request URI. The value of the “dns” variable
is the content of the DNS request message, encoded with base64url.
The ?dns=
parameter is mandatory, and we must follow the RFC specification. Therefore, the feature of using custom query parameter names is no longer necessary.
Steps To Reproduce
Additional Information
No response