Compare commits
3 Commits
fix/releas
...
preview-ax
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
46e95317f6 | ||
|
|
b55c49c360 | ||
|
|
f46773ec8f |
@@ -97,7 +97,10 @@ app
|
|||||||
|
|
||||||
// Register HTTP proxy
|
// Register HTTP proxy
|
||||||
if (settings.network.proxy.enabled) {
|
if (settings.network.proxy.enabled) {
|
||||||
await createCustomProxyAgent(settings.network.proxy);
|
await createCustomProxyAgent(
|
||||||
|
settings.network.proxy,
|
||||||
|
settings.network.forceIpv4First
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Migrate library types
|
// Migrate library types
|
||||||
|
|||||||
@@ -11,9 +11,14 @@ export let requestInterceptorFunction: (
|
|||||||
) => InternalAxiosRequestConfig;
|
) => InternalAxiosRequestConfig;
|
||||||
|
|
||||||
export default async function createCustomProxyAgent(
|
export default async function createCustomProxyAgent(
|
||||||
proxySettings: ProxySettings
|
proxySettings: ProxySettings,
|
||||||
|
forceIpv4First?: boolean
|
||||||
) {
|
) {
|
||||||
const defaultAgent = new Agent({ keepAliveTimeout: 5000 });
|
const defaultAgent = new Agent({
|
||||||
|
keepAliveTimeout: 5000,
|
||||||
|
connections: 50,
|
||||||
|
connect: forceIpv4First ? { family: 4 } : undefined,
|
||||||
|
});
|
||||||
|
|
||||||
const skipUrl = (url: string | URL) => {
|
const skipUrl = (url: string | URL) => {
|
||||||
const hostname =
|
const hostname =
|
||||||
@@ -67,16 +72,23 @@ export default async function createCustomProxyAgent(
|
|||||||
uri: proxyUrl,
|
uri: proxyUrl,
|
||||||
token,
|
token,
|
||||||
keepAliveTimeout: 5000,
|
keepAliveTimeout: 5000,
|
||||||
|
connections: 50,
|
||||||
|
connect: forceIpv4First ? { family: 4 } : undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
setGlobalDispatcher(proxyAgent.compose(noProxyInterceptor));
|
setGlobalDispatcher(proxyAgent.compose(noProxyInterceptor));
|
||||||
|
|
||||||
axios.defaults.httpAgent = new HttpProxyAgent(proxyUrl, {
|
const agentOptions = {
|
||||||
headers: token ? { 'proxy-authorization': token } : undefined,
|
headers: token ? { 'proxy-authorization': token } : undefined,
|
||||||
});
|
keepAlive: true,
|
||||||
axios.defaults.httpsAgent = new HttpsProxyAgent(proxyUrl, {
|
maxSockets: 50,
|
||||||
headers: token ? { 'proxy-authorization': token } : undefined,
|
maxFreeSockets: 10,
|
||||||
});
|
timeout: 5000,
|
||||||
|
scheduling: 'lifo' as const,
|
||||||
|
family: forceIpv4First ? 4 : undefined,
|
||||||
|
};
|
||||||
|
axios.defaults.httpAgent = new HttpProxyAgent(proxyUrl, agentOptions);
|
||||||
|
axios.defaults.httpsAgent = new HttpsProxyAgent(proxyUrl, agentOptions);
|
||||||
|
|
||||||
requestInterceptorFunction = (config) => {
|
requestInterceptorFunction = (config) => {
|
||||||
const url = config.baseURL
|
const url = config.baseURL
|
||||||
|
|||||||
Reference in New Issue
Block a user