mirror of
https://github.com/usebruno/bruno.git
synced 2024-11-07 16:44:27 +01:00
chore: add support for cli
This commit is contained in:
parent
ce2e997c06
commit
bf90ee96e5
4
package-lock.json
generated
4
package-lock.json
generated
@ -16705,6 +16705,7 @@
|
|||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"mustache": "^4.2.0",
|
"mustache": "^4.2.0",
|
||||||
"qs": "^6.11.0",
|
"qs": "^6.11.0",
|
||||||
|
"socks-proxy-agent": "^8.0.2",
|
||||||
"yargs": "^17.6.2"
|
"yargs": "^17.6.2"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
@ -20024,6 +20025,7 @@
|
|||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"mustache": "^4.2.0",
|
"mustache": "^4.2.0",
|
||||||
"qs": "^6.11.0",
|
"qs": "^6.11.0",
|
||||||
|
"socks-proxy-agent": "*",
|
||||||
"yargs": "^17.6.2"
|
"yargs": "^17.6.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -21161,7 +21163,7 @@
|
|||||||
"nanoid": "3.3.4",
|
"nanoid": "3.3.4",
|
||||||
"node-machine-id": "^1.1.12",
|
"node-machine-id": "^1.1.12",
|
||||||
"qs": "^6.11.0",
|
"qs": "^6.11.0",
|
||||||
"socks-proxy-agent": "*",
|
"socks-proxy-agent": "^8.0.2",
|
||||||
"uuid": "^9.0.0",
|
"uuid": "^9.0.0",
|
||||||
"vm2": "^3.9.13",
|
"vm2": "^3.9.13",
|
||||||
"yup": "^0.32.11"
|
"yup": "^0.32.11"
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"mustache": "^4.2.0",
|
"mustache": "^4.2.0",
|
||||||
"qs": "^6.11.0",
|
"qs": "^6.11.0",
|
||||||
|
"socks-proxy-agent": "^8.0.2",
|
||||||
"yargs": "^17.6.2"
|
"yargs": "^17.6.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ const { getOptions } = require('../utils/bru');
|
|||||||
const https = require('https');
|
const https = require('https');
|
||||||
const { HttpsProxyAgent } = require('https-proxy-agent');
|
const { HttpsProxyAgent } = require('https-proxy-agent');
|
||||||
const { HttpProxyAgent } = require('http-proxy-agent');
|
const { HttpProxyAgent } = require('http-proxy-agent');
|
||||||
|
const { SocksProxyAgent } = require('socks-proxy-agent');
|
||||||
const { makeAxiosInstance } = require('../utils/axios-instance');
|
const { makeAxiosInstance } = require('../utils/axios-instance');
|
||||||
|
|
||||||
const runSingleRequest = async function (
|
const runSingleRequest = async function (
|
||||||
@ -96,7 +97,7 @@ const runSingleRequest = async function (
|
|||||||
// set proxy if enabled
|
// set proxy if enabled
|
||||||
const proxyEnabled = get(brunoConfig, 'proxy.enabled', false);
|
const proxyEnabled = get(brunoConfig, 'proxy.enabled', false);
|
||||||
if (proxyEnabled) {
|
if (proxyEnabled) {
|
||||||
let proxy;
|
let proxyUri;
|
||||||
const interpolationOptions = {
|
const interpolationOptions = {
|
||||||
envVars: envVariables,
|
envVars: envVariables,
|
||||||
collectionVariables,
|
collectionVariables,
|
||||||
@ -107,6 +108,7 @@ const runSingleRequest = async function (
|
|||||||
const proxyHostname = interpolateString(get(brunoConfig, 'proxy.hostname'), interpolationOptions);
|
const proxyHostname = interpolateString(get(brunoConfig, 'proxy.hostname'), interpolationOptions);
|
||||||
const proxyPort = interpolateString(get(brunoConfig, 'proxy.port'), interpolationOptions);
|
const proxyPort = interpolateString(get(brunoConfig, 'proxy.port'), interpolationOptions);
|
||||||
const proxyAuthEnabled = get(brunoConfig, 'proxy.auth.enabled', false);
|
const proxyAuthEnabled = get(brunoConfig, 'proxy.auth.enabled', false);
|
||||||
|
const socksEnabled = proxyProtocol.includes('socks');
|
||||||
|
|
||||||
interpolateString;
|
interpolateString;
|
||||||
|
|
||||||
@ -114,17 +116,25 @@ const runSingleRequest = async function (
|
|||||||
const proxyAuthUsername = interpolateString(get(brunoConfig, 'proxy.auth.username'), interpolationOptions);
|
const proxyAuthUsername = interpolateString(get(brunoConfig, 'proxy.auth.username'), interpolationOptions);
|
||||||
const proxyAuthPassword = interpolateString(get(brunoConfig, 'proxy.auth.password'), interpolationOptions);
|
const proxyAuthPassword = interpolateString(get(brunoConfig, 'proxy.auth.password'), interpolationOptions);
|
||||||
|
|
||||||
proxy = `${proxyProtocol}://${proxyAuthUsername}:${proxyAuthPassword}@${proxyHostname}:${proxyPort}`;
|
proxyUri = `${proxyProtocol}://${proxyAuthUsername}:${proxyAuthPassword}@${proxyHostname}:${proxyPort}`;
|
||||||
} else {
|
} else {
|
||||||
proxy = `${proxyProtocol}://${proxyHostname}:${proxyPort}`;
|
proxyUri = `${proxyProtocol}://${proxyHostname}:${proxyPort}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (socksEnabled) {
|
||||||
|
const socksProxyAgent = new SocksProxyAgent(proxyUri);
|
||||||
|
|
||||||
|
request.httpsAgent = socksProxyAgent;
|
||||||
|
|
||||||
|
request.httpAgent = socksProxyAgent;
|
||||||
|
} else {
|
||||||
request.httpsAgent = new HttpsProxyAgent(
|
request.httpsAgent = new HttpsProxyAgent(
|
||||||
proxy,
|
proxyUri,
|
||||||
Object.keys(httpsAgentRequestFields).length > 0 ? { ...httpsAgentRequestFields } : undefined
|
Object.keys(httpsAgentRequestFields).length > 0 ? { ...httpsAgentRequestFields } : undefined
|
||||||
);
|
);
|
||||||
|
|
||||||
request.httpAgent = new HttpProxyAgent(proxy);
|
request.httpAgent = new HttpProxyAgent(proxyUri);
|
||||||
|
}
|
||||||
} else if (Object.keys(httpsAgentRequestFields).length > 0) {
|
} else if (Object.keys(httpsAgentRequestFields).length > 0) {
|
||||||
request.httpsAgent = new https.Agent({
|
request.httpsAgent = new https.Agent({
|
||||||
...httpsAgentRequestFields
|
...httpsAgentRequestFields
|
||||||
|
Loading…
Reference in New Issue
Block a user