termites 1.0.2 → 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/bin/termites.js +11 -2
- package/client.js +4 -0
- package/package.json +1 -1
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}`);
|