*Re-implement blacklist
This commit is contained in:
parent
8b57218172
commit
12dfdb750c
|
@ -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"
|
||||||
}
|
}
|
||||||
|
|
35
src/index.ts
35
src/index.ts
|
@ -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();
|
||||||
|
|
Loading…
Reference in New Issue