Skip to content
This repository has been archived by the owner on Sep 19, 2023. It is now read-only.

Commit

Permalink
Merge pull request #33 from jp-modernisation-gouv-fr/master
Browse files Browse the repository at this point in the history
add proxy option
  • Loading branch information
michaelkaye committed Dec 21, 2018
2 parents 267c79f + 8628987 commit 4ab98de
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions config/default.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ scan:
#
# altRemovalCmd: 'rm'

# Optional. If need to use a proxy to access baseUrl
# proxy: "http://10.228.1.1:80"

middleware:
# Configuration for using encrypted_body in POST requests.
encryptedBody:
Expand Down
1 change: 1 addition & 0 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const configSchema = Joi.object().keys({
directDownload: Joi.boolean(),
}).required(),
altRemovalCmd: Joi.string(),
proxy: Joi.string(),
middleware: Joi.object().keys({
encryptedBody: Joi.object().keys({
pickleKey: Joi.string().required(),
Expand Down
10 changes: 9 additions & 1 deletion src/reporting.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const executeCommand = require('./execute-cmd.js');
const decryptFile = require('./decrypt-file.js');

const crypto = require('crypto');
const { getConfig } = require('./config.js');

const { getConfig } = require('./config.js');
const fileType = require('file-type');
Expand Down Expand Up @@ -197,8 +198,15 @@ async function _generateReportFromDownload(console, domain, mediaId, matrixFile,
try {
downloadHeaders = await new Promise((resolve, reject) => {
let responseHeaders;
let connect = {url: httpUrl, encoding: null, qs: thumbnailQueryParams};
const config = getConfig();
const proxy = config.proxy;
if (proxy != null) {
connect.proxy = proxy;
}

request
.get({url: httpUrl, encoding: null, qs: thumbnailQueryParams})
.get(connect)
.on('error', reject)
.on('response', (response) => {
responseHeaders = response.headers;
Expand Down

0 comments on commit 4ab98de

Please sign in to comment.