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 +7 -5
- package/bin/termites.js +11 -2
- package/client.js +4 -0
- package/index.js +1 -1
- package/package.json +1 -1
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:
|
|
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:
|
|
51
|
-
termites client ws://example.com:
|
|
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
|
|
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
|
-
|
|
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