iosignal-cli 4.6.0 → 4.10.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/{auth_file.js → auth_file_sample/auth_file.js} +2 -5
- package/auth_file_sample/auth_file.json +9 -0
- package/bin/io-client.js +31 -16
- package/bin/io-server.js +15 -15
- package/package.json +2 -2
- package/auth_file.json +0 -13
|
@@ -3,17 +3,14 @@
|
|
|
3
3
|
Authentication data sample.
|
|
4
4
|
|
|
5
5
|
device props: ["did", "key", "cid", level ]
|
|
6
|
-
|
|
7
6
|
did: ( device id ) authentication id. maximum 8 chars.
|
|
8
|
-
key: ( device key ) authentication key. no size limit.
|
|
7
|
+
key: ( device key ) authentication key. no size limit. recommended ~44 base64 chars.
|
|
9
8
|
cid: ( communication id ) signal target id. maximum 12 chars.
|
|
10
|
-
level:( quota level) <Number> ref. /
|
|
9
|
+
level:( quota level) <Number> ref. /src/common/quotaTable.js
|
|
11
10
|
|
|
12
11
|
*/
|
|
13
12
|
export const authInfo = [
|
|
14
13
|
["did","passowrd","cid",0],
|
|
15
|
-
["device1","device1_key","device1_cid",0],
|
|
16
|
-
["device2","device2_key","device2_cid",0],
|
|
17
14
|
["uno","uno-key","uno",1],
|
|
18
15
|
["go","go-key","go",2],
|
|
19
16
|
["bro","bro-key","bro",3],
|
package/bin/io-client.js
CHANGED
|
@@ -108,7 +108,8 @@ const defaultWebSocketPort = 7777;
|
|
|
108
108
|
console.log(options)
|
|
109
109
|
|
|
110
110
|
if (!options.connect) {
|
|
111
|
-
options.connect = 'localhost:' + defaultWebSocketPort;
|
|
111
|
+
// options.connect = 'localhost:' + defaultWebSocketPort;
|
|
112
|
+
options.connect = 'wss://io.remocon.kr/ws'
|
|
112
113
|
}
|
|
113
114
|
|
|
114
115
|
|
|
@@ -167,7 +168,8 @@ io.on('ready', () => {
|
|
|
167
168
|
})
|
|
168
169
|
|
|
169
170
|
io.on('close', () => {
|
|
170
|
-
|
|
171
|
+
let date = new Date().toLocaleTimeString()
|
|
172
|
+
wsConsole.print(Console.Types.Control, `closed ${date}`, Console.Colors.Yellow)
|
|
171
173
|
})
|
|
172
174
|
|
|
173
175
|
|
|
@@ -184,6 +186,14 @@ io.on('auth_fail', () => {
|
|
|
184
186
|
`Boho auth_fail.`,
|
|
185
187
|
Console.Colors.Yellow)
|
|
186
188
|
})
|
|
189
|
+
|
|
190
|
+
io.on('auth_clear', () => {
|
|
191
|
+
wsConsole.print(
|
|
192
|
+
Console.Types.Control,
|
|
193
|
+
`Boho auth_clear.`,
|
|
194
|
+
Console.Colors.Yellow)
|
|
195
|
+
})
|
|
196
|
+
|
|
187
197
|
io.on('over_size', () => {
|
|
188
198
|
wsConsole.print(
|
|
189
199
|
Console.Types.Control,
|
|
@@ -206,7 +216,13 @@ io.on('iam_res', (...args) => {
|
|
|
206
216
|
})
|
|
207
217
|
|
|
208
218
|
io.on('message',(tag,...args)=>{
|
|
209
|
-
|
|
219
|
+
let msg ;
|
|
220
|
+
if(typeof args[0] == 'object'){
|
|
221
|
+
msg = JSON.stringify( args[0])
|
|
222
|
+
}else{
|
|
223
|
+
msg = args;
|
|
224
|
+
}
|
|
225
|
+
wsConsole.print(Console.Types.Incoming, `message: ${tag} ${msg}`, Console.Colors.Green)
|
|
210
226
|
})
|
|
211
227
|
|
|
212
228
|
wsConsole.on('line', (data) => {
|
|
@@ -249,13 +265,13 @@ wsConsole.on('line', (data) => {
|
|
|
249
265
|
break;
|
|
250
266
|
|
|
251
267
|
case 'id':
|
|
252
|
-
console.log(`cid: ${io.cid} level: ${io.level}`)
|
|
268
|
+
console.log(`state: ${io.stateName} cid: ${io.cid} level: ${io.level}`)
|
|
253
269
|
break;
|
|
254
270
|
|
|
255
271
|
case 'sudo':
|
|
256
272
|
toks.shift()
|
|
257
273
|
console.log('sudo toks', toks)
|
|
258
|
-
io.
|
|
274
|
+
io.call('sudo', ...toks).then(res => {
|
|
259
275
|
if (res.ok) {
|
|
260
276
|
console.log('>> sudo response:', res.body)
|
|
261
277
|
} else {
|
|
@@ -304,18 +320,17 @@ wsConsole.on('line', (data) => {
|
|
|
304
320
|
io.set(toks[1])
|
|
305
321
|
break;
|
|
306
322
|
|
|
307
|
-
case '
|
|
308
|
-
case 'req':
|
|
323
|
+
case 'call':
|
|
309
324
|
toks.shift()
|
|
310
325
|
if (toks.length < 2) {
|
|
311
326
|
wsConsole.print(
|
|
312
327
|
Console.Types.Error,
|
|
313
|
-
'[.
|
|
328
|
+
'[.call need at least two params] call target command [, ..args]',
|
|
314
329
|
Console.Colors.Yellow
|
|
315
330
|
)
|
|
316
331
|
return
|
|
317
332
|
}
|
|
318
|
-
io.
|
|
333
|
+
io.call(...toks).then(result => {
|
|
319
334
|
console.log('>> response:', result)
|
|
320
335
|
}).catch(e => {
|
|
321
336
|
console.log(e)
|
|
@@ -328,13 +343,13 @@ wsConsole.on('line', (data) => {
|
|
|
328
343
|
case 'listen':
|
|
329
344
|
toks.shift()
|
|
330
345
|
let tag = toks[0]
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
346
|
+
if(tag){
|
|
347
|
+
io.subscribe( tag )
|
|
348
|
+
let tagList = tag.split(',')
|
|
349
|
+
tagList.forEach( (v)=>{
|
|
350
|
+
io.channels.add( v )
|
|
351
|
+
})
|
|
352
|
+
}
|
|
338
353
|
break;
|
|
339
354
|
|
|
340
355
|
|
package/bin/io-server.js
CHANGED
|
@@ -4,7 +4,7 @@ import { createClient } from 'redis';
|
|
|
4
4
|
import { program } from 'commander'
|
|
5
5
|
import { serverInfo } from './serverInfo.js';
|
|
6
6
|
import {
|
|
7
|
-
Server, serverOption,
|
|
7
|
+
Server, serverOption, replyService, sudoService, RedisService, version as iosignal_version,
|
|
8
8
|
BohoAuth, FileKeyProvider, StringKeyProvider, RedisKeyProvider
|
|
9
9
|
} from 'iosignal'
|
|
10
10
|
|
|
@@ -19,14 +19,13 @@ program
|
|
|
19
19
|
.option('-l, --listen <port>', 'listen on port (start WebSocket Server)')
|
|
20
20
|
.option('-L, --listen-congport <port>', 'listen on cong port (start CongSocket Server)')
|
|
21
21
|
.option('-d, --auth-file <path>', 'auth data file path')
|
|
22
|
-
.option('-e, --auth-param <id.key.level>', 'auth data from argument:
|
|
23
|
-
.option('-E, --auth-env', 'auth data from shell env BOHO_AUTH')
|
|
22
|
+
.option('-e, --auth-param <id.key.level>', 'auth data from argument: id1.key.cid1.level1,id2.key2.cid2.level2')
|
|
24
23
|
.option('-r, --auth-redis', 'connect to redis. if exist use env REDIS_HOST, REDIS_PORT or localhost:6379')
|
|
25
24
|
.option('-t, --timeout <milliseconds>', 'ping period & timeout')
|
|
26
25
|
.option('-m, --metric <type>', 'show metric <number> 1:traffic, 2:echo')
|
|
27
26
|
.option('-s, --show-message <none|message>', 'show receive message. ')
|
|
28
27
|
.option('-f, --file-logger', 'write log files.')
|
|
29
|
-
.option('-a, --
|
|
28
|
+
.option('-a, --attach-services [list...]', 'one or multiple service module names: -a service1 service2')
|
|
30
29
|
.option('-o, --show-options', 'show server init options.')
|
|
31
30
|
.parse(process.argv)
|
|
32
31
|
|
|
@@ -70,8 +69,6 @@ if (options.authFile) {
|
|
|
70
69
|
authManager = new BohoAuth( new FileKeyProvider(authFilePath) )
|
|
71
70
|
} else if (options.authParam) {
|
|
72
71
|
authManager = new BohoAuth( new StringKeyProvider(options.authParam) )
|
|
73
|
-
} else if (options.authEnv) {
|
|
74
|
-
authManager = new BohoAuth( new StringKeyProvider(options.authEnv) )
|
|
75
72
|
} else if (options.authRedis) {
|
|
76
73
|
console.log("auth data origin: redis")
|
|
77
74
|
// console.log('####### default redis server url: redis://localhost:6379 ' )
|
|
@@ -87,26 +84,29 @@ if (options.authFile) {
|
|
|
87
84
|
|
|
88
85
|
const server = new Server( privateServerOptions , authManager);
|
|
89
86
|
|
|
90
|
-
if (options.
|
|
91
|
-
let
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
if (
|
|
87
|
+
if (options.attachServices && options.attachServices.length > 0) {
|
|
88
|
+
let attachServices = options.attachServices
|
|
89
|
+
if (attachServices.includes('reply')){
|
|
90
|
+
server.attach('reply', replyService)
|
|
91
|
+
}
|
|
92
|
+
if (attachServices.includes('sudo')){
|
|
93
|
+
server.attach('sudo', sudoService)
|
|
94
|
+
}
|
|
95
|
+
if (attachServices.includes('redis')){
|
|
96
96
|
if(!redisClient){
|
|
97
97
|
redisClient = createClient();
|
|
98
98
|
redisClient.on('error', (err) => console.log('Redis Client Error', err));
|
|
99
99
|
redisClient.connect();
|
|
100
100
|
}
|
|
101
|
-
server.
|
|
101
|
+
server.attach('redis', new RedisService(redisClient))
|
|
102
102
|
}
|
|
103
|
-
|
|
103
|
+
console.log('registed service names', server.serviceNames)
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
if (options.showOptions) {
|
|
107
107
|
console.log('global ServerOptions:', serverOption)
|
|
108
108
|
console.log('private ServerOptions:', privateServerOptions)
|
|
109
|
-
console.log('server
|
|
109
|
+
console.log('server serviceNames:', server.serviceNames)
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
setTimeout(()=>{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "iosignal-cli",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.10.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": "^4.
|
|
24
|
+
"iosignal": "^4.10.0",
|
|
25
25
|
"redis": "4.7.1"
|
|
26
26
|
},
|
|
27
27
|
"repository": {
|
package/auth_file.json
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
[
|
|
2
|
-
["sampleid","samplekey","sample_cid",0],
|
|
3
|
-
["id_max8","no_key_size_limit","communication_id",0],
|
|
4
|
-
["device1","device1_key","device1_cid",0],
|
|
5
|
-
["device2","device2_key","device2_cid",0],
|
|
6
|
-
["uno","uno","uno",1],
|
|
7
|
-
["go","go","go",2],
|
|
8
|
-
["bro","bro","bro",3],
|
|
9
|
-
["admin","admin","admin",255],
|
|
10
|
-
["adminb","adminb","adminb",255]
|
|
11
|
-
]
|
|
12
|
-
|
|
13
|
-
|