Browse Source

allow command and sshadrress to be se by url

pull/126/head
butlerx 6 years ago
parent
commit
f3593eedec
No known key found for this signature in database GPG Key ID: B37CA765BAA89170
  1. 20
      src/server/command.ts
  2. 2
      src/server/term.ts
  3. 12
      src/server/wetty.ts

20
src/server/command.ts

@ -32,11 +32,13 @@ export default (
args: localhost(host) args: localhost(host)
? loginOptions(command, remoteAddress) ? loginOptions(command, remoteAddress)
: sshOptions( : sshOptions(
address(referer, user, host), urlArgs(referer, {
port, ssh: address(referer, user, host),
auth, port: `${port}`,
pass,
command, command,
urlArgs(referer, { pass }), auth,
}),
key key
), ),
user: user:
@ -47,19 +49,15 @@ export default (
}); });
function sshOptions( function sshOptions(
sshAddress: string, { pass, path, command, ssh, port, auth }: { [s: string]: string },
port: number,
auth: string,
command: string,
{ pass, path }: { [s: string]: string },
key?: string key?: string
): string[] { ): string[] {
const sshRemoteOptsBase = [ const sshRemoteOptsBase = [
'ssh', 'ssh',
sshAddress, ssh,
'-t', '-t',
'-p', '-p',
`${port}`, port,
'-o', '-o',
`PreferredAuthentications=${auth}`, `PreferredAuthentications=${auth}`,
path !== undefined path !== undefined

2
src/server/term.ts

@ -37,7 +37,6 @@ export default class Term {
.on('disconnect', () => { .on('disconnect', () => {
const { pid } = term; const { pid } = term;
term.kill(); term.kill();
term.destroy();
events.exited(0, pid); events.exited(0, pid);
}); });
} }
@ -59,7 +58,6 @@ export default class Term {
}) })
.on('disconnect', () => { .on('disconnect', () => {
term.kill(); term.kill();
term.destroy();
reject(); reject();
}); });
}); });

12
src/server/wetty.ts

@ -42,9 +42,6 @@ export default class WeTTy extends EventEmitter {
/** /**
* @event wetty#connection * @event wetty#connection
* @name connection * @name connection
* @type {object}
* @property {string} msg Message for logs
* @property {Date} date date and time of connection
*/ */
this.emit('connection', { this.emit('connection', {
msg: `Connection accepted.`, msg: `Connection accepted.`,
@ -80,9 +77,6 @@ export default class WeTTy extends EventEmitter {
* @event WeTTy#spawn * @event WeTTy#spawn
* @name spawn * @name spawn
* @type {object} * @type {object}
* @property {string} msg Message containing pid info and status
* @property {number} pid Pid of the terminal
* @property {string} address address of connecting user
*/ */
this.emit('spawn', { this.emit('spawn', {
msg: `PID=${pid} STARTED on behalf of ${address}`, msg: `PID=${pid} STARTED on behalf of ${address}`,
@ -101,9 +95,6 @@ export default class WeTTy extends EventEmitter {
* Terminal process exits * Terminal process exits
* @event WeTTy#exit * @event WeTTy#exit
* @name exit * @name exit
* @type {object}
* @property {number} code the exit code
* @property {string} msg Message containing pid info and status
*/ */
this.emit('exit', { code, msg: `PID=${pid} ENDED` }); this.emit('exit', { code, msg: `PID=${pid} ENDED` });
} }
@ -130,9 +121,6 @@ export default class WeTTy extends EventEmitter {
* @event WeTTy#server * @event WeTTy#server
* @type {object} * @type {object}
* @name server * @name server
* @property {string} msg Message for logging
* @property {number} port port sever is on
* @property {string} connection connection type for web traffic
*/ */
this.emit('server', { this.emit('server', {
msg: `${connection} on port ${port}`, msg: `${connection} on port ${port}`,

Loading…
Cancel
Save