diff --git a/README.md b/README.md index 9f42da7..7e2eed3 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,8 @@ indexer.scanUrl(url) | Wrapper Version | Supported ODD Versions (up to) | Included Version | | --- | --- | --- | -| **6.1.2** | **2.1.0.0** | **2.1.0.0** | +| **6.2.0** | **2.1.0.8** | **2.1.0.8** | +| 6.1.2 | 2.1.0.0 | 2.1.0.0 | | 6.1.0 | 2.1.0.0 | 2.1.0.0 | | 5.1.0 | 2.0.0.6 | 2.0.0.3 | | 5.0.0 | 2.0.0.2 | 2.0.0.0 | @@ -118,6 +119,7 @@ Some intermediary releases might not be fully supported. It is recommended to us - `auth` (`Object`) (optional) Used to configure (HTTP Basic) auth settings - `username` (`String`) (optional, default is `""`]) The user name to use for authentication - `password` (`String`) (optional, default is `""`]) The password to use for authentication + - `auth` (`Object`) (optional) Used to configure additional headers to be sent with each request (cookies, referrers, etc.). Headers are key-value pairs of strings. - `threads` (`Number`) (optional, default is `5`] Number of threads to use for scanning - `timeout` (`Number`) (optional, default is `100`] Number of seconds to wait before timing out - **Returns**: Promise`> diff --git a/config.js b/config.js index 72a1fd3..fae9e86 100644 --- a/config.js +++ b/config.js @@ -2,8 +2,8 @@ module.exports = {} module.exports.GitHubReleasesUrl = `https://api.github.com/repos/KoalaBear84/OpenDirectoryDownloader/releases` module.exports.OpenDirectoryDownloaderVersion = { - version: `v2.1.0.0`, - releaseId: `50845174` + version: `v2.1.0.8`, + releaseId: `53442251` } module.exports.OpenDirectoryDownloaderFolder = `${__dirname}/ODD` module.exports.OpenDirectoryDownloaderOutputFolderName = `Scans` diff --git a/open-directory-downloader.js b/open-directory-downloader.js index bee3f26..a3384dc 100644 --- a/open-directory-downloader.js +++ b/open-directory-downloader.js @@ -51,6 +51,7 @@ module.exports.OpenDirectoryDownloader = class OpenDirectoryDownloader { * @param {Object} [options.auth] Used to configure (HTTP Basic) auth settings * @param {String} [options.auth.username=""] The user name to use for authentication * @param {String} [options.auth.password=""] The password to use for authentication + * @param {Object} [options.headers] Object containing additional headers to use for all HTTP requests * @param {Number} [options.threads=5] Number of threads to use for scanning * @param {Number} [options.timeout=100] Number of seconds to wait before timing out */ @@ -71,6 +72,7 @@ module.exports.OpenDirectoryDownloader = class OpenDirectoryDownloader { options.uploadUrlFile = options.uploadUrlFile || false options.fastScan = options.fastScan || false options.exactSizes = options.exactSizes || false + options.headers = options.headers || {} // both String and URL implement the toString() method, so just use that instead of detecting the type let processArgs = [`-u "${url}"`, `--quit`, `--json`, ] @@ -116,6 +118,16 @@ module.exports.OpenDirectoryDownloader = class OpenDirectoryDownloader { processArgs.push(`"${options.auth.password}"`) } + if (options.headers !== {}) { + Object.entries(options.headers).forEach(([headerName, headerValue]) => { + if (typeof headerValue !== `string`) { + throw new ODDWrapperError(`Header value for ${headerName} is not a string!`) + } + processArgs.push(`--header`) + processArgs.push(`"${headerName}: ${headerValue}"`) + }) + } + const oddProcess = spawn(this.executable, processArgs, { shell: true, cwd: this.outputDir, @@ -164,7 +176,7 @@ module.exports.OpenDirectoryDownloader = class OpenDirectoryDownloader { oddProcess.on(`exit`, (code, signal) => { - this.monitor.stopMonitoring() + this.monitor?.stopMonitoring() this.memoryUsage = 0 }) diff --git a/package-lock.json b/package-lock.json index cb9591f..ec995a6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "open-directory-downloader", - "version": "6.1.2", + "version": "6.2.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index d2583b4..b22c195 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "open-directory-downloader", - "version": "6.1.2", + "version": "6.2.0", "description": "A NodeJS wrapper around KoalaBear84/OpenDirectoryDownloader", "main": "open-directory-downloader.js", "scripts": {