Browse Source

update docs

pull/206/head
butlerx 5 years ago
parent
commit
651d4ff23c
No known key found for this signature in database GPG Key ID: B37CA765BAA89170
  1. 109
      docs/API.md
  2. 3
      src/server/index.ts
  3. 1
      src/server/interfaces.ts
  4. 8
      src/server/wetty.ts

109
docs/API.md

@ -1,93 +1,86 @@
<a name="module_WeTTy"></a>
## WeTTy ## WeTTy
Create WeTTY server Create WeTTY server
* [WeTTy](#module_WeTTy) - [WeTTy](#module_WeTTy)
* [~start](#module_WeTTy..start) ⇒ <code>Promise</code> - [start](#module_WeTTy..start) ⇒ `Promise`
* ["connection"](#event_connection) - [connection](#event_connection)
* ["spawn"](#event_spawn) - [spawn](#event_spawn)
* ["exit"](#event_exit) - [exit](#event_exit)
* ["disconnect"](#event_disconnect) - [disconnect](#event_disconnect)
* ["server"](#event_server) - [server](#event_server)
<a name="module_WeTTy..start"></a>
### WeTTy~start ⇒ <code>Promise</code> ### WeTTy.start ⇒ `Promise`
Starts WeTTy Server Starts WeTTy Server
**Kind**: inner property of [<code>WeTTy</code>](#module_WeTTy) **Kind**: inner property of [`WeTTy`](#module_WeTTy)
**Returns**: <code>Promise</code> - Promise resolves once server is running **Returns**: `Promise` - Promise resolves once server is running
| Param | Type | Default | Description | | Param | Type | Default | Description |
| ------------ | ------------------- | ------------------------------------- | --------------------------- | | :------------------------ | --------- | ------------- | ---------------------------------------------------------------------------------------------------------------------- |
| [ssh] | <code>Object</code> | | SSH settings | | [ssh] | `Object` | | SSH settings |
| [ssh.user] | <code>string</code> | <code>&quot;&#x27;&#x27;&quot;</code> | default user for ssh | | [ssh.user] | `string` | `"''"` | default user for ssh |
| [ssh.host] | <code>string</code> | <code>&quot;localhost&quot;</code> | machine to ssh too | | [ssh.host] | `string` | `"localhost"` | machine to ssh too |
| [ssh.auth] | <code>string</code> | <code>&quot;password&quot;</code> | authtype to use | | [ssh.auth] | `string` | `"password"` | authtype to use |
| [ssh.port] | <code>number</code> | <code>22</code> | port to connect to over ssh | | [ssh.port] | `number` | `22` | port to connect to over ssh |
| [serverPort] | <code>number</code> | <code>3000</code> | Port to run server on | | [serverConf] | `Object` | | Server settings |
| [ssl] | <code>Object</code> | | SSL settings | | [serverConf.base] | `Object` | `'/wetty/'` | Server settings |
| [ssl.key] | <code>string</code> | | Path to ssl key | | [serverConf.port] | `number` | `3000` | Port to run server on |
| [ssl.cert] | <code>string</code> | | Path to ssl cert | | [serverConf.host] | `string` | `'0.0.0.0'` | Host address for server |
| [serverConf.title] | `string` | `'WeTTy'` | Title of the server |
<a name="event_connection"></a> | [serverConf.bypasshelmet] | `boolean` | `false` | if helmet should be disabled on the sever |
| [command] | `string` | `"''"` | The command to execute. If running as root and no host specified this will be login if a host is specified will be ssh |
| [ssl] | `Object` | | SSL settings |
| [ssl.key] | `string` | | Path to ssl key |
| [ssl.cert] | `string` | | Path to ssl cert |
### "connection" ### "connection"
**Kind**: event emitted by [<code>WeTTy</code>](#module_WeTTy) **Kind**: event emitted by [`WeTTy`](#module_WeTTy)
**Properties** **Properties**
| Name | Type | Description | | Name | Type | Description |
| ---- | ------------------- | --------------------------- | | ---- | -------- | --------------------------- |
| msg | <code>string</code> | Message for logs | | msg | `string` | Message for logs |
| date | <code>Date</code> | date and time of connection | | date | `Date` | date and time of connection |
<a name="event_spawn"></a>
### "spawn" ### "spawn"
Terminal process spawned Terminal process spawned
**Kind**: event emitted by [<code>WeTTy</code>](#module_WeTTy) **Kind**: event emitted by [`WeTTy`](#module_WeTTy)
**Properties** **Properties**
| Name | Type | Description | | Name | Type | Description |
| ------- | ------------------- | -------------------------------------- | | ------- | -------- | -------------------------------------- |
| msg | <code>string</code> | Message containing pid info and status | | msg | `string` | Message containing pid info and status |
| pid | <code>number</code> | Pid of the terminal | | pid | `number` | Pid of the terminal |
| address | <code>string</code> | address of connecting user | | address | `string` | address of connecting user |
<a name="event_exit"></a>
### "exit" ### "exit"
Terminal process exits Terminal process exits
**Kind**: event emitted by [<code>WeTTy</code>](#module_WeTTy) **Kind**: event emitted by [`WeTTy`](#module_WeTTy)
**Properties** **Properties**
| Name | Type | Description | | Name | Type | Description |
| ---- | ------------------- | -------------------------------------- | | ---- | -------- | -------------------------------------- |
| code | <code>number</code> | the exit code | | code | `number` | the exit code |
| msg | <code>string</code> | Message containing pid info and status | | msg | `string` | Message containing pid info and status |
<a name="event_disconnect"></a>
### "disconnect" ### "disconnect"
**Kind**: event emitted by [<code>WeTTy</code>](#module_WeTTy) **Kind**: event emitted by [`WeTTy`](#module_WeTTy)
<a name="event_server"></a>
### "server" ### "server"
**Kind**: event emitted by [<code>WeTTy</code>](#module_WeTTy) **Kind**: event emitted by [`WeTTy`](#module_WeTTy)
**Properties** **Properties**
| Name | Type | Description | | Name | Type | Description |
| ---------- | ------------------- | ------------------------------- | | ---------- | -------- | ------------------------------- |
| msg | <code>string</code> | Message for logging | | msg | `string` | Message for logging |
| port | <code>number</code> | port sever is on | | port | `number` | port sever is on |
| connection | <code>string</code> | connection type for web traffic | | connection | `string` | connection type for web traffic |

3
src/server/index.ts

@ -58,11 +58,10 @@ export default class Server {
host: sshhost, host: sshhost,
auth: sshauth, auth: sshauth,
port: sshport, port: sshport,
title,
pass: sshpass, pass: sshpass,
key: sshkey, key: sshkey,
}, },
{ base, host, port, title, bypasshelmet }, { base, host, port, title, bypasshelmet},
command, command,
{ key: sslkey, cert: sslcert } { key: sslkey, cert: sslcert }
); );

1
src/server/interfaces.ts

@ -20,6 +20,7 @@ export interface SSLBuffer {
export interface Server { export interface Server {
port: number; port: number;
host: string; host: string;
title: string;
base: string; base: string;
bypasshelmet: boolean; bypasshelmet: boolean;
} }

8
src/server/wetty.ts

@ -16,7 +16,13 @@ export default class WeTTy extends EventEmitter {
*/ */
public start( public start(
ssh: SSH = { user: '', host: 'localhost', auth: 'password', port: 22 }, ssh: SSH = { user: '', host: 'localhost', auth: 'password', port: 22 },
serverConf: Server = { base: '/wetty/', port: 3000, host: '0.0.0.0' }, serverConf: Server = {
base: '/wetty/',
port: 3000,
host: '0.0.0.0',
title: 'WeTTy',
bypasshelmet: false,
},
command = '', command = '',
ssl?: SSL ssl?: SSL
): Promise<void> { ): Promise<void> {

Loading…
Cancel
Save