*Re-implement blacklist
This commit is contained in:
parent
8b57218172
commit
12dfdb750c
|
@ -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"
|
||||
}
|
||||
|
|
33
src/index.ts
33
src/index.ts
|
@ -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[] = [];
|
||||
|
||||
constructor(resolver: ResolverRegistry) {
|
||||
super(resolver);
|
||||
|
||||
for (const subresolver of resolver.resolvers) {
|
||||
this.tldBlacklist = [
|
||||
...this.tldBlacklist,
|
||||
...subresolver.getSupportedTlds(),
|
||||
];
|
||||
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));
|
||||
}
|
||||
|
||||
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();
|
||||
|
|
Loading…
Reference in New Issue