mdslab / wstun Goto Github PK
View Code? Open in Web Editor NEWThis project forked from mhzed/wstunnel
Tunnels and reverse tunnels over WebSocket
License: Apache License 2.0
This project forked from mhzed/wstunnel
Tunnels and reverse tunnels over WebSocket
License: Apache License 2.0
I already have a WS application server with quite some functionality, is there a way I could use the same server for wstun?
Client is giving the Server access to a HTTP Proxy so that the Server can Send HTTP(s) Requests using the Client's IP Address.
After a while of running this is the output, ignore the fact that my IP is in there, it has cycled since these logs.
root@ChromiumVNC-Base:~/ClientTunnel/node_modules/node-reverse-wstunnel/bin# ./wstt.js -r -s 12345
Thu Jun 02 2016 19:58:49 GMT+0000 (UTC) Server is listening on port 12345
Created TCP server on port 12121
WS Connectio for Control Created
Request for Data WS Socket
Request for Data WS Socket
Thu Jun 02 2016 20:01:41 GMT+0000 (UTC)TCP connection Close
Thu Jun 02 2016 20:01:41 GMT+0000 (UTC)TCP connection Close
Thu Jun 02 2016 20:01:41 GMT+0000 (UTC)WebSocket Peer ::ffff:79.66.225.8 disconnected for:"Normal connection closure"
Thu Jun 02 2016 20:01:41 GMT+0000 (UTC)WebSocket Peer ::ffff:79.66.225.8 disconnected for:"Normal connection closure"
(node:2893) Warning: Possible EventEmitter memory leak detected. 11 created listeners added. Use emitter.setMaxListeners() to increase limit
Request for Data WS Socket
Request for Data WS Socket
Request for Data WS Socket
Request for Data WS Socket
Request for Data WS Socket
Request for Data WS Socket
Request for Data WS Socket
Request for Data WS Socket
Request for Data WS Socket
Request for Data WS Socket
Request for Data WS Socket
Request for Data WS Socket
Request for Data WS Socket
Request for Data WS Socket
Request for Data WS Socket
Request for Data WS Socket
Request for Data WS Socket
Request for Data WS Socket
Request for Data WS Socket
Request for Data WS Socket
Request for Data WS Socket
Request for Data WS Socket
Request for Data WS Socket
Request for Data WS Socket
Request for Data WS Socket
Thu Jun 02 2016 20:03:02 GMT+0000 (UTC)TCP connection Close
Thu Jun 02 2016 20:03:02 GMT+0000 (UTC)TCP connection Close
Thu Jun 02 2016 20:03:02 GMT+0000 (UTC)TCP connection Close
Thu Jun 02 2016 20:03:02 GMT+0000 (UTC)TCP connection Close
Thu Jun 02 2016 20:03:02 GMT+0000 (UTC)TCP connection Close
Thu Jun 02 2016 20:03:02 GMT+0000 (UTC)TCP connection Close
Thu Jun 02 2016 20:03:02 GMT+0000 (UTC)TCP connection Close
Thu Jun 02 2016 20:03:02 GMT+0000 (UTC)TCP connection Close
Thu Jun 02 2016 20:03:02 GMT+0000 (UTC)TCP connection Close
Thu Jun 02 2016 20:03:02 GMT+0000 (UTC)TCP connection Close
Thu Jun 02 2016 20:03:02 GMT+0000 (UTC)WebSocket Peer ::ffff:79.66.225.8 disconnected for:"Normal connection closure"
Thu Jun 02 2016 20:03:02 GMT+0000 (UTC)WebSocket Peer ::ffff:79.66.225.8 disconnected for:"Normal connection closure"
Thu Jun 02 2016 20:03:02 GMT+0000 (UTC)WebSocket Peer ::ffff:79.66.225.8 disconnected for:"Normal connection closure"
Thu Jun 02 2016 20:03:02 GMT+0000 (UTC)WebSocket Peer ::ffff:79.66.225.8 disconnected for:"Normal connection closure"
Thu Jun 02 2016 20:03:02 GMT+0000 (UTC)WebSocket Peer ::ffff:79.66.225.8 disconnected for:"Normal connection closure"
Thu Jun 02 2016 20:03:02 GMT+0000 (UTC)WebSocket Peer ::ffff:79.66.225.8 disconnected for:"Normal connection closure"
Thu Jun 02 2016 20:03:02 GMT+0000 (UTC)WebSocket Peer ::ffff:79.66.225.8 disconnected for:"Normal connection closure"
Thu Jun 02 2016 20:03:02 GMT+0000 (UTC)WebSocket Peer ::ffff:79.66.225.8 disconnected for:"Normal connection closure"
Thu Jun 02 2016 20:03:02 GMT+0000 (UTC)WebSocket Peer ::ffff:79.66.225.8 disconnected for:"Normal connection closure"
Thu Jun 02 2016 20:03:02 GMT+0000 (UTC)WebSocket Peer ::ffff:79.66.225.8 disconnected for:"Normal connection closure"
Thu Jun 02 2016 20:03:32 GMT+0000 (UTC)tcp Error Error: read ECONNRESET
Thu Jun 02 2016 20:03:32 GMT+0000 (UTC)TCP connection Close
Thu Jun 02 2016 20:03:32 GMT+0000 (UTC)tcp Error Error: read ECONNRESET
Thu Jun 02 2016 20:03:32 GMT+0000 (UTC)tcp Error Error: read ECONNRESET
Thu Jun 02 2016 20:03:32 GMT+0000 (UTC)tcp Error Error: read ECONNRESET
Thu Jun 02 2016 20:03:32 GMT+0000 (UTC)tcp Error Error: read ECONNRESET
Thu Jun 02 2016 20:03:32 GMT+0000 (UTC)tcp Error Error: read ECONNRESET
Thu Jun 02 2016 20:03:32 GMT+0000 (UTC)TCP connection Close
Thu Jun 02 2016 20:03:32 GMT+0000 (UTC)TCP connection Close
Thu Jun 02 2016 20:03:32 GMT+0000 (UTC)TCP connection Close
Thu Jun 02 2016 20:03:32 GMT+0000 (UTC)TCP connection Close
Thu Jun 02 2016 20:03:32 GMT+0000 (UTC)TCP connection Close
Thu Jun 02 2016 20:03:32 GMT+0000 (UTC)WebSocket Peer ::ffff:79.66.225.8 disconnected for:"Normal connection closure"
Thu Jun 02 2016 20:03:32 GMT+0000 (UTC)WebSocket Peer ::ffff:79.66.225.8 disconnected for:"Normal connection closure"
Thu Jun 02 2016 20:03:32 GMT+0000 (UTC)WebSocket Peer ::ffff:79.66.225.8 disconnected for:"Normal connection closure"
Thu Jun 02 2016 20:03:32 GMT+0000 (UTC)WebSocket Peer ::ffff:79.66.225.8 disconnected for:"Normal connection closure"
Thu Jun 02 2016 20:03:32 GMT+0000 (UTC)WebSocket Peer ::ffff:79.66.225.8 disconnected for:"Normal connection closure"
Thu Jun 02 2016 20:03:32 GMT+0000 (UTC)WebSocket Peer ::ffff:79.66.225.8 disconnected for:"Normal connection closure"
Request for Data WS Socket
/root/ClientTunnel/node_modules/websocket/lib/WebSocketRequest.js:509
throw new Error('WebSocketRequest may only be accepted or rejected one time.');
^
Error: WebSocketRequest may only be accepted or rejected one time.
at WebSocketRequest._verifyResolution (/root/ClientTunnel/node_modules/websocket/lib/WebSocketRequest.js:509:15)
at WebSocketRequest.accept (/root/ClientTunnel/node_modules/websocket/lib/WebSocketRequest.js:250:10)
at EventEmitter.<anonymous> (/root/ClientTunnel/node_modules/node-reverse-wstunnel/lib/wst_server_reverse.js:111:46)
at emitOne (events.js:101:20)
at EventEmitter.emit (events.js:188:7)
at WebSocketServer.<anonymous> (/root/ClientTunnel/node_modules/node-reverse-wstunnel/lib/wst_server_reverse.js:84:23)
at emitOne (events.js:96:13)
at WebSocketServer.emit (events.js:188:7)
at WebSocketServer.handleUpgrade (/root/ClientTunnel/node_modules/websocket/lib/WebSocketServer.js:213:14)
at emitThree (events.js:116:13)
Any insight is appreciated.
Thanks
Manage the TCP connections with unique ID, this ID is used in server an in client to solve the problem
$ ./wstt.js -s 2222
Thu Aug 06 2015 14:41:27 GMT+0000 (UTC) Server is listening on port 2222
# lsof -ni|grep node
node 5857 wstunnel 10u IPv4 25660001 0t0 TCP *:2222 (LISTEN)
[...]
$ ./wstt.js -s 127.0.0.1:2222
Thu Aug 06 2015 14:40:43 GMT+0000 (UTC) Server is listening on port 127.0.0.1:2222
# lsof -ni|grep node
#
It also creates the -s target as a socket in .
:
srwxrwxr-x 1 wstunnel wstunnel 0 Aug 6 14:40 127.0.0.1:2222
It doesn't seem to create the socket when just the port is specified.
If it's listening to external traffic then most of the purpose of putting it behind an HTTPS proxy is defeated.
Nov 15 07:00:34 earth wstun[30783]: [2018-11-15 07:00:34.651] [INFO] wstun - [SYSTEM] --> WebSocket Request for Data
Nov 15 07:00:34 earth wstun[30783]: [2018-11-15 07:00:34.672] [INFO] wstun - [SYSTEM] --> WebSocket Request for Data
Nov 15 07:00:38 earth wstun[30783]: events.js:183
Nov 15 07:00:38 earth wstun[30783]: throw er; // Unhandled 'error' event
Nov 15 07:00:38 earth wstun[30783]: ^
Nov 15 07:00:38 earth wstun[30783]: Error: read ECONNRESET
Nov 15 07:00:38 earth wstun[30783]: at TCP.onread (net.js:622:25)
Nov 15 07:00:38 earth systemd[1]: wstun.service: Main process exited, code=exited, status=1/FAILURE
Nov 15 07:00:38 earth systemd[1]: wstun.service: Unit entered failed state.
Nov 15 07:00:38 earth systemd[1]: wstun.service: Failed with result 'exit-code'.
Your script is awesome, please add these important features:
Thanks
I have built something similar before with socket.io but this seems way better then what i built.
I have currently 3 servers (slaves) that are connected to one master that handels all request and distributes them over to all slaves throught socket.io
Can something similar be done with this package?
Hello,
Using crome browser
When going to http://localhost:3333
I was expecting to get website hosted at http://10.216.5.47:8000
Instead server crashed:
CLIENT
[winMachine]$ node wstt.js -t 3333 ws://10.216.5.47:8888
Connection detected
SERVER
[root@partedmagic bin]$ ./wstt.js -s 8888 -t 127.0.0.1:8000
Tue Dec 13 2016 14:08:27 GMT+0100 (CET) Server is listening on port 8888
/home/user/node_modules/node-reverse-wstunnel/lib/wst_server.js:78
return this._reject(request, "Tunnel connect error to " + remoteAddr + ": " + err);
^
TypeError: this._reject is not a function
at Socket. (/home/user/node_modules/node-reverse-wstunnel/lib/wst_server.js:78:25)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at emitErrorNT (net.js:1276:8)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
[root@partedmagic bin]$ ./wstt.js -s 8888 -t 127.0.0.1:8000
Tue Dec 13 2016 14:09:20 GMT+0100 (CET) Server is listening on port 8888
/home/user/node_modules/node-reverse-wstunnel/lib/wst_server.js:78
return this._reject(request, "Tunnel connect error to " + remoteAddr + ": " + err);
Is there any way that this can be enhanced to allow for the path in the websocket instead of just the root?
I see today I can specify the port only and the web request goest to ws(s)://hostname:port/?dst=xxxx
but I would like to see a path option available so I can put it through additional proxies along the way
so it could look like .ws(s)://hostname:port/additionalpath/?dst=xxxx
thank you
Is this possible to use on Heroku? Could you provide a simple server & client example to do so?
./scripts/postinst
npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the @mdslab/[email protected] postinstall script. npm ERR! This is probably not a problem with npm. There is likely additional log ging output above. npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\ideeps\AppData\Roaming\npm-cache_logs\2020-03-08T04_51_14 _066Z-debug.logIs it possible to set the https_proxy from the client side of the reverse tunnel.
something similar to what wstunnel support
wstunnel -r port -p https://proxy_host:proxy_port wss://...
i didn't see this option (-p) available in reverse tunnel. Any suggestion how to achieve this ?
something inline with allowing reverse wstunnel to use HTTP_CONNECT to work across proxy.
Hi, I am not sure I use this module correctly.
I installed it by npm then try to create new server in my JS application. But I got "log4js is not defined error". Did I miss something?
To fix it, I manually add var log4js = require('log4js');
to the source code.
Modify the reverse wstunnel server to be able to management more than one reverse wstunnel client.
Looks like the reverse proxy mode can be used to expose a local server behind NAT to be exposed to internet
Eg. a server running on wsclient can be exposed to internet using reverse proxy.
Examples about how to run a reverse tunnel client:
//without security
./wstun.js -r6666:2.2.2.2:33 ws://server:8080
//with security
./wstun.js -r6666:2.2.2.2:33 wss://server:8080
In the above examples, the client asks the server to open a TCP server on port 6666 and all connections on this port are tunneled to the client that is directely connected to 2.2.2.2:33.
In above example, i am not clear, what is tunneled to the client that is directely connected to 2.2.2.2:33
What is 2.2.2.2 ? I want to expose a server on 127.0.0.1:LOCALPORT
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.