Skip to content

Commit 1d47564

Browse files
committed
refactor proxy condition
1 parent d7a29ee commit 1d47564

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/config.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import { OpenIDConnectAuth } from './oidc_auth.js';
3434
import WebSocket from 'isomorphic-ws';
3535
import child_process from 'node:child_process';
3636
import { SocksProxyAgent } from 'socks-proxy-agent';
37-
import { HttpProxyAgent, HttpsProxyAgent } from 'hpagent';
37+
import { HttpProxyAgent, HttpProxyAgentOptions, HttpsProxyAgent, HttpsProxyAgentOptions } from 'hpagent';
3838

3939
const SERVICEACCOUNT_ROOT: string = '/var/run/secrets/kubernetes.io/serviceaccount';
4040
const SERVICEACCOUNT_CA_PATH: string = SERVICEACCOUNT_ROOT + '/ca.crt';
@@ -254,17 +254,16 @@ export class KubeConfig implements SecurityAuthentication {
254254

255255
if (cluster && cluster.proxyUrl) {
256256
if (cluster.proxyUrl.startsWith('socks')) {
257+
agentOptions.rejectUnauthorized = false;
257258
agent = new SocksProxyAgent(cluster.proxyUrl, agentOptions);
258-
} else if (cluster.server.startsWith('http')) {
259-
agent = new HttpProxyAgent({
260-
proxy: cluster.proxyUrl,
261-
...agentOptions,
262-
});
263259
} else if (cluster.server.startsWith('https')) {
264-
agent = new HttpsProxyAgent({
265-
proxy: cluster.proxyUrl,
266-
...agentOptions,
267-
});
260+
const httpsProxyAgentOptions: HttpsProxyAgentOptions = agentOptions as HttpsProxyAgentOptions;
261+
httpsProxyAgentOptions.proxy = cluster.proxyUrl;
262+
agent = new HttpsProxyAgent(httpsProxyAgentOptions);
263+
} else if (cluster.server.startsWith('http')) {
264+
const httpProxyAgentOptions: HttpProxyAgentOptions = agentOptions as HttpProxyAgentOptions;
265+
httpProxyAgentOptions.proxy = cluster.proxyUrl;
266+
agent = new HttpProxyAgent(httpProxyAgentOptions);
268267
} else {
269268
throw new Error('Unsupported proxy type');
270269
}

0 commit comments

Comments
 (0)