Skip to content

Instantly share code, notes, and snippets.

@jashkenas
Forked from tim-smart/cheeky_async.js
Created June 28, 2010 03:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jashkenas/455396 to your computer and use it in GitHub Desktop.
Save jashkenas/455396 to your computer and use it in GitHub Desktop.
# sample use: node nodeproxy.js 127.0.0.1 88 127.0.0.1 80
net: require 'net'
sys: require 'sys'
[proxyHost, proxyPort, proxyTargetHost, proxyTargetPort]: process.argv.slice(2)
proxyServer: net.createServer (source_stream) ->
source_stream.addListener 'connect', ->
target_stream: new net.Stream()
target_stream.addListener 'connect', -> sys.pump source_stream, target_stream
target_stream.connect new Number(proxyTargetPort), proxyTargetHost
proxyServer.listen new Number(proxyPort), proxyHost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment