-
Notifications
You must be signed in to change notification settings - Fork 25
/
ssh-connect
executable file
·44 lines (33 loc) · 1.13 KB
/
ssh-connect
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env node
var net = require('net');
var socks = require('node-socks/socks.js');
var http = require('http');
var request = require('request');
var b64 = require('./lib/base64stream');
var tunnel = require('./lib/request_tunnel');
var tunnel_address, tunnel_port;
if (!process.argv[2]) {
console.log('Usage: ./ssh-connect TUNNEL_ADDRESS TARGET_ADDRESS TARGET_PORT [MODE] # TUNNEL ADDRESS is the address of the tunnelling server. pass development as MODE for port 3001 ');
return 0;
} else {
tunnel_address = process.argv[2]
}
if (process.argv[5] == 'development') {
tunnel_port = 3001;
} else {
tunnel_port = 80;
}
var target_params = {host: process.argv[3], port: process.argv[4]};
var client = tunnel.createPersistentClient(tunnel_address, tunnel_port, function() {
process.stdin.resume(); // ?
// Make a connection through the tunnel
client.TCPConnection(target_params, function(conn) {
// Now pipe the data
process.stdin.pipe(conn).pipe(process.stdout);
conn.on('end', function() {
// client.destroy();
// process.exit(0);
});
});
});
// vim: set filetype=javascript syntax=javascript :