iosignal-cli 3.1.1 → 3.3.0
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/io-client.js +27 -3
- package/bin/io-server.js +23 -17
- package/bin/serverInfo.js +10 -10
- package/package.json +2 -2
- package/bin/getVersion.js +0 -9
package/bin/io-client.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import { IO, IOCongSocket, ENC_MODE, serverOption } from 'iosignal'
|
|
4
3
|
import { EventEmitter } from 'events'
|
|
5
4
|
import readline from 'readline'
|
|
6
5
|
import tty from 'tty'
|
|
7
6
|
import { program } from 'commander'
|
|
8
|
-
|
|
7
|
+
|
|
8
|
+
import { IO, IOCongSocket, ENC_MODE, version as iosignal_version } from 'iosignal'
|
|
9
|
+
import pkg from '../package.json' with { type: 'json' };
|
|
10
|
+
const cli_version = pkg.version;
|
|
11
|
+
const version = `CLI ${cli_version} IOSignal ${iosignal_version}`
|
|
12
|
+
|
|
9
13
|
|
|
10
14
|
class Console extends EventEmitter {
|
|
11
15
|
constructor() {
|
|
@@ -137,6 +141,8 @@ io.listen('@', (...args) => {
|
|
|
137
141
|
console.log('rcv @', args)
|
|
138
142
|
})
|
|
139
143
|
|
|
144
|
+
|
|
145
|
+
|
|
140
146
|
if (options.joinChannel) {
|
|
141
147
|
console.log('options joinchannel', options.joinChannel)
|
|
142
148
|
io.channels.add(options.joinChannel)
|
|
@@ -185,6 +191,19 @@ io.on('over_size', () => {
|
|
|
185
191
|
Console.Colors.Yellow)
|
|
186
192
|
})
|
|
187
193
|
|
|
194
|
+
io.on('echo', (...args) => {
|
|
195
|
+
wsConsole.print(
|
|
196
|
+
Console.Types.Control,
|
|
197
|
+
`ECHO ${args}`,
|
|
198
|
+
Console.Colors.Yellow)
|
|
199
|
+
})
|
|
200
|
+
io.on('iam_res', (...args) => {
|
|
201
|
+
// console.log('log: ', args)
|
|
202
|
+
wsConsole.print(
|
|
203
|
+
Console.Types.Incoming,
|
|
204
|
+
`IAM_RES ${args}`,
|
|
205
|
+
Console.Colors.Yellow)
|
|
206
|
+
})
|
|
188
207
|
|
|
189
208
|
io.on('message', (data, isBinary) => {
|
|
190
209
|
|
|
@@ -384,7 +403,12 @@ wsConsole.on('line', (data) => {
|
|
|
384
403
|
)
|
|
385
404
|
}
|
|
386
405
|
} else {
|
|
387
|
-
io.send( data )
|
|
406
|
+
// io.send( data )
|
|
407
|
+
wsConsole.print(
|
|
408
|
+
Console.Types.Error,
|
|
409
|
+
'command list: .signal .sig .listen .publish .pub .subscribe .sub .unsub .ping .pong .id .iam .open .connect .close .login .auth .quit .exit',
|
|
410
|
+
Console.Colors.Yellow
|
|
411
|
+
)
|
|
388
412
|
}
|
|
389
413
|
wsConsole.prompt()
|
|
390
414
|
})
|
package/bin/io-server.js
CHANGED
|
@@ -2,13 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
import { createClient } from 'redis';
|
|
4
4
|
import { program } from 'commander'
|
|
5
|
-
import { version } from './getVersion.js'
|
|
6
5
|
import { serverInfo } from './serverInfo.js';
|
|
7
6
|
import {
|
|
8
7
|
Server, serverOption, Auth_File, Auth_Env, Auth_Redis,
|
|
9
|
-
api_reply, api_sudo, RedisAPI
|
|
8
|
+
api_reply, api_sudo, RedisAPI, version as iosignal_version
|
|
10
9
|
} from 'iosignal'
|
|
11
10
|
|
|
11
|
+
import pkg from '../package.json' with { type: 'json' };
|
|
12
|
+
const cli_version = pkg.version;
|
|
13
|
+
const version = `CLI ${cli_version} IOSignal ${iosignal_version}`
|
|
12
14
|
|
|
13
15
|
|
|
14
16
|
program
|
|
@@ -30,20 +32,13 @@ program
|
|
|
30
32
|
|
|
31
33
|
const options = program.opts()
|
|
32
34
|
|
|
35
|
+
// global shared serverOption
|
|
33
36
|
if (options.fileLogger) {
|
|
34
37
|
serverOption.fileLogger.connection.use = true;
|
|
35
38
|
serverOption.fileLogger.auth.use = true;
|
|
36
39
|
serverOption.fileLogger.attack.use = true;
|
|
37
40
|
}
|
|
38
41
|
|
|
39
|
-
if (options.listen) {
|
|
40
|
-
serverOption.port = parseInt(options.listen)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (options.listenCongport) {
|
|
44
|
-
serverOption.congPort = parseInt(options.listenCongport)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
42
|
if (options.showMessage) {
|
|
48
43
|
serverOption.showMessage = options.showMessage
|
|
49
44
|
}
|
|
@@ -56,6 +51,15 @@ if (options.timeout) {
|
|
|
56
51
|
serverOption.timeout = options.timeout
|
|
57
52
|
}
|
|
58
53
|
|
|
54
|
+
// private port, congPort
|
|
55
|
+
let privateServerOptions = { };
|
|
56
|
+
if (options.listen) {
|
|
57
|
+
privateServerOptions.port = parseInt(options.listen)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (options.listenCongport) {
|
|
61
|
+
privateServerOptions.congPort = parseInt(options.listenCongport)
|
|
62
|
+
}
|
|
59
63
|
|
|
60
64
|
let authManager;
|
|
61
65
|
let redisClient;
|
|
@@ -81,7 +85,7 @@ if (options.authFile) {
|
|
|
81
85
|
}
|
|
82
86
|
|
|
83
87
|
|
|
84
|
-
const server = new Server(
|
|
88
|
+
const server = new Server( privateServerOptions , authManager);
|
|
85
89
|
|
|
86
90
|
if (options.apiList && options.apiList.length > 0) {
|
|
87
91
|
let apiList = options.apiList
|
|
@@ -93,12 +97,14 @@ if (options.apiList && options.apiList.length > 0) {
|
|
|
93
97
|
}
|
|
94
98
|
|
|
95
99
|
if (options.showOptions) {
|
|
96
|
-
console.log('ServerOptions:', serverOption)
|
|
100
|
+
console.log('global ServerOptions:', serverOption)
|
|
101
|
+
console.log('private ServerOptions:', privateServerOptions)
|
|
97
102
|
console.log('server api list', server.apiNames)
|
|
98
103
|
}
|
|
99
104
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
if (
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
+
setTimeout(()=>{
|
|
106
|
+
console.log(serverInfo(server))
|
|
107
|
+
if ( server.port === null && server.congPort === null ) {
|
|
108
|
+
process.exit();
|
|
109
|
+
}
|
|
110
|
+
},1000)
|
package/bin/serverInfo.js
CHANGED
|
@@ -17,12 +17,12 @@ export function getNetworkAddress (){
|
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
export function serverInfo (
|
|
21
|
-
|
|
20
|
+
export function serverInfo ( server ){
|
|
21
|
+
|
|
22
22
|
let ip = getNetworkAddress();
|
|
23
23
|
let message
|
|
24
24
|
|
|
25
|
-
if(
|
|
25
|
+
if( server.port == 0 || server.port || server.congPort == 0 || server.congPort ){
|
|
26
26
|
message = chalk.green('Serving');
|
|
27
27
|
}else{
|
|
28
28
|
message = chalk.green('please use -l and -L option to select port number.');
|
|
@@ -39,27 +39,27 @@ export function serverInfo ( wsPort, congPort ){
|
|
|
39
39
|
const prefix = '- '
|
|
40
40
|
const space = ' '
|
|
41
41
|
|
|
42
|
-
if(
|
|
42
|
+
if(server.port == 0 || server.port){
|
|
43
43
|
message += `\n\n`;
|
|
44
44
|
message += chalk.green('IOSignal Over WebSocket');
|
|
45
45
|
message += chalk.yellow('\n\n Web Browser & Node.js');
|
|
46
|
-
message += `\n ${chalk.bold(`${prefix}Local:`)}${space}ws://localhost:${
|
|
47
|
-
message += `\n ${chalk.bold('- Network:')} ws://${ip}:${
|
|
46
|
+
message += `\n ${chalk.bold(`${prefix}Local:`)}${space}ws://localhost:${server.port}`;
|
|
47
|
+
message += `\n ${chalk.bold('- Network:')} ws://${ip}:${server.port}`;
|
|
48
48
|
}else{
|
|
49
49
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
if(congPort){
|
|
52
|
+
if(server.congPort == 0 || server.congPort){
|
|
53
53
|
message += `\n\n`;
|
|
54
54
|
message += chalk.green('IOSignal Over CongSocket');
|
|
55
55
|
message += chalk.yellow('\n\n Node.js');
|
|
56
56
|
|
|
57
|
-
message += `\n ${chalk.bold(`${prefix}Local:`)}${space}cong://localhost:${congPort}`;
|
|
58
|
-
message += `\n ${chalk.bold('- Network:')} cong://${ip}:${congPort}`;
|
|
57
|
+
message += `\n ${chalk.bold(`${prefix}Local:`)}${space}cong://localhost:${server.congPort}`;
|
|
58
|
+
message += `\n ${chalk.bold('- Network:')} cong://${ip}:${server.congPort}`;
|
|
59
59
|
|
|
60
60
|
message += chalk.yellow('\n\n Arduino');
|
|
61
61
|
message += `\n ${chalk.bold(`${prefix}host:`)} ${ip}`;
|
|
62
|
-
message += `\n ${chalk.bold('- port:')} ${congPort }`;
|
|
62
|
+
message += `\n ${chalk.bold('- port:')} ${server.congPort }`;
|
|
63
63
|
|
|
64
64
|
}
|
|
65
65
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "iosignal-cli",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"description": "IOSignal server and client CLI program.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"boxen": "8.0.1",
|
|
22
22
|
"chalk": "5.6.2",
|
|
23
23
|
"commander": "13.1.0",
|
|
24
|
-
"iosignal": "^3.
|
|
24
|
+
"iosignal": "^3.3.0",
|
|
25
25
|
"redis": "4.7.1"
|
|
26
26
|
},
|
|
27
27
|
"repository": {
|