Browse Source

preserve lts support

pull/126/head
butlerx 8 years ago
parent
commit
a9f1a16c4c
No known key found for this signature in database GPG Key ID: B37CA765BAA89170
  1. 48
      app.js

48
app.js

@ -7,37 +7,37 @@ const optimist = require('optimist');
const opts = optimist const opts = optimist
.options({ .options({
sslkey: { sslkey: {
demand: false, demand : false,
description: 'path to SSL key', description: 'path to SSL key',
}, },
sslcert: { sslcert: {
demand: false, demand : false,
description: 'path to SSL certificate', description: 'path to SSL certificate',
}, },
sshhost: { sshhost: {
demand: false, demand : false,
description: 'ssh server host', description: 'ssh server host',
}, },
sshport: { sshport: {
demand: false, demand : false,
description: 'ssh server port', description: 'ssh server port',
}, },
sshuser: { sshuser: {
demand: false, demand : false,
description: 'ssh user', description: 'ssh user',
}, },
sshauth: { sshauth: {
demand: false, demand : false,
description: 'defaults to "password", you can use "publickey,password" instead', description: 'defaults to "password", you can use "publickey,password" instead',
}, },
port: { port: {
demand: false, demand : false,
alias: 'p', alias : 'p',
description: 'wetty listen port', description: 'wetty listen port',
}, },
help: { help: {
demand: false, demand : false,
alias: 'h', alias : 'h',
description: 'Print help message', description: 'Print help message',
}, },
}) })
@ -70,16 +70,22 @@ tty.on('disconnect', () => {
console.log('disconnect'); console.log('disconnect');
}); });
async function loadSSL({ sslkey, sslcert }) { function loadSSL({ sslkey, sslcert }) {
try { return new Promise((resolve, reject) => {
return sslkey && sslcert if (sslkey && sslcert) {
? { const ssl = {};
key: await fs.readFile(path.resolve(sslkey)), fs
cert: await fs.readFile(path.resolve(sslcert)), .readFile(path.resolve(sslkey))
} .then(key => {
: {}; ssl.key = key;
} catch (err) { })
console.err(err); .then(fs.readFile(path.resolve(sslcert)))
process.exit(1); .then(cert => {
ssl.cert = cert;
})
.then(resolve(ssl))
.catch(reject);
} }
resolve({});
});
} }

Loading…
Cancel
Save