iosignal-cli 3.3.0 → 4.5.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/README.md CHANGED
@@ -1,38 +1,36 @@
1
1
  # IOSignal CLI
2
- [ [한국어](README.ko.md) | English ]
3
2
 
4
- IOSignal facilitates real-time communication among web browsers, Node.js applications, and Arduino devices. It also offers secure authentication and encrypted communication. With its built-in signaling protocol, the server can be used without additional programming.
3
+ IOSignal 브라우저, Node.js 애플리케이션 Arduino 장치 간의 실시간 통신을 용이하게 합니다. 또한 안전한 인증 암호화된 통신을 제공합니다. 내장된 시그널링 프로토콜을 통해 서버는 추가 프로그래밍 없이 사용할 수 있습니다.
5
4
 
6
- The `iosignal-cli` program simplifies the operation of an IOSignal server and client. It leverages the [iosignal](https://www.npmjs.com/package/iosignal) library and utilizes Redis for authentication database functionality.
5
+ `iosignal-cli` 프로그램은 IOSignal 서버 클라이언트의 작동을 단순화합니다. [iosignal](https://www.npmjs.com/package/iosignal) 라이브러리를 활용하고 인증 데이터베이스 기능에 Redis를 사용합니다.
7
6
 
7
+ ## 지원 플랫폼
8
8
 
9
- ## Supported Platforms
9
+ Windows, macOS, Linux.
10
10
 
11
- Windows, macOS, and Linux.
11
+ ## 설치
12
12
 
13
- ## Installation
14
-
15
- ### Linux, macOS, and Shell
13
+ ### Linux, macOS 및 쉘
16
14
 
17
15
  ```sh
18
- # Global installation.
16
+ # 전역 설치.
19
17
  $ npm install -g iosignal-cli
20
18
 
21
- # If you encounter a permissions error, use sudo.
19
+ # 권한 오류가 발생하면 sudo를 사용하십시오.
22
20
  $ sudo npm install -g iosignal-cli
23
21
  ```
24
22
 
25
- ### Windows (with Administrator Permissions)
23
+ ### Windows (관리자 권한)
26
24
 
27
25
  ```sh
28
- # Global installation.
26
+ # 전역 설치.
29
27
  $ npm install -g iosignal-cli
30
28
  ```
31
29
 
32
- ## IOSignal Server
30
+ ## IOSignal 서버
33
31
 
34
- - Use the `io-server` command.
35
- - `ios` is a shorthand alias for `io-server`.
32
+ - `io-server` 명령을 사용합니다.
33
+ - `ios`는 `io-server`의 약어입니다.
36
34
 
37
35
  ```
38
36
  % io-server -h
@@ -59,30 +57,29 @@ Options:
59
57
 
60
58
  ```
61
59
 
62
- ### IOSignal over WebSocket
60
+ ### WebSocket을 통한 IOSignal
63
61
 
64
- - Use the `-l` option to specify the port number for WebSocket connections.
65
- - Supports web browser and Node.js client access.
62
+ - `-l` 옵션을 사용하여 WebSocket 연결을 위한 포트 번호를 지정합니다.
63
+ - 브라우저 Node.js 클라이언트 액세스를 지원합니다.
66
64
 
67
65
  ```sh
68
66
  % io-server -l 7777
69
67
  ```
70
68
 
71
- ### IOSignal Over CongSocket
69
+ ### CongSocket을 통한 IOSignal
72
70
 
73
- - Use the `-L` option to specify the port number for CongSocket connections.
74
- - CongSocket is IOSignal's proprietary protocol, designed to be lighter than WebSocket.
75
- - It was developed specifically for low-end devices like Arduino.
76
- - Supports Arduino and Node.js client access.
71
+ - `-L` 옵션을 사용하여 CongSocket 연결을 위한 포트 번호를 지정합니다.
72
+ - CongSocket WebSocket보다 가볍게 설계된 IOSignal의 자체 프로토콜입니다.
73
+ - Arduino와 같은 저사양 장치를 위해 특별히 개발되었습니다.
74
+ - Arduino Node.js 클라이언트 액세스를 지원합니다.
77
75
 
78
76
  ```sh
79
77
  % io-server -L 8888
80
78
  ```
81
79
 
82
- ### Simultaneous WebSocket and CongSocket Support
83
-
84
- - This allows Arduino and web browsers to communicate with each other.
80
+ ### WebSocket CongSocket 동시 지원
85
81
 
82
+ - 이를 통해 Arduino와 웹 브라우저가 서로 통신할 수 있습니다.
86
83
 
87
84
  ```sh
88
85
  % io-server -l 7777 -L 8888
@@ -115,12 +112,12 @@ opening CongSocket Server: 8888
115
112
 
116
113
  ```
117
114
 
118
- ## Monitor Server
115
+ ## 모니터 서버
119
116
 
120
- ### Viewing Incoming Messages
117
+ ### 수신 메시지 보기
121
118
 
122
- - To view incoming signal messages on the server, use the `-s` option.
123
- - `ios` is a shorthand alias for `io-server`.
119
+ - 서버에서 수신되는 시그널 메시지를 보려면 `-s` 옵션을 사용합니다.
120
+ - `ios`는 `io-server`의 약어입니다.
124
121
 
125
122
  ```
126
123
  % ios -l 7777 -s message
@@ -132,57 +129,13 @@ opening CongSocket Server: 8888
132
129
 
133
130
  ```
134
131
 
135
- ### Viewing Metrics
136
132
 
137
- - `-m 1`: Displays channels, clients, and traffic.
138
- - `-m 2`: Displays clients.
139
- - `-m 3`: Displays channels.
133
+ ## IOSignal 클라이언트
140
134
 
141
- ```sh
142
-
143
- $ ios -l 7777 -m 1
144
- ...
145
-
146
- monitor metric type: 1
147
- ┌─────────┬───────────┬───────────┬──────────┬──────────┬──────────────┐
148
- │ (index) │ rss │ heapTotal │ heapUsed │ external │ arrayBuffers │
149
- ├─────────┼───────────┼───────────┼──────────┼──────────┼──────────────┤
150
- │ 0 │ 108232704 │ 57294848 │ 24523112 │ 1389925 │ 59260 │
151
- └─────────┴───────────┴───────────┴──────────┴──────────┴──────────────┘
152
- ┌─────────┬──────────┬─────────┬──────────┬─────────┬─────────┐
153
- │ (index) │ lastSSID │ remotes │ channels │ txBytes │ rxBytes │
154
- ├─────────┼──────────┼─────────┼──────────┼─────────┼─────────┤
155
- │ 0 │ 2 │ 2 │ 1 │ 57 │ 18 │
156
- └─────────┴──────────┴─────────┴──────────┴─────────┴─────────┘
157
-
158
-
159
- $ ios -l 7777 -m 2
160
- ...
161
- monitor metric type: 2
162
- ┌─────────┬───────────────┐
163
- │ (index) │ Values │
164
- ├─────────┼───────────────┤
165
- │ 0 │ '#1:?9P-i(7)' │
166
- │ 1 │ '#2:?zNuW(7)' │
167
- └─────────┴───────────────┘
168
-
169
-
170
- $ ios -l 7777 -m 3
171
- ...
172
- monitor metric type: 3
173
- ┌─────────┬───────────────────────┐
174
- │ (index) │ Values │
175
- ├─────────┼───────────────────────┤
176
- │ 0 │ 'PRIVATE:#homeButton' │
177
- └─────────┴───────────────────────┘
178
- ```
135
+ - `io-client` 명령을 사용합니다.
136
+ - `io`는 `io-client`의 약어입니다.
179
137
 
180
- ## IOSignal Client
181
-
182
- - Use the `io-client` command.
183
- - `io` is a shorthand alias for `io-client`.
184
-
185
- ### Usage
138
+ ### 사용법
186
139
 
187
140
  ```
188
141
  % io -h
@@ -196,16 +149,16 @@ Options:
196
149
  -k, --key <key> userKey
197
150
  -a, --auth-idKey <idkey> auth id.key
198
151
  -j, --join-channel <channelName> join to channel
199
- -h, --help display help for command
152
+ -h, --help display help for command
200
153
 
201
154
  ```
202
155
 
203
- ### Connection
156
+ ### 연결
204
157
 
205
- - To connect to a server, specify the server address and port number using the `-c` option.
206
- - The server address requires one of the following protocols: `ws`, `wss`, or `cong`.
158
+ - 서버에 연결하려면 `-c` 옵션을 사용하여 서버 주소와 포트 번호를 지정합니다.
159
+ - 서버 주소는 다음 프로토콜 하나를 필요로 합니다: `ws`, `wss`, 또는 `cong`.
207
160
  - `ws://url:port` (WebSocket)
208
- - For `localhost`, `ws://` can be omitted.
161
+ - `localhost`의 경우 `ws://`는 생략할 있습니다.
209
162
  - `wss://url:port` (WebSocket TLS)
210
163
  - `cong://url:port` (CongSocket)
211
164
 
@@ -227,17 +180,16 @@ ready: cid: ?yVAQ
227
180
 
228
181
  ```
229
182
 
230
- - Upon successful client connection, the `cid` (Communication ID) is displayed with a `ready` indication.
231
- - The CID is a unique communication ID issued by the server.
232
- - The CID of an unauthenticated client changes with each connection.
233
- - Authenticated clients use a fixed, predefined CID.
234
- - You can use CIDs for one-to-one communication or CID subscriptions.
235
-
183
+ - 클라이언트 연결에 성공하면 `cid` (통신 ID) `ready` 표시와 함께 표시됩니다.
184
+ - CID 서버에서 발급하는 고유한 통신 ID입니다.
185
+ - 인증되지 않은 클라이언트의 CID는 연결할 때마다 변경됩니다.
186
+ - 인증된 클라이언트는 고정된 사전 정의된 CID를 사용합니다.
187
+ - CID를 사용하여 일대일 통신 또는 CID 구독을 있습니다.
236
188
 
237
- ### `io-client` CLI Command List
189
+ ### `io-client` CLI 명령 목록
238
190
 
239
- - When connected to the server with the `io-client` CLI program, you can communicate, subscribe, and issue signals using the commands below.
240
- - The CLI program can also communicate with browsers and Arduino devices connected to the server.
191
+ - `io-client` CLI 프로그램을 사용하여 서버에 연결하면 아래 명령을 사용하여 통신하고, 구독하고, 시그널을 발행할 수 있습니다.
192
+ - CLI 프로그램은 서버에 연결된 브라우저 Arduino 장치와도 통신할 있습니다.
241
193
 
242
194
  ```
243
195
  io-client cli commands:
@@ -260,21 +212,20 @@ io-client cli commands:
260
212
  .exit
261
213
  ```
262
214
 
215
+ ## 튜토리얼
263
216
 
264
- ## Tutorial
217
+ ### 시그널링
265
218
 
266
- ### Signaling
219
+ - **멀티캐스트**: 채널 이름을 구독/발행합니다.
220
+ - **유니캐스트**: CID (통신 ID)를 사용합니다.
267
221
 
268
- - **Multicast**: Publish/subscribe to a channel name.
269
- - **Unicast**: Use a CID (Communication ID).
270
-
271
- 1. Start the server:
222
+ 1. 서버 시작:
272
223
  ```sh
273
224
  $ io-server -l 7777
274
225
 
275
226
  ```
276
227
 
277
- 2. Start client A:
228
+ 2. 클라이언트 A 시작:
278
229
 
279
230
  ```sh
280
231
  $ io -c localhost:7777
@@ -282,85 +233,89 @@ Connecting to ws://localhost:7777
282
233
  ready: cid: ?c3Nr
283
234
 
284
235
  > .subscribe channel_name
285
- # Subscribe to a channel
236
+ # 채널 구독
286
237
  ```
287
238
 
288
- 3. Start client B:
239
+ 3. 클라이언트 B 시작:
289
240
  ```sh
290
241
  $ io -c localhost:7777
291
242
  Connecting to ws://localhost:7777
292
243
  ready: cid: ?rr75
293
244
  >
294
- # Multicast.
245
+ # 멀티캐스트.
295
246
  > .signal channel_name some_message
296
247
 
297
- # Unicast to A.
248
+ # A에게 유니캐스트.
298
249
  > .signal ?c3Nr@ direct_message
299
- # IMPORTANT: Unicast signal tags must include the '@' character (e.g., tag = 'cid' + @).
250
+ # 중요: 유니캐스트 시그널 태그에는 '@' 문자가 포함되어야 합니다 (예: tag = 'cid' + @).
300
251
  ```
301
252
 
302
- ### Authentication
253
+ ### 인증
254
+
255
+ #### 유형 1: 파일에서 인증 데이터
303
256
 
304
- #### Type 1: Authentication Data from File
257
+ - 개인 용도로만 사용합니다.
258
+ - 원시, 일반 비밀번호 문자열 (해시되지 않음).
259
+ - 각 장치에는 `deviceId`, `deviceKey`, `deviceCId`, `level`의 네 가지 값이 있습니다.
260
+ - auth_file_sample 폴더에서 `auth_file.js` 및 `auth_file.json` sample 을 찾을 수 있습니다.
305
261
 
306
- - For personal use only.
307
- - Raw, plain password strings (not hashed).
308
- - Each device has four values: `deviceId`, `deviceKey`, `deviceCId`, and `level`.
309
- - You can find sample `auth_file.js` and `auth_file.json` in the root folder.
310
262
  ```sh
311
263
  $ io-server -l 7777 -d auth_file.json
312
264
  or
313
265
  $ io-server -l 7777 -d auth_file.js
314
266
  ```
315
267
 
316
- auth_file.json structure:
317
- - `deviceId` string size limit: 8 characters.
318
- - No passphrase string limit (it will be digested to 32 bytes with SHA256).
319
- - `CID` string size limit: currently 20 characters (can be changed).
320
- - JSON files do not support comments.
268
+ `auth_file.json` 구조:
269
+ - `deviceId` 문자열 길이 제한: 8자.
270
+ - 비밀번호 문자열 길이 제한 없음 (SHA256으로 32바이트로 다이제스트됨).
271
+ - `CID` 문자열 길이 제한: 현재 20 (변경 가능).
272
+ - JSON 파일은 주석을 지원하지 않습니다.
321
273
  ```js
322
274
  [
323
- ["id","key","cid",0],
324
- ["did2","did2key","did2-cid",0],
325
- ["uno3","uno3-key","uno3-cid",1]
275
+ ["did","passowrd","cid",0],
276
+ ["uno","uno-key","uno",1],
277
+ ["go","go-key","go",2],
278
+ ["bro","bro-key","bro",3],
279
+ ["admin","admin-key","admin",255]
326
280
  ]
281
+
282
+
327
283
  ```
328
284
 
329
285
  ### `auth_file.js`
330
286
 
331
- - Supports comments.
287
+ - 주석을 지원합니다.
332
288
 
333
289
  ```js
334
290
  // *.mjs file support comments.
335
291
  export const authInfo = [
336
- // device id, key, communication id, level:Number(0~255)
337
- ["did","passowrd","cid",0],
338
- ["device1","device1_key","device1_cid",0],
339
- ["root","root-key","root-cid",255], // default admin_root level is 255
340
- ["uno","uno-key","uno",1]
292
+ ["did","passowrd","cid",0],
293
+ ["uno","uno-key","uno",1],
294
+ ["go","go-key","go",2],
295
+ ["bro","bro-key","bro",3],
296
+ ["admin","admin-key","admin",255],
341
297
  ]
342
- ```
343
298
 
344
299
 
300
+ ```
345
301
 
346
- #### Type 2: Authentication Data from Redis (or other Database)
302
+ #### 유형 2: Redis (또는 기타 데이터베이스)에서 인증 데이터
347
303
 
348
- - Recommended.
349
- - You can find source code and examples here:
304
+ - 권장됩니다.
305
+ - 소스 코드 예제는 다음에서 찾을 있습니다:
350
306
  - `iosignal`: `/src/auth/`
351
307
  - `iosignal-cli`: `/test_auth_redis/`
352
308
 
353
- Before running the server, ensure your Redis server is operational and that you have registered your device credentials. A simple credentials enrollment example is included in the source above.
309
+ 서버를 실행하기 전에 Redis 서버가 작동 중이고 장치 자격 증명을 등록했는지 확인하십시오. 간단한 자격 증명 등록 예제는 소스에 포함되어 있습니다.
354
310
 
355
- start server with local redis-auth-system
311
+ 로컬 Redis 인증 시스템으로 서버 시작
356
312
  ```sh
357
313
  $ io-server -l 7777 -r # redis://localhost:6379
358
314
  ```
359
315
 
360
-
361
- ### Authenticating Clients
362
- 1. Start the authentication server.
363
- 2. Connect and log in.
316
+ ### 클라이언트 인증
317
+ 1. 인증 서버를 시작합니다.
318
+ 2. 연결하고 로그인합니다.
364
319
 
365
320
  ```sh
366
321
  $ io -c localhost:7777
@@ -371,39 +326,37 @@ try manual login: uno3
371
326
  current quota: {"signalSize":255,"publishCounter":10,"trafficRate":100000}
372
327
  ready: cid: uno3-cid
373
328
 
374
- - Now the device has a (pre-registered) CID.
329
+ - 이제 장치에 (사전 등록된) CID가 있습니다.
375
330
 
376
331
  ```
377
332
 
378
- ## Support for Both Web Browsers and Arduino
333
+ ## 브라우저 Arduino 동시 지원
379
334
 
380
- ### Specifying Two Types of Ports
335
+ ### 가지 유형의 포트 지정
381
336
 
382
- IOSignal uses WebSockets for web browser peer connections. If you want to use an Arduino connection, you must specify the CongSocket port using the `-L` option.
337
+ IOSignal 브라우저 피어 연결에 WebSocket을 사용합니다. Arduino 연결을 사용하려면 `-L` 옵션을 사용하여 CongSocket 포트를 지정해야 합니다.
383
338
 
384
- The `-l` option specifies the WebSocket port, and the `-L` option specifies the CongSocket port for Arduino connections.
339
+ `-l` 옵션은 WebSocket 포트를 지정하고, `-L` 옵션은 Arduino 연결을 위한 CongSocket 포트를 지정합니다.
385
340
 
386
341
  ```sh
387
342
 
388
343
  $ io-server -l 7777 -L 8888
389
- # -l option for WebSocket port
390
- # -L option for CongSocket port ( Arduino connection)
344
+ # -l 옵션은 WebSocket 포트용
345
+ # -L 옵션은 CongSocket 포트용 (Arduino 연결)
391
346
  ```
392
347
 
393
- ### Local Network IP Address
348
+ ### 로컬 네트워크 IP 주소
394
349
 
395
- If you need the server's IP address to access it from your local network, you can check it using the following command:
350
+ 로컬 네트워크에서 서버에 액세스하기 위해 서버의 IP 주소가 필요한 경우 다음 명령을 사용하여 확인할 있습니다:
396
351
 
397
352
  ```sh
398
353
  $ ioip
399
354
  192.168.0.72
400
355
  ```
401
356
 
357
+ ### IOSignal Arduino 라이브러리
402
358
 
403
- ### IOSignal Arduino Library
404
-
405
- Search for `IOSignal` in the Arduino library manager and install it, or refer to the [`iosignal-arduino`](https://github.com/remocons/iosignal-arduino) GitHub repository.
406
-
359
+ Arduino 라이브러리 관리자에서 `IOSignal`을 검색하여 설치하거나, [`iosignal-arduino`](https://github.com/remocons/iosignal-arduino) GitHub 저장소를 참조하십시오.
407
360
 
408
- ## iosignal stack
361
+ ## iosignal 스택
409
362
  ![IOSignal](./img/iosignal_architecture.png)
package/bin/io-client.js CHANGED
@@ -137,8 +137,8 @@ if (options.id && options.key) {
137
137
  }
138
138
 
139
139
 
140
- io.listen('@', (...args) => {
141
- console.log('rcv @', args)
140
+ io.listen('@', (tag, ...args) => {
141
+ console.log('CID Message: ', tag, args)
142
142
  })
143
143
 
144
144
 
@@ -205,28 +205,10 @@ io.on('iam_res', (...args) => {
205
205
  Console.Colors.Yellow)
206
206
  })
207
207
 
208
- io.on('message', (data, isBinary) => {
209
-
210
- let moreBytesIndicator = ""
211
- if (isBinary) {
212
- let buffer
213
- const displayBufferLimit = 20
214
- if (data.byteLength > displayBufferLimit) {
215
- buffer = Buffer.from(data, 0, displayBufferLimit);
216
- moreBytesIndicator = "..."
217
- } else {
218
- buffer = Buffer.from(data);
219
- }
220
-
221
- let prn = `${buffer.toString('hex')}${moreBytesIndicator} [${data.byteLength} bytes total]`;
222
- if (wsConsole.showIncommingMessage) wsConsole.print(Console.Types.Incoming, `rx: bin [hex] ${prn}`, Console.Colors.Green)
223
-
224
- } else {
225
- if (wsConsole.showIncommingMessage) wsConsole.print(Console.Types.Incoming, `rx: text: ${data}`, Console.Colors.Green)
226
- }
208
+ io.on('message',(tag,...args)=>{
209
+ wsConsole.print(Console.Types.Incoming, `message: ${tag} ${args}`, Console.Colors.Green)
227
210
  })
228
211
 
229
- // to send frame message.
230
212
  wsConsole.on('line', (data) => {
231
213
  if (data[0] === '.') {
232
214
  const toks = data.split(/\s+/)
@@ -346,12 +328,13 @@ wsConsole.on('line', (data) => {
346
328
  case 'listen':
347
329
  toks.shift()
348
330
  let tag = toks[0]
349
- console.log('listen tag', tag)
350
- io.listen(tag, (...args) => {
351
- console.log(`subscribe & listen tag: ${tag} args:`, args)
331
+ io.subscribe( tag )
332
+ console.log('subscribe tag', tag)
333
+ // io.listen(tag, (tag, ...args) => {
334
+ // console.log(`subscribe & listen tag: ${tag} args:`, args)
352
335
 
353
- })
354
- io.subscribe_memory_channels()
336
+ // })
337
+ // io.subscribe_memory_channels()
355
338
  break;
356
339
 
357
340
 
package/bin/io-server.js CHANGED
@@ -4,8 +4,8 @@ import { createClient } from 'redis';
4
4
  import { program } from 'commander'
5
5
  import { serverInfo } from './serverInfo.js';
6
6
  import {
7
- Server, serverOption, Auth_File, Auth_Env, Auth_Redis,
8
- api_reply, api_sudo, RedisAPI, version as iosignal_version
7
+ Server, serverOption, api_reply, api_sudo, RedisAPI, version as iosignal_version,
8
+ BohoAuth, FileKeyProvider, StringKeyProvider, RedisKeyProvider
9
9
  } from 'iosignal'
10
10
 
11
11
  import pkg from '../package.json' with { type: 'json' };
@@ -67,18 +67,18 @@ let redisClient;
67
67
  if (options.authFile) {
68
68
  console.log("auth data origin: auth_file")
69
69
  let authFilePath = options.authFile;
70
- authManager = new Auth_File(authFilePath)
70
+ authManager = new BohoAuth( new FileKeyProvider(authFilePath) )
71
71
  } else if (options.authParam) {
72
- authManager = new Auth_Env(options.authParam)
72
+ authManager = new BohoAuth( new StringKeyProvider(options.authParam) )
73
73
  } else if (options.authEnv) {
74
- authManager = new Auth_Env()
74
+ authManager = new BohoAuth( new StringKeyProvider(options.authEnv) )
75
75
  } else if (options.authRedis) {
76
76
  console.log("auth data origin: redis")
77
77
  // console.log('####### default redis server url: redis://localhost:6379 ' )
78
78
  redisClient = createClient();
79
79
  redisClient.on('error', (err) => console.log('Redis Client Error', err));
80
80
  redisClient.connect();
81
- authManager = new Auth_Redis(redisClient)
81
+ authManager = new BohoAuth( new RedisKeyProvider( redisClient))
82
82
  } else {
83
83
  // console.log("No authentication support.")
84
84
 
@@ -92,7 +92,14 @@ if (options.apiList && options.apiList.length > 0) {
92
92
  console.log('api list', apiList)
93
93
  if (apiList.includes('reply')) server.api('reply', api_reply)
94
94
  if (apiList.includes('sudo')) server.api('sudo', api_sudo)
95
- if (apiList.includes('redis')) server.api('redis', new RedisAPI(redisClient))
95
+ if (apiList.includes('redis')){
96
+ if(!redisClient){
97
+ redisClient = createClient();
98
+ redisClient.on('error', (err) => console.log('Redis Client Error', err));
99
+ redisClient.connect();
100
+ }
101
+ server.api('redis', new RedisAPI(redisClient))
102
+ }
96
103
 
97
104
  }
98
105
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iosignal-cli",
3
- "version": "3.3.0",
3
+ "version": "4.5.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.3.0",
24
+ "iosignal": "^4.5.0",
25
25
  "redis": "4.7.1"
26
26
  },
27
27
  "repository": {
package/README.ko.md DELETED
@@ -1,400 +0,0 @@
1
- # IOSignal CLI
2
- [ 한국어 | [English](README.md) ]
3
-
4
- IOSignal은 웹 브라우저, Node.js 애플리케이션 및 Arduino 장치 간의 실시간 통신을 용이하게 합니다. 또한 안전한 인증 및 암호화된 통신을 제공합니다. 내장된 시그널링 프로토콜을 통해 서버는 추가 프로그래밍 없이 사용할 수 있습니다.
5
-
6
- `iosignal-cli` 프로그램은 IOSignal 서버 및 클라이언트의 작동을 단순화합니다. [iosignal](https://www.npmjs.com/package/iosignal) 라이브러리를 활용하고 인증 데이터베이스 기능에 Redis를 사용합니다.
7
-
8
- ## 지원 플랫폼
9
-
10
- Windows, macOS, Linux.
11
-
12
- ## 설치
13
-
14
- ### Linux, macOS 및 쉘
15
-
16
- ```sh
17
- # 전역 설치.
18
- $ npm install -g iosignal-cli
19
-
20
- # 권한 오류가 발생하면 sudo를 사용하십시오.
21
- $ sudo npm install -g iosignal-cli
22
- ```
23
-
24
- ### Windows (관리자 권한)
25
-
26
- ```sh
27
- # 전역 설치.
28
- $ npm install -g iosignal-cli
29
- ```
30
-
31
- ## IOSignal 서버
32
-
33
- - `io-server` 명령을 사용합니다.
34
- - `ios`는 `io-server`의 약어입니다.
35
-
36
- ```
37
- % io-server -h
38
- Usage: io-server [options] (--listen <port> )
39
-
40
- Options:
41
- -V, --version output the version number
42
- -l, --listen <port> listen on port (start WebSocket Server)
43
- -L, --listen-congport <port> listen on cong port (start CongSocket
44
- Server)
45
- -d, --auth-file <path> auth data file path
46
- -e, --auth-param <id.key.level> auth data from argument:
47
- id.key.level,id2.key2.level2
48
- -E, --auth-env auth data from shell env BOHO_AUTH
49
- -r, --auth-redis connect to redis. if exist use env
50
- REDIS_HOST, REDIS_PORT or localhost:6379
51
- -t, --timeout <milliseconds> ping period & timeout
52
- -m, --metric <type> show metric <number> 1:traffic, 2:echo
53
- -s, --show-message <none|message> show receive message.
54
- -f, --file-logger write log files.
55
- -a, --api-list [list...] one or multiple api names: -a api_1 api_2
56
- -o, --show-options show server init options.
57
- -h, --help display help for command
58
-
59
- ```
60
-
61
- ### WebSocket을 통한 IOSignal
62
-
63
- - `-l` 옵션을 사용하여 WebSocket 연결을 위한 포트 번호를 지정합니다.
64
- - 웹 브라우저 및 Node.js 클라이언트 액세스를 지원합니다.
65
-
66
- ```sh
67
- % io-server -l 7777
68
- ```
69
-
70
- ### CongSocket을 통한 IOSignal
71
-
72
- - `-L` 옵션을 사용하여 CongSocket 연결을 위한 포트 번호를 지정합니다.
73
- - CongSocket은 WebSocket보다 가볍게 설계된 IOSignal의 자체 프로토콜입니다.
74
- - Arduino와 같은 저사양 장치를 위해 특별히 개발되었습니다.
75
- - Arduino 및 Node.js 클라이언트 액세스를 지원합니다.
76
-
77
- ```sh
78
- % io-server -L 8888
79
- ```
80
-
81
- ### WebSocket 및 CongSocket 동시 지원
82
-
83
- - 이를 통해 Arduino와 웹 브라우저가 서로 통신할 수 있습니다.
84
-
85
- ```sh
86
- % io-server -l 7777 -L 8888
87
- opening WebSocket Server: 7777
88
- opening CongSocket Server: 8888
89
-
90
- ┌───────────────────────────────────────────┐
91
- │ │
92
- │ Serving │
93
- │ │
94
- │ IOSignal Over WebSocket │
95
- │ │
96
- │ Web Browser & Node.js │
97
- │ - Local: ws://localhost:7777 │
98
- │ - Network: ws://192.168.0.72:7777 │
99
- │ │
100
- │ IOSignal Over CongSocket │
101
- │ │
102
- │ Node.js │
103
- │ - Local: cong://localhost:8888 │
104
- │ - Network: cong://192.168.0.72:8888 │
105
- │ │
106
- │ Arduino │
107
- │ - host: 192.168.0.72 │
108
- │ - port: 8888 │
109
- │ │
110
- └───────────────────────────────────────────┘
111
-
112
-
113
-
114
- ```
115
-
116
- ## 모니터 서버
117
-
118
- ### 수신 메시지 보기
119
-
120
- - 서버에서 수신되는 시그널 메시지를 보려면 `-s` 옵션을 사용합니다.
121
- - `ios`는 `io-server`의 약어입니다.
122
-
123
- ```
124
- % ios -l 7777 -s message
125
- ...
126
-
127
- #1(undefined) [ CID_REQ ] <Buffer c1>
128
- #1(?ayTp) [ SIGNAL ] <Buffer d0 02 68 69 00>
129
- #1(?ayTp) [ PING ] <Buffer cd>
130
-
131
- ```
132
-
133
- ### 메트릭 보기
134
-
135
- - `-m 1`: 채널, 클라이언트 및 트래픽을 표시합니다.
136
- - `-m 2`: 클라이언트를 표시합니다.
137
- - `-m 3`: 채널을 표시합니다.
138
-
139
- ```sh
140
-
141
- $ ios -l 7777 -m 1
142
- ...
143
-
144
- monitor metric type: 1
145
- ┌─────────┬───────────┬───────────┬──────────┬──────────┬──────────────┐
146
- │ (index) │ rss │ heapTotal │ heapUsed │ external │ arrayBuffers │
147
- ├─────────┼───────────┼───────────┼──────────┼──────────┼──────────────┤
148
- │ 0 │ 108232704 │ 57294848 │ 24523112 │ 1389925 │ 59260 │
149
- └─────────┴───────────┴───────────┴──────────┴──────────┴──────────────┘
150
- ┌─────────┬──────────┬─────────┬──────────┬─────────┬─────────┐
151
- │ (index) │ lastSSID │ remotes │ channels │ txBytes │ rxBytes │
152
- ├─────────┼──────────┼─────────┼──────────┼─────────┼─────────┤
153
- │ 0 │ 2 │ 2 │ 1 │ 57 │ 18 │
154
- └─────────┴──────────┴─────────┴──────────┴─────────┴─────────┘
155
-
156
-
157
- $ ios -l 7777 -m 2
158
- ...
159
- monitor metric type: 2
160
- ┌─────────┬───────────────┐
161
- │ (index) │ Values │
162
- ├─────────┼───────────────┤
163
- │ 0 │ '#1:?9P-i(7)' │
164
- │ 1 │ '#2:?zNuW(7)' │
165
- └─────────┴───────────────┘
166
-
167
-
168
- $ ios -l 7777 -m 3
169
- ...
170
- monitor metric type: 3
171
- ┌─────────┬───────────────────────┐
172
- │ (index) │ Values │
173
- ├─────────┼───────────────────────┤
174
- │ 0 │ 'PRIVATE:#homeButton' │
175
- └─────────┴───────────────────────┘
176
- ```
177
-
178
- ## IOSignal 클라이언트
179
-
180
- - `io-client` 명령을 사용합니다.
181
- - `io`는 `io-client`의 약어입니다.
182
-
183
- ### 사용법
184
-
185
- ```
186
- % io -h
187
- Usage: io [options] (--connect <url> )
188
-
189
- Options:
190
- -V, --version output the version number
191
- -t, --timeout <milliseconds> ping period & timeout
192
- -c, --connect <url> connect to a server
193
- -i, --id <id> userId
194
- -k, --key <key> userKey
195
- -a, --auth-idKey <idkey> auth id.key
196
- -j, --join-channel <channelName> join to channel
197
- -h, --help display help for command
198
-
199
- ```
200
-
201
- ### 연결
202
-
203
- - 서버에 연결하려면 `-c` 옵션을 사용하여 서버 주소와 포트 번호를 지정합니다.
204
- - 서버 주소는 다음 프로토콜 중 하나를 필요로 합니다: `ws`, `wss`, 또는 `cong`.
205
- - `ws://url:port` (WebSocket)
206
- - `localhost`의 경우 `ws://`는 생략할 수 있습니다.
207
- - `wss://url:port` (WebSocket TLS)
208
- - `cong://url:port` (CongSocket)
209
-
210
- ```sh
211
- % io -c ws://localhost:7777
212
- { connect: 'ws://localhost:7777' }
213
- Connecting to ws://localhost:7777
214
- ready: cid: ?cybL
215
- >
216
-
217
- ```
218
-
219
- ```sh
220
- % io -c cong://localhost:8888
221
- { connect: 'cong://localhost:8888' }
222
- Connecting to cong://localhost:8888
223
- ready: cid: ?yVAQ
224
- >
225
-
226
- ```
227
-
228
- - 클라이언트 연결에 성공하면 `cid` (통신 ID)가 `ready` 표시와 함께 표시됩니다.
229
- - CID는 서버에서 발급하는 고유한 통신 ID입니다.
230
- - 인증되지 않은 클라이언트의 CID는 연결할 때마다 변경됩니다.
231
- - 인증된 클라이언트는 고정된 사전 정의된 CID를 사용합니다.
232
- - CID를 사용하여 일대일 통신 또는 CID 구독을 할 수 있습니다.
233
-
234
- ### `io-client` CLI 명령 목록
235
-
236
- - `io-client` CLI 프로그램을 사용하여 서버에 연결하면 아래 명령을 사용하여 통신하고, 구독하고, 시그널을 발행할 수 있습니다.
237
- - CLI 프로그램은 서버에 연결된 브라우저 및 Arduino 장치와도 통신할 수 있습니다.
238
-
239
- ```
240
- io-client cli commands:
241
- .sig
242
- .signal .publish .pub is the same as .sig.
243
- .sub
244
- .subscribe is the same as .sub.
245
- .listen : subscirbe and print the received messages to the screen.
246
- .unsub
247
- .ping
248
- .pong
249
- .id
250
- .iam
251
- .open
252
- .connect
253
- .close
254
- .login
255
- .auth
256
- .quit
257
- .exit
258
- ```
259
-
260
- ## 튜토리얼
261
-
262
- ### 시그널링
263
-
264
- - **멀티캐스트**: 채널 이름을 구독/발행합니다.
265
- - **유니캐스트**: CID (통신 ID)를 사용합니다.
266
-
267
- 1. 서버 시작:
268
- ```sh
269
- $ io-server -l 7777
270
-
271
- ```
272
-
273
- 2. 클라이언트 A 시작:
274
-
275
- ```sh
276
- $ io -c localhost:7777
277
- Connecting to ws://localhost:7777
278
- ready: cid: ?c3Nr
279
-
280
- > .subscribe channel_name
281
- # 채널 구독
282
- ```
283
-
284
- 3. 클라이언트 B 시작:
285
- ```sh
286
- $ io -c localhost:7777
287
- Connecting to ws://localhost:7777
288
- ready: cid: ?rr75
289
- >
290
- # 멀티캐스트.
291
- > .signal channel_name some_message
292
-
293
- # A에게 유니캐스트.
294
- > .signal ?c3Nr@ direct_message
295
- # 중요: 유니캐스트 시그널 태그에는 '@' 문자가 포함되어야 합니다 (예: tag = 'cid' + @).
296
- ```
297
-
298
- ### 인증
299
-
300
- #### 유형 1: 파일에서 인증 데이터
301
-
302
- - 개인 용도로만 사용합니다.
303
- - 원시, 일반 비밀번호 문자열 (해시되지 않음).
304
- - 각 장치에는 `deviceId`, `deviceKey`, `deviceCId`, `level`의 네 가지 값이 있습니다.
305
- - 루트 폴더에서 샘플 `auth_file.js` 및 `auth_file.json`을 찾을 수 있습니다.
306
- ```sh
307
- $ io-server -l 7777 -d auth_file.json
308
- or
309
- $ io-server -l 7777 -d auth_file.js
310
- ```
311
-
312
- `auth_file.json` 구조:
313
- - `deviceId` 문자열 길이 제한: 8자.
314
- - 비밀번호 문자열 길이 제한 없음 (SHA256으로 32바이트로 다이제스트됨).
315
- - `CID` 문자열 길이 제한: 현재 20자 (변경 가능).
316
- - JSON 파일은 주석을 지원하지 않습니다.
317
- ```js
318
- [
319
- ["id","key","cid",0],
320
- ["did2","did2key","did2-cid",0],
321
- ["uno3","uno3-key","uno3-cid",1]
322
- ]
323
- ```
324
-
325
- ### `auth_file.js`
326
-
327
- - 주석을 지원합니다.
328
-
329
- ```js
330
- // *.mjs file support comments.
331
- export const authInfo = [
332
- // device id, key, communication id, level:Number(0~255)
333
- ["did","passowrd","cid",0],
334
- ["device1","device1_key","device1_cid",0],
335
- ["root","root-key","root-cid",255], // default admin_root level is 255
336
- ["uno","uno-key","uno",1]
337
- ]
338
- ```
339
-
340
- #### 유형 2: Redis (또는 기타 데이터베이스)에서 인증 데이터
341
-
342
- - 권장됩니다.
343
- - 소스 코드 및 예제는 다음에서 찾을 수 있습니다:
344
- - `iosignal`: `/src/auth/`
345
- - `iosignal-cli`: `/test_auth_redis/`
346
-
347
- 서버를 실행하기 전에 Redis 서버가 작동 중이고 장치 자격 증명을 등록했는지 확인하십시오. 간단한 자격 증명 등록 예제는 위 소스에 포함되어 있습니다.
348
-
349
- 로컬 Redis 인증 시스템으로 서버 시작
350
- ```sh
351
- $ io-server -l 7777 -r # redis://localhost:6379
352
- ```
353
-
354
- ### 클라이언트 인증
355
- 1. 인증 서버를 시작합니다.
356
- 2. 연결하고 로그인합니다.
357
-
358
- ```sh
359
- $ io -c localhost:7777
360
- ready: cid: ?YXDr
361
- > .login uno3 uno3-key
362
- try manual login: uno3
363
- > >> QUOTA_LEVEL : 1
364
- current quota: {"signalSize":255,"publishCounter":10,"trafficRate":100000}
365
- ready: cid: uno3-cid
366
-
367
- - 이제 장치에 (사전 등록된) CID가 있습니다.
368
-
369
- ```
370
-
371
- ## 웹 브라우저 및 Arduino 동시 지원
372
-
373
- ### 두 가지 유형의 포트 지정
374
-
375
- IOSignal은 웹 브라우저 피어 연결에 WebSocket을 사용합니다. Arduino 연결을 사용하려면 `-L` 옵션을 사용하여 CongSocket 포트를 지정해야 합니다.
376
-
377
- `-l` 옵션은 WebSocket 포트를 지정하고, `-L` 옵션은 Arduino 연결을 위한 CongSocket 포트를 지정합니다.
378
-
379
- ```sh
380
-
381
- $ io-server -l 7777 -L 8888
382
- # -l 옵션은 WebSocket 포트용
383
- # -L 옵션은 CongSocket 포트용 (Arduino 연결)
384
- ```
385
-
386
- ### 로컬 네트워크 IP 주소
387
-
388
- 로컬 네트워크에서 서버에 액세스하기 위해 서버의 IP 주소가 필요한 경우 다음 명령을 사용하여 확인할 수 있습니다:
389
-
390
- ```sh
391
- $ ioip
392
- 192.168.0.72
393
- ```
394
-
395
- ### IOSignal Arduino 라이브러리
396
-
397
- Arduino 라이브러리 관리자에서 `IOSignal`을 검색하여 설치하거나, [`iosignal-arduino`](https://github.com/remocons/iosignal-arduino) GitHub 저장소를 참조하십시오.
398
-
399
- ## iosignal 스택
400
- ![IOSignal](./img/iosignal_architecture.png)
@@ -1,32 +0,0 @@
1
- import { Auth_Redis } from 'iosignal'
2
- import { createClient } from 'redis';
3
-
4
- let redisClient = createClient();
5
- redisClient.on('error', (err) => console.log('Redis Client Error', err));
6
- redisClient.connect();
7
-
8
- let auth = new Auth_Redis( redisClient)
9
-
10
- //addUSer(did,dkey,cid,level)
11
- if( process.argv.length != 5 ){
12
- console.log('=> $ node addAdmin.js id key cid')
13
- process.exit()
14
- }
15
-
16
- let did = process.argv[2]
17
- let dkey = process.argv[3]
18
- let cid = process.argv[4]
19
-
20
- let addResult = await auth.addAuth( did, dkey, cid ,255)
21
- let getResult = await auth.getAuth( did )
22
- let saveResult = await auth.save();
23
-
24
- console.log('add',addResult )
25
- console.log('get',getResult)
26
- console.log('data.key',getResult.key)
27
- console.log('save result', saveResult)
28
-
29
- process.exit()
30
-
31
-
32
-
@@ -1,29 +0,0 @@
1
- import { Auth_Redis } from 'iosignal'
2
- import { createClient } from 'redis';
3
-
4
- let redisClient = createClient();
5
- redisClient.on('error', (err) => console.log('Redis Client Error', err));
6
- redisClient.connect();
7
-
8
- let auth = new Auth_Redis( redisClient)
9
-
10
- // node filename base_id level number
11
- // node uno 1 10
12
- //addUSer(did,dey,cid,level)
13
- let baseId = process.argv[2] ? process.argv[2] : 'uno'
14
- let level = process.argv[3] ? process.argv[3] : 1;
15
- let n = process.argv[4] ? process.argv[4] : 10;
16
-
17
- console.log( baseId, n )
18
- for(let i=0; i< n ;i++){
19
- let id = baseId + i;
20
- let addResult = await auth.addAuth( id, id, id ,level)
21
- console.log('add',addResult )
22
- }
23
-
24
- await auth.save();
25
-
26
- process.exit()
27
-
28
-
29
-
@@ -1,24 +0,0 @@
1
- import { Auth_Redis } from 'iosignal'
2
- import { createClient } from 'redis';
3
-
4
- let redisClient = createClient();
5
- redisClient.on('error', (err) => console.log('Redis Client Error', err));
6
- redisClient.connect();
7
-
8
- let auth = new Auth_Redis( redisClient)
9
-
10
- //addUSer(did,dey,cid,level)
11
- let addResult = await auth.addAuth('uno','uno','uno',1)
12
- let getResult = await auth.getAuth('uno')
13
- let wrongResult = await auth.getAuth('noid')
14
-
15
- console.log('add',addResult )
16
- console.log('get',getResult)
17
- console.log('data.key',getResult.key)
18
- console.log('wrongResult',wrongResult)
19
- console.log('wrongResult.key',wrongResult?.key)
20
-
21
- process.exit()
22
-
23
-
24
-
@@ -1,12 +0,0 @@
1
- import { Auth_Redis , serverOption , Server } from 'iosignal'
2
- import { createClient } from 'redis';
3
-
4
- let redisClient = createClient();
5
- redisClient.on('error', (err) => console.log('Redis Client Error', err));
6
- redisClient.connect();
7
-
8
- let authManager = new Auth_Redis( redisClient)
9
-
10
- serverOption.showMessage = 'message';
11
- const server = new Server( serverOption ,authManager )
12
- console.log( 'serverOption:', serverOption )