Skip to content

Commit

Permalink
[misc] test proxy suspending remote correction
Browse files Browse the repository at this point in the history
  • Loading branch information
rusher committed Jun 27, 2022
1 parent e6a1a00 commit f5c156f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions test/tools/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,13 @@ function Proxy(args) {
host: REMOTE_ADDR,
port: REMOTE_PORT
});
remoteSockets.push(to);
if (stopRemote) to.pause();
from.pipe(to);
to.pipe(from);

to.on('connect', () => {
if (stopRemote) to.pause();
});
to.on('end', function () {
if (log) console.log('<< remote end (' + ended + ')');
if (!ended) from.end();
Expand Down Expand Up @@ -107,17 +111,13 @@ function Proxy(args) {

server.on('suspendRemote', () => {
if (log) console.log('suspend proxy server');
remoteSockets.forEach((socket) => {
if (socket) socket.pause();
});
remoteSockets.forEach((socket) => socket.pause());
stopRemote = true;
});

server.on('resumeRemote', () => {
if (log) console.log('resume proxy server');
remoteSockets.forEach((socket) => {
if (socket) socket.resume();
});
remoteSockets.forEach((socket) => socket.resume());
stopRemote = false;
});

Expand Down

0 comments on commit f5c156f

Please sign in to comment.