question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Patch chrome.dns.resolve to support canonical_name flag

See original GitHub issue

Description

Chromium presently supports IP address resolution:

chrome.dns.resolve('www.brave.com', response => {
  console.log(response.address)
})

In order to combat CNAME-trackers, uBO and others are evaluating Firefox’s implementation of the DNS API, which supports passing optional flags:

chrome.dns.resolve('www.brave.com', ['canonical_name']).then( response => {
  console.log(response.canonicalName)
})

There are many other optional flags, but CNAME appears to be the most necessary for now.

Note: Chromium expects a callback as the second argument. Firefox, however, returns a promise.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:4
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
pes10kcommented, Oct 14, 2020

@antonok-edm the idea here is that it might be worth exposing for other extensions that might do adblocking in other ways than brave-core does (folks might want to do disconnect or uBO on top of adblock-rust).

I think it’d be a nice to expose the capability to other extensions if it was easy to do, but if its a medium-to-big lift (say, more than 1-2 days work) its prob not worth doing

0reactions
hackademixcommented, Feb 17, 2022

FWIW uBlock Origin only even bothers to check for the presence of browser.dns on Firefox. It just assumes it doesn’t exist on Chromium, so it won’t even work out of the box.

https://github.com/gorhill/uBlock/blob/11d24abea01fdb1c7070a2940dfda6e43cfe0c2c/platform/firefox/vapi-webrequest.js#L53

It wouldn’t work anyway: even if uBlock could leverage this API, it couldn’t be useful on Chromium because webRequest there doesn’t support asynchronous responses and dns.resolve() is asynchronous in nature.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fix DNS errors - Chromebook Help - Google Support
If you see a DNS (Domain Name System) error, try switching to one of Google's public name servers: Make sure your Chromebook is...
Read more >
dns.resolve() - Mozilla - MDN Web Docs
The canonical name for this record. This is only included in the response if the "canonical_name" flag was passed to resolve() .
Read more >
Add, modify, and delete records | Cloud DNS
Add, modify, and delete DNS records such as A, AAAA, CNAME, and MX records. ... The canonical name to resolve for incoming address...
Read more >
Chrome Host Resolution
Implementation and support of host resolution for the Chrome network stack. Includes client implementations of host resolution protocols (DNS and mDNS), ...
Read more >
DNS | Node.js v19.3.0 Documentation
Supported getaddrinfo flags. dns.lookupService(address, port, callback); dns.resolve(hostname[, rrtype], callback); dns.resolve4(hostname[, options], ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found