Skip to content

Commit

Permalink
Handle socket errors
Browse files Browse the repository at this point in the history
  • Loading branch information
tjgq committed Apr 8, 2014
1 parent afa0851 commit 044611d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions bin/throttleproxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,16 @@ function runProxy(localAddr, remoteAddr, downRate, upRate) {
var remoteThrottle = new Throttle({rate: downRate});

local.pipe(localThrottle).pipe(remote);
local.on('error', function() {
remote.destroy();
local.destroy();
});

remote.pipe(remoteThrottle).pipe(local);
remote.on('error', function() {
local.destroy();
remote.destroy();
});
});

server.listen(localAddr.port, localAddr.host);
Expand Down

0 comments on commit 044611d

Please sign in to comment.