Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ Erii.bind(
if (options.verbose) {
logger.enableDebugMode();
}
if (!options.noProxy && !process.env.NO_PROXY) {
if (options.noProxy) {
ProxyAgent.disableProxy();
} else if (!process.env.NO_PROXY) {
if (process.platform === "win32") {
await ProxyAgent.readWindowsSystemProxy();
}
Expand Down
10 changes: 10 additions & 0 deletions src/utils/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ class ProxyAgentHelper {
* Note: environment variables will override system proxy in Windows.
*/
readProxyConfigurationFromEnv() {
if (process.env.NO_PROXY) {
return;
}
const proxySettings = process.env.ALL_PROXY || process.env.HTTP_PROXY || process.env.HTTPS_PROXY;
if (proxySettings) {
this.setProxy(process.env.ALL_PROXY || process.env.HTTP_PROXY || process.env.HTTPS_PROXY);
Expand Down Expand Up @@ -113,6 +116,13 @@ class ProxyAgentHelper {
// ignore
}
}

/**
* Disable proxy by setting proxyAgentInstance to null
*/
disableProxy() {
this.proxyAgentInstance = null;
}
}

export default new ProxyAgentHelper();
1 change: 1 addition & 0 deletions src/utils/m3u8.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export async function loadM3U8({ path, retries = 1, timeout = 60000, initPrimary
...(!axios.defaults.headers.common["Host"] ? { Host: new URL(path).host } : {}),
},
cancelToken: source.token,
proxy: proxyAgent ? undefined : false, // P3647
});
logger.info("M3U8 file fetched.");
m3u8Content = response.data;
Expand Down
2 changes: 2 additions & 0 deletions src/utils/media.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export function download(url: string, path: string, options: AxiosRequestConfig
},
cancelToken: source.token,
...options,
proxy: proxyAgentInstance ? undefined : false, // P8f0a
});
if (
response.headers["content-length"] &&
Expand Down Expand Up @@ -136,6 +137,7 @@ export async function requestRaw(url: string, options: AxiosRequestConfig = {}):
Host: new URL(url).host,
},
...options,
proxy: proxyAgentInstance ? undefined : false, // P8f0a
});
}
/**
Expand Down