File tree Expand file tree Collapse file tree 1 file changed +26
-6
lines changed Expand file tree Collapse file tree 1 file changed +26
-6
lines changed Original file line number Diff line number Diff line change @@ -310,14 +310,34 @@ export class SSHService {
310
310
log . error ( "Forwarding error: " , err ) ;
311
311
return ;
312
312
}
313
+ // Track data size for el rpc
314
+ connection . on ( "data" , ( data ) => {
315
+ stream . write ( data ) ;
316
+ this . handleReceivedData ( data . length , forwardOptions . srcPort ) ;
317
+ } ) ;
313
318
314
- // Pipe the connection to the stream and vice versa
315
- connection . pipe ( stream ) . pipe ( connection ) ;
319
+ connection . on ( "end" , ( ) => {
320
+ stream . end ( ) ;
321
+ } ) ;
322
+ stream . on ( "end" , ( ) => {
323
+ connection . end ( ) ;
324
+ } ) ;
316
325
317
- // Listen for data on the stream
318
- stream . on ( "data" , ( data ) => {
319
- // Call the handleReceivedData method to handle the received data
320
- this . handleReceivedData ( data . length , forwardOptions . srcPort ) ;
326
+ connection . on ( "error" , ( error ) => {
327
+ log . error ( "Connection error: " , error ) ;
328
+ stream . end ( ) ;
329
+ } ) ;
330
+
331
+ stream . on ( "error" , ( error ) => {
332
+ log . error ( "Stream error: " , error ) ;
333
+ connection . end ( ) ;
334
+ } ) ;
335
+
336
+ connection . on ( "close" , ( ) => {
337
+ stream . destroy ( ) ;
338
+ } ) ;
339
+ stream . on ( "close" , ( ) => {
340
+ connection . destroy ( ) ;
321
341
} ) ;
322
342
}
323
343
) ;
You can’t perform that action at this time.
0 commit comments