@openclaw/discord 2026.6.33 → 2026.6.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/action-runtime-api.js +1 -1
- package/dist/{api-CjnGBhM3.js → api-1GXlSrYP.js} +42 -21
- package/dist/api.js +14 -14
- package/dist/{approval-handler.runtime-BWPQrzpP.js → approval-handler.runtime-Dv4p7REU.js} +3 -3
- package/dist/{audit-BwJ_2OjL.js → audit-DEVi9nIs.js} +3 -3
- package/dist/{channel-Ddnonoy4.js → channel-CQIRiosn.js} +15 -15
- package/dist/{channel-actions-CwmIqnYN.js → channel-actions-JziPEcBU.js} +2 -2
- package/dist/{channel-actions.runtime-DvpTfaJ4.js → channel-actions.runtime-D7L47LY3.js} +5 -5
- package/dist/channel-plugin-api.js +1 -1
- package/dist/{channel.setup-glZ5Y98a.js → channel.setup-oMeR19Cc.js} +2 -2
- package/dist/{components-j6lTZBsT.js → components-_s5UPJqU.js} +1 -1
- package/dist/{conversation-identity-36FFBwm5.js → conversation-identity-B0k94-bz.js} +2 -2
- package/dist/{directory-config-BYMFzL29.js → directory-config-CD1svkyN.js} +1 -1
- package/dist/directory-contract-api.js +1 -1
- package/dist/{directory-live-9JtJCiu8.js → directory-live-DBTsSRxl.js} +5 -5
- package/dist/{handle-action.guild-admin-xxGYrp-I.js → handle-action.guild-admin-CYIFMxh-.js} +2 -2
- package/dist/index.js +1 -1
- package/dist/{manager.runtime-BK6cf2Zu.js → manager.runtime-BZVdGX2d.js} +17 -9
- package/dist/{message-handler-BqpJIavO.js → message-handler-DZd9Bpq8.js} +7 -6
- package/dist/{message-handler.preflight-C90MxCcv.js → message-handler.preflight-Axv9J9EO.js} +12 -11
- package/dist/{message-handler.process-CeQ7Bd_3.js → message-handler.process-CG0zFS-Z.js} +10 -10
- package/dist/{message-utils-CJeAoISH.js → message-utils-Dbuw27gd.js} +1 -1
- package/dist/{outbound-adapter-Dxs6iKEq.js → outbound-adapter-CKC_kmUN.js} +6 -6
- package/dist/pluralkit-CfTReLl3.js +40 -0
- package/dist/{probe-esE_Oqdm.js → probe-DcgZIpyF.js} +3 -2
- package/dist/{probe.runtime-C3Atgpvr.js → probe.runtime-CVwM9L5E.js} +1 -1
- package/dist/{provider-C7376XFH.js → provider-CwwSXIIj.js} +102 -37
- package/dist/{provider-session.runtime-CCdqogGf.js → provider-session.runtime-reBWkqHZ.js} +3 -3
- package/dist/provider.runtime-BsmTLYS_.js +2 -0
- package/dist/{resolve-allowlist-common-3gB2Gpmm.js → resolve-allowlist-common-D7bZqAw3.js} +3 -3
- package/dist/{resolve-channels-B3gQf8QL.js → resolve-channels--oE-RnO6.js} +6 -6
- package/dist/{resolve-users-BO10y5fJ.js → resolve-users-QXo8CXBU.js} +5 -5
- package/dist/{runtime-CFlR3L9X.js → runtime-CF7ramAs.js} +7 -7
- package/dist/runtime-api.actions.js +2 -2
- package/dist/runtime-api.js +19 -19
- package/dist/runtime-api.lookup.js +5 -5
- package/dist/runtime-api.monitor-CzF8MUl_.js +6 -0
- package/dist/runtime-api.monitor.js +5 -5
- package/dist/runtime-api.send.js +5 -5
- package/dist/runtime-api.threads.js +3 -3
- package/dist/{send-JHxfT4Pk.js → send-Bb295iHT.js} +5 -5
- package/dist/{send.components-CN35E2Ck.js → send.components-COkDUO3B.js} +4 -4
- package/dist/{send.outbound-B-cA1Esv.js → send.outbound-B_sk0hNe.js} +3 -3
- package/dist/{send.receipt-CGecJDin.js → send.receipt-Cli6_9Sn.js} +19 -7
- package/dist/{send.shared-vcbfThdy.js → send.shared-BCG7MWnP.js} +2 -2
- package/dist/session-binding-contract-api.js +1 -1
- package/dist/setup-plugin-api.js +1 -1
- package/dist/{subagent-hooks-20wXhVzZ.js → subagent-hooks-CtqoWK4x.js} +2 -2
- package/dist/subagent-hooks-api.js +1 -1
- package/dist/{system-events-DR27TE7p.js → system-events-BxGNk_wE.js} +1 -1
- package/dist/{target-resolver-CDi1gI90.js → target-resolver-BcoK6b0g.js} +2 -2
- package/dist/targets-Q-ZoP7K4.js +3 -0
- package/dist/{thread-bindings-DU4T6nDo.js → thread-bindings-DJ_HT6GJ.js} +4 -4
- package/dist/{thread-bindings.discord-api-CYkr-3Gj.js → thread-bindings.discord-api-OPyjvgyz.js} +4 -4
- package/dist/{thread-bindings.manager-BqWs1UE2.js → thread-bindings.manager-Cd2HAVw_.js} +3 -3
- package/dist/{transcripts-source-D-lBI5ZD.js → transcripts-source-CPf5gURy.js} +1 -1
- package/dist/transcripts-source-api.js +1 -1
- package/dist/{typing-xr05bL-r.js → typing-DY0cwLdg.js} +1 -1
- package/node_modules/undici/README.md +8 -2
- package/node_modules/undici/docs/docs/api/Agent.md +248 -44
- package/node_modules/undici/docs/docs/api/BalancedPool.md +246 -48
- package/node_modules/undici/docs/docs/api/CacheStorage.md +171 -13
- package/node_modules/undici/docs/docs/api/CacheStore.md +294 -98
- package/node_modules/undici/docs/docs/api/Client.md +386 -179
- package/node_modules/undici/docs/docs/api/ClientStats.md +80 -14
- package/node_modules/undici/docs/docs/api/Connector.md +118 -36
- package/node_modules/undici/docs/docs/api/ContentType.md +65 -25
- package/node_modules/undici/docs/docs/api/Cookies.md +122 -71
- package/node_modules/undici/docs/docs/api/Debug.md +34 -18
- package/node_modules/undici/docs/docs/api/DiagnosticsChannel.md +364 -164
- package/node_modules/undici/docs/docs/api/Dispatcher.md +485 -1102
- package/node_modules/undici/docs/docs/api/EnvHttpProxyAgent.md +102 -87
- package/node_modules/undici/docs/docs/api/Errors.md +503 -40
- package/node_modules/undici/docs/docs/api/EventSource.md +298 -32
- package/node_modules/undici/docs/docs/api/Fetch.md +680 -31
- package/node_modules/undici/docs/docs/api/GlobalInstallation.md +78 -98
- package/node_modules/undici/docs/docs/api/H2CClient.md +298 -176
- package/node_modules/undici/docs/docs/api/Interceptors.md +418 -0
- package/node_modules/undici/docs/docs/api/MockAgent.md +333 -314
- package/node_modules/undici/docs/docs/api/MockCallHistory.md +272 -98
- package/node_modules/undici/docs/docs/api/MockCallHistoryLog.md +189 -26
- package/node_modules/undici/docs/docs/api/MockClient.md +151 -33
- package/node_modules/undici/docs/docs/api/MockErrors.md +56 -5
- package/node_modules/undici/docs/docs/api/MockPool.md +321 -258
- package/node_modules/undici/docs/docs/api/Pool.md +235 -43
- package/node_modules/undici/docs/docs/api/PoolStats.md +119 -13
- package/node_modules/undici/docs/docs/api/ProxyAgent.md +179 -160
- package/node_modules/undici/docs/docs/api/RedirectHandler.md +238 -63
- package/node_modules/undici/docs/docs/api/RetryAgent.md +113 -26
- package/node_modules/undici/docs/docs/api/RetryHandler.md +161 -77
- package/node_modules/undici/docs/docs/api/RoundRobinPool.md +166 -72
- package/node_modules/undici/docs/docs/api/SnapshotAgent.md +264 -542
- package/node_modules/undici/docs/docs/api/Socks5ProxyAgent.md +177 -196
- package/node_modules/undici/docs/docs/api/Util.md +68 -11
- package/node_modules/undici/docs/docs/api/WebSocket.md +475 -80
- package/node_modules/undici/docs/docs/api/api-lifecycle.md +100 -32
- package/node_modules/undici/docs/docs/best-practices/client-certificate.md +2 -0
- package/node_modules/undici/docs/docs/best-practices/crawling.md +3 -1
- package/node_modules/undici/docs/docs/best-practices/migrating-from-v7-to-v8.md +6 -4
- package/node_modules/undici/docs/docs/best-practices/mocking-request.md +9 -7
- package/node_modules/undici/docs/docs/best-practices/proxy.md +3 -1
- package/node_modules/undici/docs/docs/best-practices/undici-vs-builtin-fetch.md +10 -8
- package/node_modules/undici/docs/docs/best-practices/writing-tests.md +2 -0
- package/node_modules/undici/docs/docs/{GettingStarted.md → getting-started.md} +22 -19
- package/node_modules/undici/docs/docs/index.md +784 -0
- package/node_modules/undici/docs/docs/site.json +125 -0
- package/node_modules/undici/docs/docs/type-map.json +79 -0
- package/node_modules/undici/lib/api/api-request.js +7 -1
- package/node_modules/undici/lib/api/readable.js +42 -7
- package/node_modules/undici/lib/cache/memory-cache-store.js +56 -11
- package/node_modules/undici/lib/cache/sqlite-cache-store.js +7 -1
- package/node_modules/undici/lib/core/connect.js +16 -2
- package/node_modules/undici/lib/core/errors.js +20 -0
- package/node_modules/undici/lib/core/request.js +14 -3
- package/node_modules/undici/lib/core/symbols.js +3 -0
- package/node_modules/undici/lib/core/util.js +30 -2
- package/node_modules/undici/lib/dispatcher/agent.js +10 -5
- package/node_modules/undici/lib/dispatcher/balanced-pool.js +7 -4
- package/node_modules/undici/lib/dispatcher/client-h1.js +74 -9
- package/node_modules/undici/lib/dispatcher/client-h2.js +483 -151
- package/node_modules/undici/lib/dispatcher/client.js +76 -30
- package/node_modules/undici/lib/dispatcher/dispatcher-base.js +13 -1
- package/node_modules/undici/lib/dispatcher/dispatcher.js +15 -1
- package/node_modules/undici/lib/dispatcher/dispatcher1-wrapper.js +3 -0
- package/node_modules/undici/lib/dispatcher/env-http-proxy-agent.js +37 -8
- package/node_modules/undici/lib/dispatcher/proxy-agent.js +58 -7
- package/node_modules/undici/lib/dispatcher/retry-agent.js +3 -0
- package/node_modules/undici/lib/dispatcher/round-robin-pool.js +1 -1
- package/node_modules/undici/lib/dispatcher/socks5-proxy-agent.js +106 -22
- package/node_modules/undici/lib/global.js +36 -16
- package/node_modules/undici/lib/handler/cache-handler.js +297 -65
- package/node_modules/undici/lib/handler/cache-revalidation-handler.js +13 -3
- package/node_modules/undici/lib/handler/decorator-handler.js +7 -1
- package/node_modules/undici/lib/handler/deduplication-handler.js +12 -6
- package/node_modules/undici/lib/handler/redirect-handler.js +26 -5
- package/node_modules/undici/lib/handler/retry-handler.js +238 -51
- package/node_modules/undici/lib/interceptor/cache.js +221 -58
- package/node_modules/undici/lib/interceptor/decompress.js +124 -15
- package/node_modules/undici/lib/interceptor/deduplicate.js +5 -4
- package/node_modules/undici/lib/interceptor/dns.js +7 -0
- package/node_modules/undici/lib/interceptor/dump.js +10 -23
- package/node_modules/undici/lib/mock/mock-agent.js +13 -1
- package/node_modules/undici/lib/mock/mock-interceptor.js +25 -7
- package/node_modules/undici/lib/mock/mock-utils.js +246 -27
- package/node_modules/undici/lib/util/cache.js +415 -71
- package/node_modules/undici/lib/util/date.js +23 -6
- package/node_modules/undici/lib/web/cookies/parse.js +150 -146
- package/node_modules/undici/lib/web/cookies/util.js +79 -9
- package/node_modules/undici/lib/web/eventsource/eventsource-stream.js +28 -1
- package/node_modules/undici/lib/web/eventsource/eventsource.js +13 -3
- package/node_modules/undici/lib/web/eventsource/util.js +1 -1
- package/node_modules/undici/lib/web/fetch/body.js +2 -1
- package/node_modules/undici/lib/web/fetch/constants.js +1 -1
- package/node_modules/undici/lib/web/fetch/index.js +17 -2
- package/node_modules/undici/lib/web/fetch/request.js +2 -3
- package/node_modules/undici/lib/web/fetch/response.js +1 -3
- package/node_modules/undici/lib/web/fetch/util.js +10 -2
- package/node_modules/undici/lib/web/webidl/index.js +3 -3
- package/node_modules/undici/lib/web/websocket/connection.js +1 -1
- package/node_modules/undici/lib/web/websocket/permessage-deflate.js +5 -0
- package/node_modules/undici/lib/web/websocket/stream/websocketstream.js +8 -10
- package/node_modules/undici/lib/web/websocket/websocket.js +22 -0
- package/node_modules/undici/package.json +4 -4
- package/node_modules/undici/types/client.d.ts +53 -3
- package/node_modules/undici/types/cookies.d.ts +1 -1
- package/node_modules/undici/types/dispatcher.d.ts +3 -3
- package/node_modules/undici/types/errors.d.ts +10 -0
- package/node_modules/undici/types/handlers.d.ts +2 -0
- package/node_modules/undici/types/interceptors.d.ts +2 -0
- package/node_modules/undici/types/mock-agent.d.ts +11 -10
- package/node_modules/undici/types/mock-interceptor.d.ts +5 -1
- package/node_modules/undici/types/proxy-agent.d.ts +7 -0
- package/node_modules/undici/types/socks5-proxy-agent.d.ts +2 -0
- package/npm-shrinkwrap.json +7 -7
- package/package.json +6 -5
- package/dist/pluralkit-DI6RYaVj.js +0 -24
- package/dist/provider.runtime-D1m66kDS.js +0 -2
- package/dist/runtime-api.monitor-4oc58TSk.js +0 -6
- package/dist/targets-C6yd3y8R.js +0 -3
|
@@ -4,22 +4,33 @@ const { URL } = require('node:url')
|
|
|
4
4
|
|
|
5
5
|
let tls // include tls conditionally since it is not always available
|
|
6
6
|
const DispatcherBase = require('./dispatcher-base')
|
|
7
|
-
const { InvalidArgumentError } = require('../core/errors')
|
|
7
|
+
const { ConnectTimeoutError, InvalidArgumentError } = require('../core/errors')
|
|
8
8
|
const { Socks5Client, STATES } = require('../core/socks5-client')
|
|
9
|
-
const { kDispatch, kClose, kDestroy } = require('../core/symbols')
|
|
9
|
+
const { kBusy, kConnected, kDispatch, kClose, kDestroy } = require('../core/symbols')
|
|
10
10
|
const Pool = require('./pool')
|
|
11
11
|
const buildConnector = require('../core/connect')
|
|
12
|
+
const { setupConnectTimeout } = require('../core/util')
|
|
12
13
|
const { debuglog } = require('node:util')
|
|
13
14
|
|
|
14
15
|
const debug = debuglog('undici:socks5-proxy')
|
|
15
16
|
|
|
17
|
+
const DEFAULT_SOCKS5_CONNECT_TIMEOUT = 5000
|
|
18
|
+
|
|
16
19
|
const kProxyUrl = Symbol('proxy url')
|
|
17
20
|
const kProxyHeaders = Symbol('proxy headers')
|
|
18
21
|
const kProxyAuth = Symbol('proxy auth')
|
|
19
22
|
const kProxyProtocol = Symbol('proxy protocol')
|
|
20
23
|
const kPools = Symbol('pools')
|
|
21
24
|
const kConnector = Symbol('connector')
|
|
25
|
+
const kConnectTimeout = Symbol('connect timeout')
|
|
22
26
|
const kRequestTls = Symbol('request tls settings')
|
|
27
|
+
const kRequestTlsTimeout = Symbol('request tls timeout')
|
|
28
|
+
|
|
29
|
+
function createConnectTimeoutError (hostname, port, timeout) {
|
|
30
|
+
return new ConnectTimeoutError(
|
|
31
|
+
`Connect Timeout Error (attempted address: ${hostname}:${port}, timeout: ${timeout}ms)`
|
|
32
|
+
)
|
|
33
|
+
}
|
|
23
34
|
|
|
24
35
|
// Static flag to ensure warning is only emitted once per process
|
|
25
36
|
let experimentalWarningEmitted = false
|
|
@@ -29,7 +40,7 @@ let experimentalWarningEmitted = false
|
|
|
29
40
|
*/
|
|
30
41
|
class Socks5ProxyAgent extends DispatcherBase {
|
|
31
42
|
constructor (proxyUrl, options = {}) {
|
|
32
|
-
super()
|
|
43
|
+
super(options)
|
|
33
44
|
|
|
34
45
|
// Emit experimental warning only once
|
|
35
46
|
if (!experimentalWarningEmitted) {
|
|
@@ -54,7 +65,20 @@ class Socks5ProxyAgent extends DispatcherBase {
|
|
|
54
65
|
this[kProxyUrl] = url
|
|
55
66
|
this[kProxyHeaders] = options.headers || {}
|
|
56
67
|
this[kProxyProtocol] = options.proxyTls ? 'https:' : 'http:'
|
|
57
|
-
|
|
68
|
+
|
|
69
|
+
const connectTimeout = options.connectTimeout ?? DEFAULT_SOCKS5_CONNECT_TIMEOUT
|
|
70
|
+
if (!Number.isFinite(connectTimeout) || connectTimeout < 0) {
|
|
71
|
+
throw new InvalidArgumentError('invalid connectTimeout')
|
|
72
|
+
}
|
|
73
|
+
this[kConnectTimeout] = connectTimeout
|
|
74
|
+
|
|
75
|
+
const { timeout, ...requestTls } = options.requestTls || {}
|
|
76
|
+
const requestTlsTimeout = timeout ?? connectTimeout
|
|
77
|
+
if (!Number.isFinite(requestTlsTimeout) || requestTlsTimeout < 0) {
|
|
78
|
+
throw new InvalidArgumentError('invalid requestTls.timeout')
|
|
79
|
+
}
|
|
80
|
+
this[kRequestTls] = requestTls
|
|
81
|
+
this[kRequestTlsTimeout] = requestTlsTimeout
|
|
58
82
|
|
|
59
83
|
// Extract auth from URL or options
|
|
60
84
|
this[kProxyAuth] = {
|
|
@@ -63,8 +87,13 @@ class Socks5ProxyAgent extends DispatcherBase {
|
|
|
63
87
|
}
|
|
64
88
|
|
|
65
89
|
// Create connector for proxy connection
|
|
90
|
+
const proxyTlsTimeout = options.proxyTls?.timeout ?? connectTimeout
|
|
91
|
+
if (!Number.isFinite(proxyTlsTimeout) || proxyTlsTimeout < 0) {
|
|
92
|
+
throw new InvalidArgumentError('invalid proxyTls.timeout')
|
|
93
|
+
}
|
|
66
94
|
this[kConnector] = options.connect || buildConnector({
|
|
67
95
|
...options.proxyTls,
|
|
96
|
+
timeout: proxyTlsTimeout,
|
|
68
97
|
servername: options.proxyTls?.servername || url.hostname
|
|
69
98
|
})
|
|
70
99
|
|
|
@@ -113,20 +142,29 @@ class Socks5ProxyAgent extends DispatcherBase {
|
|
|
113
142
|
|
|
114
143
|
// Wait for authentication (if required)
|
|
115
144
|
const authenticationReady = Promise.withResolvers()
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
145
|
+
const authenticationTimeout = this[kConnectTimeout] === 0
|
|
146
|
+
? null
|
|
147
|
+
: setTimeout(() => {
|
|
148
|
+
cleanupAuthenticationListeners()
|
|
149
|
+
socks5Client.destroy()
|
|
150
|
+
authenticationReady.reject(
|
|
151
|
+
createConnectTimeoutError(proxyHost, proxyPort, this[kConnectTimeout])
|
|
152
|
+
)
|
|
153
|
+
}, this[kConnectTimeout])
|
|
154
|
+
|
|
155
|
+
const cleanupAuthenticationListeners = () => {
|
|
122
156
|
clearTimeout(authenticationTimeout)
|
|
157
|
+
socks5Client.removeListener('authenticated', onAuthenticated)
|
|
123
158
|
socks5Client.removeListener('error', onAuthenticationError)
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const onAuthenticated = () => {
|
|
162
|
+
cleanupAuthenticationListeners()
|
|
124
163
|
authenticationReady.resolve()
|
|
125
164
|
}
|
|
126
165
|
|
|
127
166
|
const onAuthenticationError = (err) => {
|
|
128
|
-
|
|
129
|
-
socks5Client.removeListener('authenticated', onAuthenticated)
|
|
167
|
+
cleanupAuthenticationListeners()
|
|
130
168
|
authenticationReady.reject(err)
|
|
131
169
|
}
|
|
132
170
|
|
|
@@ -146,21 +184,30 @@ class Socks5ProxyAgent extends DispatcherBase {
|
|
|
146
184
|
|
|
147
185
|
// Wait for connection
|
|
148
186
|
const connectionReady = Promise.withResolvers()
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
187
|
+
const connectionTimeout = this[kConnectTimeout] === 0
|
|
188
|
+
? null
|
|
189
|
+
: setTimeout(() => {
|
|
190
|
+
cleanupConnectionListeners()
|
|
191
|
+
socks5Client.destroy()
|
|
192
|
+
connectionReady.reject(
|
|
193
|
+
createConnectTimeoutError(targetHost, targetPort, this[kConnectTimeout])
|
|
194
|
+
)
|
|
195
|
+
}, this[kConnectTimeout])
|
|
196
|
+
|
|
197
|
+
const cleanupConnectionListeners = () => {
|
|
198
|
+
clearTimeout(connectionTimeout)
|
|
199
|
+
socks5Client.removeListener('connected', onConnected)
|
|
200
|
+
socks5Client.removeListener('error', onConnectionError)
|
|
201
|
+
}
|
|
153
202
|
|
|
154
203
|
const onConnected = (info) => {
|
|
155
204
|
debug('SOCKS5 tunnel established to', targetHost, targetPort, 'via', info)
|
|
156
|
-
|
|
157
|
-
socks5Client.removeListener('error', onConnectionError)
|
|
205
|
+
cleanupConnectionListeners()
|
|
158
206
|
connectionReady.resolve()
|
|
159
207
|
}
|
|
160
208
|
|
|
161
209
|
const onConnectionError = (err) => {
|
|
162
|
-
|
|
163
|
-
socks5Client.removeListener('connected', onConnected)
|
|
210
|
+
cleanupConnectionListeners()
|
|
164
211
|
connectionReady.reject(err)
|
|
165
212
|
}
|
|
166
213
|
|
|
@@ -213,8 +260,31 @@ class Socks5ProxyAgent extends DispatcherBase {
|
|
|
213
260
|
})
|
|
214
261
|
|
|
215
262
|
const tlsReady = Promise.withResolvers()
|
|
216
|
-
|
|
217
|
-
|
|
263
|
+
|
|
264
|
+
const cleanupTlsListeners = () => {
|
|
265
|
+
queueMicrotask(clearTlsTimeout)
|
|
266
|
+
finalSocket.removeListener('secureConnect', onSecureConnect)
|
|
267
|
+
finalSocket.removeListener('error', onTlsError)
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
const onSecureConnect = () => {
|
|
271
|
+
cleanupTlsListeners()
|
|
272
|
+
tlsReady.resolve()
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
const onTlsError = (err) => {
|
|
276
|
+
cleanupTlsListeners()
|
|
277
|
+
tlsReady.reject(err)
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
const clearTlsTimeout = setupConnectTimeout(new WeakRef(finalSocket), {
|
|
281
|
+
timeout: this[kRequestTlsTimeout],
|
|
282
|
+
hostname: targetHost,
|
|
283
|
+
port: targetPort
|
|
284
|
+
})
|
|
285
|
+
|
|
286
|
+
finalSocket.once('secureConnect', onSecureConnect)
|
|
287
|
+
finalSocket.once('error', onTlsError)
|
|
218
288
|
await tlsReady.promise
|
|
219
289
|
}
|
|
220
290
|
|
|
@@ -226,6 +296,20 @@ class Socks5ProxyAgent extends DispatcherBase {
|
|
|
226
296
|
}
|
|
227
297
|
})
|
|
228
298
|
this[kPools].set(originKey, pool)
|
|
299
|
+
|
|
300
|
+
const closePoolIfUnused = () => {
|
|
301
|
+
if (this[kPools].get(originKey) !== pool || pool[kConnected] > 0 || pool[kBusy]) {
|
|
302
|
+
return
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
this[kPools].delete(originKey)
|
|
306
|
+
if (!pool.destroyed) {
|
|
307
|
+
pool.close()
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
pool.on('disconnect', closePoolIfUnused)
|
|
312
|
+
pool.on('connectionError', closePoolIfUnused)
|
|
229
313
|
}
|
|
230
314
|
|
|
231
315
|
// Dispatch the request through the per-origin pool
|
|
@@ -8,6 +8,9 @@ const { InvalidArgumentError } = require('./core/errors')
|
|
|
8
8
|
const Agent = require('./dispatcher/agent')
|
|
9
9
|
const Dispatcher1Wrapper = require('./dispatcher/dispatcher1-wrapper')
|
|
10
10
|
|
|
11
|
+
// Fallback storage for when globalThis is not extensible (e.g. frozen)
|
|
12
|
+
let fallbackDispatcher
|
|
13
|
+
|
|
11
14
|
if (getGlobalDispatcher() === undefined) {
|
|
12
15
|
setGlobalDispatcher(new Agent())
|
|
13
16
|
}
|
|
@@ -17,25 +20,42 @@ function setGlobalDispatcher (agent) {
|
|
|
17
20
|
throw new InvalidArgumentError('Argument agent must implement Agent')
|
|
18
21
|
}
|
|
19
22
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
23
|
+
try {
|
|
24
|
+
Object.defineProperty(globalThis, globalDispatcher, {
|
|
25
|
+
value: agent,
|
|
26
|
+
writable: true,
|
|
27
|
+
enumerable: false,
|
|
28
|
+
configurable: false
|
|
29
|
+
})
|
|
30
|
+
} catch (err) {
|
|
31
|
+
// globalThis is not extensible (e.g. Object.freeze(globalThis))
|
|
32
|
+
// Use fallback storage instead
|
|
33
|
+
if (err instanceof TypeError) {
|
|
34
|
+
fallbackDispatcher = agent
|
|
35
|
+
return
|
|
36
|
+
}
|
|
37
|
+
throw err
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
try {
|
|
41
|
+
const legacyAgent = agent instanceof Dispatcher1Wrapper ? agent : new Dispatcher1Wrapper(agent)
|
|
42
|
+
|
|
43
|
+
Object.defineProperty(globalThis, legacyGlobalDispatcher, {
|
|
44
|
+
value: legacyAgent,
|
|
45
|
+
writable: true,
|
|
46
|
+
enumerable: false,
|
|
47
|
+
configurable: false
|
|
48
|
+
})
|
|
49
|
+
} catch (err) {
|
|
50
|
+
// globalThis is not extensible; fallback storage is already set
|
|
51
|
+
if (!(err instanceof TypeError)) {
|
|
52
|
+
throw err
|
|
53
|
+
}
|
|
54
|
+
}
|
|
35
55
|
}
|
|
36
56
|
|
|
37
57
|
function getGlobalDispatcher () {
|
|
38
|
-
return globalThis[globalDispatcher]
|
|
58
|
+
return globalThis[globalDispatcher] ?? fallbackDispatcher
|
|
39
59
|
}
|
|
40
60
|
|
|
41
61
|
// These are the globals that can be installed by undici.install().
|