n8n-nodes-whois
Version:
Whois request
120 lines • 4.63 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Whois = void 0;
const whois_json_1 = __importDefault(require("whois-json"));
const UrlsUtils_1 = require("./utils/UrlsUtils");
class Whois {
constructor() {
this.description = {
displayName: 'Whois Data',
name: 'whois',
icon: 'file:WhoisLogo.svg',
group: ['output'],
version: 1,
triggerPanel: false,
subtitle: '={{$parameter["operation"]}}',
description: 'Get Domain Data from Whois servers',
defaults: {
name: 'Whois Data',
},
inputs: ["main"],
outputs: ["main"],
properties: [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
options: [
{
name: 'Get Whois Data',
value: 'whois',
description: 'Get data from Whois servers',
action: 'Get whois data',
},
],
default: 'whois',
},
{
displayName: 'Target Domain / URL',
name: 'target',
type: 'string',
required: true,
default: 'google.com',
description: 'Define the target domain or URL',
},
{
displayName: 'Options',
name: 'options',
type: 'collection',
placeholder: 'Add option',
default: {},
options: [
{
displayName: 'Extract Domain',
name: 'extract_domain',
type: 'boolean',
default: true,
description: 'Extract domain form URL',
},
{
displayName: 'Follow',
name: 'follow_redirects',
type: 'number',
default: 3,
description: 'The number of times to follow redirects',
},
{
displayName: 'Verbose',
name: 'verbose',
type: 'boolean',
default: false,
description: 'Show verbose results',
},
{
displayName: 'Put Result in Field',
name: 'result_field',
type: 'string',
default: 'whois',
description: 'The name of the output field to put the data in',
},
],
},
],
};
}
async execute() {
const items = this.getInputData();
let item;
const returnItems = [];
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
item = { ...items[itemIndex] };
const newItem = {
json: item.json,
pairedItem: {
item: itemIndex,
},
};
let target = this.getNodeParameter('target', itemIndex);
const options = this.getNodeParameter('options', itemIndex);
const extract_domain = options.extract_domain || true;
const follow_redirects = options.follow_redirects || 3;
const verbose = options.verbose || false;
const result_field = options.result_field || 'whois';
if (extract_domain) {
target = new UrlsUtils_1.UrlsUtils().getDomain(target);
}
newItem.json[result_field] = await (0, whois_json_1.default)(target, {
follow: follow_redirects,
verbose: verbose,
});
returnItems.push(newItem);
}
return [returnItems];
}
}
exports.Whois = Whois;
//# sourceMappingURL=Whois.node.js.map