*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", "name": "@lumeweb/resolver-module-handshake",
"version": "0.1.0", "version": "0.1.0",
"dependencies": { "dependencies": {
"@lumeweb/resolver": "github:LumeWeb/resolver#modular",
"@lumeweb/resolver-common": "github:LumeWeb/resolver-common", "@lumeweb/resolver-common": "github:LumeWeb/resolver-common",
"@lumeweb/tld-enum": "github:LumeWeb/list-of-top-level-domains" "@lumeweb/tld-enum": "github:LumeWeb/list-of-top-level-domains"
} }

View File

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