-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use tsurlfilter's DNS engine #2136
Conversation
@ameshkov FYI Hosts-only mode is for testing blocking at the host level only. The In actual DNS mode there would be no URL from which to extract the hostname, but the |
const result = TSUrlFilter.hostsOnly ? | ||
this.matchHostname(url) : | ||
this.matchRequest({ url, frameUrl, type }); | ||
return result !== null && !result.whitelist; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something worth noting is that the DNS engine also supports whitelisting rules. This is also true of other content blockers like uBlock Origin. But we have no whitelisting rules in our hosts.txt
file here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, it also supports a little different subset of rules & modifiers, the syntax is explained here:
https://github.com/AdguardTeam/AdGuardHome/wiki/Hosts-Blocklists
Although, tsurlfilter
is only capable of basic matching since it is only used for simple rules validation by different automation scripts. AdGuard DNS and AdGuard Home use another content blocking library.
@ameshkov thanks for helping with the integration. The only thing left now is serialization and deserialization. I could not find anything in the Since the library is under development, it's not so important to implement this now. In the future, when an API is available, we'll have to implement the following two functions in class TSUrlFilter {
async serialize() {
// return data in serialized format
}
async deserialize(serialized) {
// initialize engine with given data in serialized format
}
} |
This patch uses the DNS engine in @adguard/tsurlfilter for hosts-only mode.