*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"
|
||||||
}
|
}
|
||||||
|
|
33
src/index.ts
33
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>();
|
||||||
constructor(resolver: ResolverRegistry) {
|
for (const resolver: ResolverModule of this.resolver.resolvers) {
|
||||||
super(resolver);
|
let tlds = resolver.getSupportedTlds();
|
||||||
|
if (isPromise(tlds as any)) {
|
||||||
for (const subresolver of resolver.resolvers) {
|
tlds = await tlds;
|
||||||
this.tldBlacklist = [
|
}
|
||||||
...this.tldBlacklist,
|
tlds.map((item) => blacklist.add(item));
|
||||||
...subresolver.getSupportedTlds(),
|
}
|
||||||
];
|
|
||||||
|
return blacklist;
|
||||||
}
|
}
|
||||||
}*/
|
|
||||||
|
|
||||||
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