*Update dist
This commit is contained in:
parent
cab30a8c13
commit
bc190774c0
|
@ -19,6 +19,7 @@ export default class Handshake extends AbstractResolverModule {
|
||||||
return blacklist;
|
return blacklist;
|
||||||
}
|
}
|
||||||
async resolve(domain, options, bypassCache) {
|
async resolve(domain, options, bypassCache) {
|
||||||
|
options.options = options.options || {};
|
||||||
const tld = getTld(domain);
|
const tld = getTld(domain);
|
||||||
const blacklist = await this.buildBlacklist();
|
const blacklist = await this.buildBlacklist();
|
||||||
if (blacklist.has(tld)) {
|
if (blacklist.has(tld)) {
|
||||||
|
@ -38,7 +39,7 @@ export default class Handshake extends AbstractResolverModule {
|
||||||
for (const record of chainRecords) {
|
for (const record of chainRecords) {
|
||||||
switch (record.type) {
|
switch (record.type) {
|
||||||
case "NS": {
|
case "NS": {
|
||||||
await this.processNs(domain, record, records, options, bypassCache);
|
await this.processNs(domain, record, records, chainRecords, options, bypassCache);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "GLUE4": {
|
case "GLUE4": {
|
||||||
|
@ -74,29 +75,36 @@ export default class Handshake extends AbstractResolverModule {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
records = [
|
||||||
|
...new Set(records.map((item) => JSON.stringify(item))),
|
||||||
|
].map((item) => JSON.parse(item));
|
||||||
if (0 < records.length) {
|
if (0 < records.length) {
|
||||||
return resolveSuccess(records);
|
return resolveSuccess(records);
|
||||||
}
|
}
|
||||||
return resolverEmptyResponse();
|
return resolverEmptyResponse();
|
||||||
}
|
}
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
async processNs(domain, record, records, options, bypassCache) {
|
async processNs(domain, record, records, hnsRecords, options, bypassCache) {
|
||||||
if (![DNS_RECORD_TYPE.A, DNS_RECORD_TYPE.CNAME, DNS_RECORD_TYPE.NS].includes(options.type)) {
|
if (![DNS_RECORD_TYPE.A, DNS_RECORD_TYPE.CNAME, DNS_RECORD_TYPE.NS].includes(options.type)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const glue = records.slice().find((item) =>
|
const glue = hnsRecords.slice().find((item) =>
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
["GLUE4", "GLUE6"].includes(item.type) && item.ns === record.ns);
|
["GLUE4", "GLUE6"].includes(item.type) && item.ns === record.ns);
|
||||||
if (glue) {
|
if (glue && options.type !== DNS_RECORD_TYPE.NS) {
|
||||||
return this.processGlue(domain, record, records, options, bypassCache);
|
return this.processGlue(domain, glue, records, options, bypassCache);
|
||||||
|
}
|
||||||
|
if (options.type === DNS_RECORD_TYPE.NS) {
|
||||||
|
records.push({ type: options.type, value: record.ns });
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
const foundDomain = normalizeDomain(record.ns);
|
const foundDomain = normalizeDomain(record.ns);
|
||||||
let isIcann = false;
|
let isIcann = false;
|
||||||
let isHip5 = false;
|
let isHip5 = false;
|
||||||
let hip5Parts = foundDomain.split(".");
|
let hip5Parts = foundDomain.split(".");
|
||||||
if (hip5Parts.length >= 2 &&
|
if (hip5Parts.length >= 2 &&
|
||||||
[...options.options?.hip5, ...HIP5_EXTENSIONS].includes(hip5Parts[hip5Parts.length - 1])) {
|
[...(options.options?.hip5 ?? []), ...HIP5_EXTENSIONS].includes(hip5Parts[hip5Parts.length - 1])) {
|
||||||
isHip5 = true;
|
isHip5 = true;
|
||||||
}
|
}
|
||||||
if ((isDomain(foundDomain) || /[a-zA-Z0-9\-]+/.test(foundDomain)) &&
|
if ((isDomain(foundDomain) || /[a-zA-Z0-9\-]+/.test(foundDomain)) &&
|
||||||
|
@ -116,6 +124,7 @@ export default class Handshake extends AbstractResolverModule {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
return resolverEmptyResponse();
|
||||||
}
|
}
|
||||||
return this.resolver.resolve(domain, {
|
return this.resolver.resolve(domain, {
|
||||||
...options,
|
...options,
|
||||||
|
@ -130,7 +139,7 @@ export default class Handshake extends AbstractResolverModule {
|
||||||
records.push.apply(records, result.records);
|
records.push.apply(records, result.records);
|
||||||
}
|
}
|
||||||
async processGlue(domain, record, records, options, bypassCache) {
|
async processGlue(domain, record, records, options, bypassCache) {
|
||||||
if (![DNS_RECORD_TYPE.A, DNS_RECORD_TYPE.CNAME, DNS_RECORD_TYPE.NS].includes(options.type)) {
|
if (![DNS_RECORD_TYPE.A, DNS_RECORD_TYPE.CNAME].includes(options.type)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isDomain(record.ns) && isIp(record.address)) {
|
if (isDomain(record.ns) && isIp(record.address)) {
|
||||||
|
|
Loading…
Reference in New Issue