bun fetch dont support sock proxy :(

This commit is contained in:
Bojan Kucera 2025-06-06 23:08:54 -04:00
parent 5904af213f
commit 08bb21cee7
5 changed files with 89 additions and 77 deletions

View file

@ -2,6 +2,7 @@ import { HttpsProxyAgent } from 'https-proxy-agent';
import { SocksProxyAgent } from 'socks-proxy-agent';
import type { ProxyConfig } from './types.js';
import { validateProxyConfig } from './types.js';
import { HttpProxyAgent } from 'http-proxy-agent';
export class ProxyManager {
/**
@ -11,7 +12,13 @@ export class ProxyManager {
const { protocol, host, port, username, password } = proxy;
let proxyUrl: string;
console.log('Creating proxy agent with config:', {
protocol,
host,
port,
username,
password
});
if (username && password) {
proxyUrl = `${protocol}://${encodeURIComponent(username)}:${encodeURIComponent(password)}@${host}:${port}`;
} else {
@ -20,6 +27,7 @@ export class ProxyManager {
switch (protocol) {
case 'http':
return new HttpProxyAgent(proxyUrl);
case 'https':
return new HttpsProxyAgent(proxyUrl);
case 'socks4':