updating configuration of proxu address to host and port#149
Conversation
| @@ -1,4 +1,5 @@ | |||
| // Copyright (c) 2026 Broadcom Inc. and its subsidiaries. All Rights Reserved. | |||
| const utils = require("./graphman-utils"); | |||
There was a problem hiding this comment.
Unused import; remove it.
| if(input.agentType === "socks") { | ||
| return createSocksProxyAgent(input, context); | ||
| } else { | ||
| } else { |
There was a problem hiding this comment.
indentation is disturbed. revert this change.
| try { | ||
| const { SocksProxyAgent } = require("socks-proxy-agent"); | ||
| agent = new SocksProxyAgent(proxyConfig.url || new URL(input.address), proxyConfig); | ||
| agent = new SocksProxyAgent(proxyConfig.url || new URL(input.host + ":" + input.port), proxyConfig); |
There was a problem hiding this comment.
change this line to:
agent = new SocksProxyAgent(proxyConfig.url, proxyConfig);
And, make sure that the createProxyConfig method populates the proxyConfig_.url_ always.
There was a problem hiding this comment.
moved to createProxyConfig
| if (isHttps) { | ||
| const { HttpsProxyAgent } = require("https-proxy-agent") | ||
| agent = new HttpsProxyAgent(input.address, proxyConfig); | ||
| agent = new HttpsProxyAgent(completeUrl, proxyConfig); |
There was a problem hiding this comment.
Like above, with the assumption that the createProxyConfig method populates the url.
agent = new HttpsProxyAgent(proxyConfig.url, proxyConfig);
| return agent; | ||
| } | ||
|
|
||
| function createProxyConfig(obj) { |
There was a problem hiding this comment.
Let's populate url field here.
| return agent; | ||
| } | ||
|
|
||
| function createProxyConfig(obj) { |
There was a problem hiding this comment.
And, you require few supporting changes to:
- graphman.configuration
- graphman.sh
| "default": { | ||
| "agentType": "http", | ||
| "address": "http://localhost:3128", | ||
| "host": "http://localhost", |
There was a problem hiding this comment.
The value of the host seems incorrect. It cannot be in URL form. Expected default value is: localhost
| if (cred) { | ||
| if (obj.agentType === "socks") { | ||
| const url = new URL(obj.address); | ||
| if (obj.agentType === "socks") { | ||
| const url = new URL(obj.host); | ||
| if (cred) { | ||
| url.username = cred.username; | ||
| url.password = cred.password; | ||
|
|
||
| proxy.url = url; | ||
| } else { | ||
| } | ||
| url.port = obj.port; | ||
| proxy.url = url; | ||
| } else { | ||
| if (cred) { | ||
| auth = `Basic ${Buffer.from(`${cred.username}:${cred.password}`).toString('base64')}`; | ||
| } | ||
| proxy.url = obj.host + ":" + obj.port; | ||
| } |
There was a problem hiding this comment.
Let's simplify this.
const proxy = {};
const url = new URL(`${obj.agentType}://${obj.host}:${obj.port}`);
if (auth) {
url.username = cred.username;
url.password = cred.password;
}
Object.keys(obj.options).forEach(key => {
proxy[key] = obj.options[key];
});
proxy.url = url;
return proxy;
Updated the configuration for Proxy : as follows
"proxies": {
"default": {
"agentType": "http",
"host": "http://localhost",
"port":3128,
"credential": "proxyCredentials",
"options" : {
"timeout": 30000,
"keepAlive": true,
"maxSockets": 10,
"rejectUnauthorized": false
}
}
}