Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use current agent to determine secure proxy #55

Merged
merged 2 commits into from
Sep 8, 2023
Merged
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: 2 additions & 2 deletions .github/workflows/audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Install npm@latest
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
- name: Install npm@next-9
run: npm i --prefer-online --no-fund --no-audit -g npm@next-9
- name: npm Version
run: npm -v
- name: Install Dependencies
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/ci-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Install npm@latest
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
- name: Install npm@next-9
run: npm i --prefer-online --no-fund --no-audit -g npm@next-9
- name: npm Version
run: npm -v
- name: Install Dependencies
Expand Down Expand Up @@ -194,9 +194,9 @@ jobs:
- name: Install npm@7
if: startsWith(matrix.node-version, '10.')
run: npm i --prefer-online --no-fund --no-audit -g npm@7
- name: Install npm@latest
- name: Install npm@next-9
if: ${{ !startsWith(matrix.node-version, '10.') }}
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
run: npm i --prefer-online --no-fund --no-audit -g npm@next-9
- name: npm Version
run: npm -v
- name: Install Dependencies
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Install npm@latest
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
- name: Install npm@next-9
run: npm i --prefer-online --no-fund --no-audit -g npm@next-9
- name: npm Version
run: npm -v
- name: Install Dependencies
Expand Down Expand Up @@ -91,9 +91,9 @@ jobs:
- name: Install npm@7
if: startsWith(matrix.node-version, '10.')
run: npm i --prefer-online --no-fund --no-audit -g npm@7
- name: Install npm@latest
- name: Install npm@next-9
if: ${{ !startsWith(matrix.node-version, '10.') }}
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
run: npm i --prefer-online --no-fund --no-audit -g npm@next-9
- name: npm Version
run: npm -v
- name: Install Dependencies
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/post-dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Install npm@latest
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
- name: Install npm@next-9
run: npm i --prefer-online --no-fund --no-audit -g npm@next-9
- name: npm Version
run: npm -v
- name: Install Dependencies
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Install npm@latest
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
- name: Install npm@next-9
run: npm i --prefer-online --no-fund --no-audit -g npm@next-9
- name: npm Version
run: npm -v
- name: Install Dependencies
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Install npm@latest
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
- name: Install npm@next-9
run: npm i --prefer-online --no-fund --no-audit -g npm@next-9
- name: npm Version
run: npm -v
- name: Install Dependencies
Expand Down Expand Up @@ -157,8 +157,8 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Install npm@latest
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
- name: Install npm@next-9
run: npm i --prefer-online --no-fund --no-audit -g npm@next-9
- name: npm Version
run: npm -v
- name: Install Dependencies
Expand Down
8 changes: 3 additions & 5 deletions lib/agents.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const tls = require('tls')
const { once } = require('events')
const { createTimeout, abortRace, urlify, appendPort, cacheAgent } = require('./util')
const { normalizeOptions, cacheOptions } = require('./options')
const { getProxy, getProxyType, isSecureProxy, proxyCache } = require('./proxy.js')
const { getProxy, getProxyType, proxyCache } = require('./proxy.js')
const Errors = require('./errors.js')

const createAgent = (base, name) => {
Expand Down Expand Up @@ -43,18 +43,16 @@ const createAgent = (base, name) => {
return
}

const secure = isSecureProxy(proxy)

return cacheAgent({
key: cacheOptions({
...options,
...this.#options,
secure,
secure: SECURE,
timeouts: this.#timeouts,
proxy,
}),
cache: proxyCache,
secure,
secure: SECURE,
proxies: this.#proxy.proxies,
}, proxy, this.#options)
}
Expand Down
8 changes: 0 additions & 8 deletions lib/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,6 @@ const PROXY_ENV = (() => {
})()

const SOCKS_PROTOCOLS = new Set(SocksProxyAgent.protocols)
const SECURE_PROTOCOLS = new Set([...SocksProxyAgent.protocols, 'https'])

const isSecureProxy = (url) => {
url = urlify(url)
const protocol = url.protocol.slice(0, -1)
return SECURE_PROTOCOLS.has(protocol)
}

const getProxyType = (url) => {
url = urlify(url)
Expand Down Expand Up @@ -91,6 +84,5 @@ const getProxy = (url, {
module.exports = {
getProxyType,
getProxy,
isSecureProxy,
proxyCache: PROXY_CACHE,
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"16.x",
"18.0.0",
"18.x"
]
],
"npmSpec": "next-9"
},
"dependencies": {
"http-proxy-agent": "^7.0.0",
Expand Down