diff --git a/src/core/Operation.mjs b/src/core/Operation.mjs index d57f885d..c0907fe8 100755 --- a/src/core/Operation.mjs +++ b/src/core/Operation.mjs @@ -23,6 +23,7 @@ class Operation { this._breakpoint = false; this._disabled = false; this._flowControl = false; + this._manualBake = false; this._ingList = []; // Public fields @@ -282,6 +283,7 @@ class Operation { return this._flowControl; } + /** * Set whether this Operation is a flowcontrol op. * @@ -291,6 +293,26 @@ class Operation { 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; diff --git a/src/core/config/scripts/generateConfig.mjs b/src/core/config/scripts/generateConfig.mjs index 7f0dfc59..335d47b8 100644 --- a/src/core/config/scripts/generateConfig.mjs +++ b/src/core/config/scripts/generateConfig.mjs @@ -41,6 +41,7 @@ for (const opObj in Ops) { inputType: op.inputType, outputType: op.presentType, flowControl: op.flowControl, + manualBake: op.manualBake, args: op.args }; diff --git a/src/core/operations/DNSOverHTTPS.mjs b/src/core/operations/DNSOverHTTPS.mjs index 2cac79bf..b56feb6a 100644 --- a/src/core/operations/DNSOverHTTPS.mjs +++ b/src/core/operations/DNSOverHTTPS.mjs @@ -1,5 +1,5 @@ /** - * @author h345983745 [] + * @author h345983745 * @copyright Crown Copyright 2019 * @license Apache-2.0 */ @@ -7,24 +7,26 @@ import Operation from "../Operation"; 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() { super(); this.name = "DNS over HTTPS"; this.module = "Default"; - this.description = ["Takes a single domain name and performs a DNS lookup using DNS over HTTPS.", - "

", - "By default, Cloudflare and Google DNS over HTTPS services are supported.", - "

", - "Can be used with any service that supports the GET parameters name and type."].join("\n"); - this.infoURL = "https://en.wikipedia.org/wiki/DNS_over_HTTPS"; + this.description = [ + "Takes a single domain name and performs a DNS lookup using DNS over HTTPS.", + "

", + "By default, Cloudflare and Google DNS over HTTPS services are supported.", + "

", + "Can be used with any service that supports the GET parameters name and type." + ].join("\n"); + this.infoURL = "https://wikipedia.org/wiki/DNS_over_HTTPS"; this.inputType = "string"; this.outputType = "JSON"; this.manualBake = true; @@ -89,39 +91,35 @@ class HTTPSOverDNS extends Operation { return fetch(url, {headers: {"accept": "application/dns-json"}}).then(response => { return response.json(); - }) - .then(data => { - if (justAnswer) { - return this.extractData(data.Answer); - } - return data; + }).then(data => { + if (justAnswer) { + return extractData(data.Answer); + } + return data; + }).catch(e => { + throw new OperationError(`Error making request to ${url}\n${e.toString()}`); + }); - }).catch(e => { - throw new OperationError("Error making request to : " + url + "\n" + - "Error Message: " + e.toString()); - }); - - } - - - /** - * Construct an array of just data from a DNS Answer section - * @private - * @param {JSON} data - * @returns {JSON} - */ - extractData(data) { - if (typeof(data) == "undefined"){ - return []; - } else { - const dataValues = []; - data.forEach(element => { - dataValues.push(element.data); - }); - return dataValues; - - } } } -export default HTTPSOverDNS; +/** + * Construct an array of just data from a DNS Answer section + * + * @private + * @param {JSON} data + * @returns {JSON} + */ +function extractData(data) { + if (typeof(data) == "undefined"){ + return []; + } else { + const dataValues = []; + data.forEach(element => { + dataValues.push(element.data); + }); + return dataValues; + } +} + +export default DNSOverHTTPS;