Tidied up 'DNS over HTTPS' operation and fixed manualBake flag.

master
n1474335 2019-02-08 18:02:13 +00:00
parent b8ecd83bfd
commit ab43635583
3 changed files with 63 additions and 42 deletions

View File

@ -23,6 +23,7 @@ class Operation {
this._breakpoint = false; this._breakpoint = false;
this._disabled = false; this._disabled = false;
this._flowControl = false; this._flowControl = false;
this._manualBake = false;
this._ingList = []; this._ingList = [];
// Public fields // Public fields
@ -282,6 +283,7 @@ class Operation {
return this._flowControl; return this._flowControl;
} }
/** /**
* Set whether this Operation is a flowcontrol op. * Set whether this Operation is a flowcontrol op.
* *
@ -291,6 +293,26 @@ class Operation {
this._flowControl = !!value; this._flowControl = !!value;
} }
/**
* Returns true if this Operation should not trigger AutoBake.
*
* @returns {boolean}
*/
get manualBake() {
return this._manualBake;
}
/**
* Set whether this Operation should trigger AutoBake.
*
* @param {boolean} value
*/
set manualBake(value) {
this._manualBake = !!value;
}
} }
export default Operation; export default Operation;

View File

@ -41,6 +41,7 @@ for (const opObj in Ops) {
inputType: op.inputType, inputType: op.inputType,
outputType: op.presentType, outputType: op.presentType,
flowControl: op.flowControl, flowControl: op.flowControl,
manualBake: op.manualBake,
args: op.args args: op.args
}; };

View File

@ -1,5 +1,5 @@
/** /**
* @author h345983745 [] * @author h345983745
* @copyright Crown Copyright 2019 * @copyright Crown Copyright 2019
* @license Apache-2.0 * @license Apache-2.0
*/ */
@ -7,24 +7,26 @@ import Operation from "../Operation";
import OperationError from "../errors/OperationError"; import OperationError from "../errors/OperationError";
/** /**
* HTTPS Over DNS operation * DNS over HTTPS operation
*/ */
class HTTPSOverDNS extends Operation { class DNSOverHTTPS extends Operation {
/** /**
* HTTPSOverDNS constructor * DNSOverHTTPS constructor
*/ */
constructor() { constructor() {
super(); super();
this.name = "DNS over HTTPS"; this.name = "DNS over HTTPS";
this.module = "Default"; this.module = "Default";
this.description = ["Takes a single domain name and performs a DNS lookup using DNS over HTTPS.", this.description = [
"Takes a single domain name and performs a DNS lookup using DNS over HTTPS.",
"<br><br>", "<br><br>",
"By default, <a href='https://developers.cloudflare.com/1.1.1.1/dns-over-https/'>Cloudflare</a> and <a href='https://developers.google.com/speed/public-dns/docs/dns-over-https'>Google</a> DNS over HTTPS services are supported.", "By default, <a href='https://developers.cloudflare.com/1.1.1.1/dns-over-https/'>Cloudflare</a> and <a href='https://developers.google.com/speed/public-dns/docs/dns-over-https'>Google</a> DNS over HTTPS services are supported.",
"<br><br>", "<br><br>",
"Can be used with any service that supports the GET parameters <code>name</code> and <code>type</code>."].join("\n"); "Can be used with any service that supports the GET parameters <code>name</code> and <code>type</code>."
this.infoURL = "https://en.wikipedia.org/wiki/DNS_over_HTTPS"; ].join("\n");
this.infoURL = "https://wikipedia.org/wiki/DNS_over_HTTPS";
this.inputType = "string"; this.inputType = "string";
this.outputType = "JSON"; this.outputType = "JSON";
this.manualBake = true; this.manualBake = true;
@ -89,28 +91,26 @@ class HTTPSOverDNS extends Operation {
return fetch(url, {headers: {"accept": "application/dns-json"}}).then(response => { return fetch(url, {headers: {"accept": "application/dns-json"}}).then(response => {
return response.json(); return response.json();
}) }).then(data => {
.then(data => {
if (justAnswer) { if (justAnswer) {
return this.extractData(data.Answer); return extractData(data.Answer);
} }
return data; return data;
}).catch(e => { }).catch(e => {
throw new OperationError("Error making request to : " + url + "\n" + throw new OperationError(`Error making request to ${url}\n${e.toString()}`);
"Error Message: " + e.toString());
}); });
} }
}
/**
/**
* Construct an array of just data from a DNS Answer section * Construct an array of just data from a DNS Answer section
*
* @private * @private
* @param {JSON} data * @param {JSON} data
* @returns {JSON} * @returns {JSON}
*/ */
extractData(data) { function extractData(data) {
if (typeof(data) == "undefined"){ if (typeof(data) == "undefined"){
return []; return [];
} else { } else {
@ -119,9 +119,7 @@ class HTTPSOverDNS extends Operation {
dataValues.push(element.data); dataValues.push(element.data);
}); });
return dataValues; return dataValues;
}
} }
} }
export default HTTPSOverDNS; export default DNSOverHTTPS;