termites 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  A web-based terminal with server-client architecture for remote shell access.
4
4
 
5
+ ```bash
6
+ npm install -g termites
7
+ ```
8
+
5
9
  ## Architecture
6
10
 
7
11
  ```
@@ -22,8 +26,6 @@ A web-based terminal with server-client architecture for remote shell access.
22
26
  npm install -g termites
23
27
  ```
24
28
 
25
- > **Note**: The `-g` flag is required for the `termites` command to be available globally.
26
-
27
29
  ## Usage
28
30
 
29
31
  ### Start Server
@@ -43,12 +45,12 @@ PORT=8080 termites server
43
45
  ### Connect Client
44
46
 
45
47
  ```bash
46
- # Connect to localhost:3456
48
+ # Connect to localhost:6789
47
49
  termites client
48
50
 
49
51
  # Connect to a remote server
50
- termites client 192.168.1.100:3456
51
- termites client ws://example.com:3456
52
+ termites client 192.168.1.100:6789
53
+ termites client ws://example.com:6789
52
54
  ```
53
55
 
54
56
  ## Features
package/bin/termites.js CHANGED
@@ -19,7 +19,8 @@ Examples:
19
19
  termites server Start server on port 6789
20
20
  PORT=8080 termites server Start server on port 8080
21
21
  termites client Connect to ws://localhost:6789
22
- termites client 192.168.1.100:6789
22
+ termites client myserver Connect to ws://myserver:6789
23
+ termites client 192.168.1.100
23
24
  `);
24
25
  }
25
26
 
@@ -33,7 +34,15 @@ const rootDir = path.join(__dirname, '..');
33
34
  if (command === 'server') {
34
35
  require(path.join(rootDir, 'server.js'));
35
36
  } else if (command === 'client') {
36
- const serverUrl = args[1] || 'ws://localhost:6789';
37
+ let serverUrl = args[1] || 'ws://localhost:6789';
38
+ // Add ws:// prefix if missing
39
+ if (!serverUrl.startsWith('ws://') && !serverUrl.startsWith('wss://')) {
40
+ serverUrl = 'ws://' + serverUrl;
41
+ }
42
+ // Add default port if not specified
43
+ if (!serverUrl.match(/:\d+/)) {
44
+ serverUrl = serverUrl.replace(/^(wss?:\/\/[^\/]+)/, '$1:6789');
45
+ }
37
46
  process.argv = [process.argv[0], path.join(rootDir, 'client.js'), serverUrl];
38
47
  require(path.join(rootDir, 'client.js'));
39
48
  } else {
package/client.js CHANGED
@@ -135,6 +135,10 @@ let serverUrl = SERVER_URL;
135
135
  if (!serverUrl.startsWith('ws://') && !serverUrl.startsWith('wss://')) {
136
136
  serverUrl = 'ws://' + serverUrl;
137
137
  }
138
+ // Add default port if not specified
139
+ if (!serverUrl.match(/:\d+/) && !serverUrl.includes('localhost')) {
140
+ serverUrl = serverUrl.replace(/^(wss?:\/\/[^\/]+)/, '$1:6789');
141
+ }
138
142
 
139
143
  console.log('WebShell Client');
140
144
  console.log(`系统信息: ${getSystemInfo().username}@${getSystemInfo().hostname}`);
package/index.js CHANGED
@@ -3,7 +3,7 @@ const http = require('http');
3
3
  const os = require('os');
4
4
  const WebSocket = require('ws');
5
5
 
6
- const PORT = process.env.PORT || 3456;
6
+ const PORT = process.env.PORT || 6789;
7
7
  const SHELL = process.env.SHELL || '/bin/bash';
8
8
 
9
9
  function getSystemInfo() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "termites",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Web terminal with server-client architecture for remote shell access",
5
5
  "main": "index.js",
6
6
  "scripts": {