*Re-implement blacklist

This commit is contained in:
Derrick Hammer 2022-08-18 20:11:22 -04:00
parent 8b57218172
commit 12dfdb750c
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
2 changed files with 18 additions and 18 deletions

View File

@ -2,7 +2,6 @@
"name": "@lumeweb/resolver-module-handshake",
"version": "0.1.0",
"dependencies": {
"@lumeweb/resolver": "github:LumeWeb/resolver#modular",
"@lumeweb/resolver-common": "github:LumeWeb/resolver-common",
"@lumeweb/tld-enum": "github:LumeWeb/list-of-top-level-domains"
}

View File

@ -5,29 +5,30 @@ import {
DNSResult,
isDomain,
isIp,
isPromise,
normalizeDomain,
resolverEmptyResponse,
ResolverModule,
ResolverOptions,
} from "@lumeweb/resolver-common";
import type { ResolverRegistry } from "@lumeweb/resolver";
import { getTld } from "@lumeweb/resolver-common";
import { DNSRecord } from "@lumeweb/resolver-common";
const HIP5_EXTENSIONS = ["eth", "_eth"];
export default class Handshake extends AbstractResolverModule {
/* private tldBlacklist: string[] = [];
private async buildBlacklist(): Promise<Set<string>> {
const blacklist = new Set<string>();
for (const resolver: ResolverModule of this.resolver.resolvers) {
let tlds = resolver.getSupportedTlds();
if (isPromise(tlds as any)) {
tlds = await tlds;
}
tlds.map((item) => blacklist.add(item));
}
constructor(resolver: ResolverRegistry) {
super(resolver);
for (const subresolver of resolver.resolvers) {
this.tldBlacklist = [
...this.tldBlacklist,
...subresolver.getSupportedTlds(),
];
}
}*/
return blacklist;
}
async resolve(
domain: string,
@ -36,11 +37,11 @@ export default class Handshake extends AbstractResolverModule {
): Promise<DNSResult> {
const tld = getTld(domain);
/*
if (this.tldBlacklist.includes(tld)) {
return false;
}
*/
const blacklist = await this.buildBlacklist();
if (blacklist.has(tld)) {
return resolverEmptyResponse();
}
if (isIp(domain)) {
return resolverEmptyResponse();