Browse Source

Remove --sshuser option and allow a user to specify it in the URL: http://yourserver:port/wetty/ssh/<username>

pull/3/head
Krishna Srinivas 11 years ago
parent
commit
2567a212db
  1. 6
      README.md
  2. 19
      app.js
  3. 2
      package.json
  4. 6
      public/wetty/index.html
  5. 2
      public/wetty/wetty.js

6
README.md

@ -20,7 +20,9 @@ Run on http:
-----------
`node app.js -p 3000`
If you run it as root it will launch /bin/login (where you can specify the username), else it will launch ssh to localhost with the node process' user as the ssh login username.
If you run it as root it will launch /bin/login (where you can specify the username), else it will launch ssh to localhost and you can specify the sshport using --sshport option and specify username in address bar like this:
`https://yourserver:3000/wetty/ssh/<username>`
Run on https:
------------
@ -51,7 +53,7 @@ Put the following config in nginx's conf:
proxy_set_header X-NginX-Proxy true;
}
In the browser you have to use: 'http://yourserver.com/wetty'. Note that if your nginx is configured for https you should run wetty without ssl.
In the browser you have to use: 'http://yourserver.com/wetty' if you are running as root else 'http://yourserver.com/wetty/ssh/<username>'. Note that if your nginx is configured for https you should run wetty without ssl.
Issues
------

19
app.js

@ -21,10 +21,6 @@ var opts = require('optimist')
demand: false,
description: 'ssh server port'
},
sshuser: {
demand: false,
description: 'ssh user'
},
port: {
demand: true,
alias: 'p',
@ -34,16 +30,11 @@ var opts = require('optimist')
var runhttps = false;
var sshport = 22;
var sshuser = '';
if (opts.sshport) {
sshport = opts.sshport;
}
if (opts.sshuser) {
sshuser = opts.sshuser + '@';
}
if (opts.sslkey && opts.sslcert) {
runhttps = true;
opts['ssl'] = {};
@ -59,6 +50,9 @@ process.on('uncaughtException', function(e) {
var httpserv;
var app = express();
app.get('/wetty/ssh/:user', function(req, res) {
res.sendfile(__dirname + '/public/wetty/index.html');
});
app.use('/', express.static(path.join(__dirname, 'public')));
if (runhttps) {
@ -77,8 +71,15 @@ var wss = new ws({
wss.on('request', function(request) {
var term;
var sshuser = '';
var conn = request.accept('wetty', request.origin);
console.log((new Date()) + ' Connection accepted.');
if (request.resource.match('^/wetty/ssh/')) {
sshuser = request.resource;
sshuser = sshuser.replace('/wetty/ssh/', '');
}
if (sshuser)
sshuser = sshuser + '@';
conn.on('message', function(msg) {
var data = JSON.parse(msg.utf8Data);
if (!term) {

2
package.json

@ -1,6 +1,6 @@
{
"name": "wetty",
"version": "0.0.7",
"version": "0.0.8",
"dependencies": {
"express": "3.5.1",
"websocket": "",

6
public/wetty/index.html

@ -4,9 +4,9 @@
<head>
<meta charset="UTF-8">
<title>wtf</title>
<script src="hterm_all.js"></script>
<script src="hterm.js"></script>
<script src="wetty.js"></script>
<script src="/wetty/hterm_all.js"></script>
<script src="/wetty/hterm.js"></script>
<script src="/wetty/wetty.js"></script>
<style>
html,
body {

2
public/wetty/wetty.js

@ -30,7 +30,7 @@ Wetty.prototype.onTerminalResize = function(col, row) {
}));
};
ws = new WebSocket(((window.location.protocol === 'https:') ? 'wss://' : 'ws://') + window.location.host + '/wetty', 'wetty');
ws = new WebSocket(((window.location.protocol === 'https:') ? 'wss://' : 'ws://') + window.location.host + window.location.pathname, 'wetty');
ws.onopen = function() {
lib.init(function() {
term = new hterm.Terminal();

Loading…
Cancel
Save