Created
August 16, 2013 21:15
-
-
Save TooTallNate/6253581 to your computer and use it in GitHub Desktop.
Establishing a WebSocket connection to "ws://echo.websocket.org" over a Tor SOCKS proxy.
Currently depends on pull request: https://github.com/einaros/ws/pull/220
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var WebSocket = require('ws'); | |
var SocksProxyAgent = require('socks-proxy-agent'); | |
var url = process.argv[2] || 'ws://echo.websocket.org'; | |
var agent = new SocksProxyAgent('socks://127.0.0.1:9050'); | |
var opts = {}; | |
opts.agent = agent; | |
var socket = new WebSocket(url, opts); | |
socket.on('open', function () { | |
console.log('"open" event!'); | |
socket.send('something'); | |
}); | |
var i = 0; | |
socket.on('message', function (data, flags) { | |
console.log('got data!: %j', data); | |
socket.send('something ' + (i++)); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
i use 9150 port, chrome could use '127.0.0.1:9150' as socks5 proxy and access web and deep web through TOR.
i am searching the solution which could make tor a websocket proxy server, i find this project, i added code into this js file:
socket.on('error', function (evt) {
console.log('%s', evt);
});
Then i run this js file by "node websocket-over-tor.js", but the cmd prints nothing. Then i tried 9050, the log is "Error: Socket Closed".