File tree Expand file tree Collapse file tree 2 files changed +17
-3
lines changed
packages/devtools-proxy-support/src Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -145,10 +145,20 @@ export function createAgent(
145
145
146
146
export function useOrCreateAgent (
147
147
proxyOptions : DevtoolsProxyOptions | AgentWithInitialize ,
148
- target ?: string
148
+ target ?: string ,
149
+ useTargetRegardlessOfExistingAgent = false
149
150
) : AgentWithInitialize | undefined {
150
151
if ( 'createConnection' in proxyOptions ) {
151
- return proxyOptions as AgentWithInitialize ;
152
+ const agent = proxyOptions as AgentWithInitialize ;
153
+ if (
154
+ useTargetRegardlessOfExistingAgent &&
155
+ target !== undefined &&
156
+ agent . proxyOptions &&
157
+ ! proxyForUrl ( agent . proxyOptions , target )
158
+ ) {
159
+ return undefined ;
160
+ }
161
+ return agent ;
152
162
} else {
153
163
if (
154
164
target !== undefined &&
Original file line number Diff line number Diff line change @@ -331,9 +331,13 @@ class Socks5Server extends EventEmitter implements Tunnel {
331
331
socket . on ( 'error' , forwardingErrorHandler ) ;
332
332
333
333
socket . once ( 'close' , ( ) => {
334
+ if ( ! channel ?. destroyed ) channel . destroy ( ) ;
334
335
this . logger . emit ( 'socks5:forwarded-socket-closed' , { ...logMetadata } ) ;
335
336
this . connections . delete ( socket as Socket ) ;
336
337
} ) ;
338
+ channel . once ( 'close' , ( ) => {
339
+ if ( ! socket ?. destroyed ) socket ?. destroy ( ) ;
340
+ } ) ;
337
341
338
342
socket . pipe ( channel ) . pipe ( socket ) ;
339
343
} catch ( err ) {
@@ -392,7 +396,7 @@ export function createSocks5Tunnel(
392
396
return new ExistingTunnel ( socks5OnlyProxyOptions ) ;
393
397
}
394
398
395
- const agent = useOrCreateAgent ( proxyOptions , target ) ;
399
+ const agent = useOrCreateAgent ( proxyOptions , target , true ) ;
396
400
if ( ! agent ) return undefined ;
397
401
398
402
let generateCredentials = false ;
You can’t perform that action at this time.
0 commit comments