iosignal-cli 4.0.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
@@ -133,12 +130,12 @@ opening CongSocket Server: 8888
133
130
  ```
134
131
 
135
132
 
136
- ## IOSignal Client
133
+ ## IOSignal 클라이언트
137
134
 
138
- - Use the `io-client` command.
139
- - `io` is a shorthand alias for `io-client`.
135
+ - `io-client` 명령을 사용합니다.
136
+ - `io`는 `io-client`의 약어입니다.
140
137
 
141
- ### Usage
138
+ ### 사용법
142
139
 
143
140
  ```
144
141
  % io -h
@@ -152,16 +149,16 @@ Options:
152
149
  -k, --key <key> userKey
153
150
  -a, --auth-idKey <idkey> auth id.key
154
151
  -j, --join-channel <channelName> join to channel
155
- -h, --help display help for command
152
+ -h, --help display help for command
156
153
 
157
154
  ```
158
155
 
159
- ### Connection
156
+ ### 연결
160
157
 
161
- - To connect to a server, specify the server address and port number using the `-c` option.
162
- - The server address requires one of the following protocols: `ws`, `wss`, or `cong`.
158
+ - 서버에 연결하려면 `-c` 옵션을 사용하여 서버 주소와 포트 번호를 지정합니다.
159
+ - 서버 주소는 다음 프로토콜 하나를 필요로 합니다: `ws`, `wss`, 또는 `cong`.
163
160
  - `ws://url:port` (WebSocket)
164
- - For `localhost`, `ws://` can be omitted.
161
+ - `localhost`의 경우 `ws://`는 생략할 있습니다.
165
162
  - `wss://url:port` (WebSocket TLS)
166
163
  - `cong://url:port` (CongSocket)
167
164
 
@@ -183,17 +180,16 @@ ready: cid: ?yVAQ
183
180
 
184
181
  ```
185
182
 
186
- - Upon successful client connection, the `cid` (Communication ID) is displayed with a `ready` indication.
187
- - The CID is a unique communication ID issued by the server.
188
- - The CID of an unauthenticated client changes with each connection.
189
- - Authenticated clients use a fixed, predefined CID.
190
- - You can use CIDs for one-to-one communication or CID subscriptions.
191
-
183
+ - 클라이언트 연결에 성공하면 `cid` (통신 ID) `ready` 표시와 함께 표시됩니다.
184
+ - CID 서버에서 발급하는 고유한 통신 ID입니다.
185
+ - 인증되지 않은 클라이언트의 CID는 연결할 때마다 변경됩니다.
186
+ - 인증된 클라이언트는 고정된 사전 정의된 CID를 사용합니다.
187
+ - CID를 사용하여 일대일 통신 또는 CID 구독을 있습니다.
192
188
 
193
- ### `io-client` CLI Command List
189
+ ### `io-client` CLI 명령 목록
194
190
 
195
- - When connected to the server with the `io-client` CLI program, you can communicate, subscribe, and issue signals using the commands below.
196
- - The CLI program can also communicate with browsers and Arduino devices connected to the server.
191
+ - `io-client` CLI 프로그램을 사용하여 서버에 연결하면 아래 명령을 사용하여 통신하고, 구독하고, 시그널을 발행할 수 있습니다.
192
+ - CLI 프로그램은 서버에 연결된 브라우저 Arduino 장치와도 통신할 있습니다.
197
193
 
198
194
  ```
199
195
  io-client cli commands:
@@ -216,21 +212,20 @@ io-client cli commands:
216
212
  .exit
217
213
  ```
218
214
 
215
+ ## 튜토리얼
219
216
 
220
- ## Tutorial
217
+ ### 시그널링
221
218
 
222
- ### Signaling
219
+ - **멀티캐스트**: 채널 이름을 구독/발행합니다.
220
+ - **유니캐스트**: CID (통신 ID)를 사용합니다.
223
221
 
224
- - **Multicast**: Publish/subscribe to a channel name.
225
- - **Unicast**: Use a CID (Communication ID).
226
-
227
- 1. Start the server:
222
+ 1. 서버 시작:
228
223
  ```sh
229
224
  $ io-server -l 7777
230
225
 
231
226
  ```
232
227
 
233
- 2. Start client A:
228
+ 2. 클라이언트 A 시작:
234
229
 
235
230
  ```sh
236
231
  $ io -c localhost:7777
@@ -238,85 +233,89 @@ Connecting to ws://localhost:7777
238
233
  ready: cid: ?c3Nr
239
234
 
240
235
  > .subscribe channel_name
241
- # Subscribe to a channel
236
+ # 채널 구독
242
237
  ```
243
238
 
244
- 3. Start client B:
239
+ 3. 클라이언트 B 시작:
245
240
  ```sh
246
241
  $ io -c localhost:7777
247
242
  Connecting to ws://localhost:7777
248
243
  ready: cid: ?rr75
249
244
  >
250
- # Multicast.
245
+ # 멀티캐스트.
251
246
  > .signal channel_name some_message
252
247
 
253
- # Unicast to A.
248
+ # A에게 유니캐스트.
254
249
  > .signal ?c3Nr@ direct_message
255
- # IMPORTANT: Unicast signal tags must include the '@' character (e.g., tag = 'cid' + @).
250
+ # 중요: 유니캐스트 시그널 태그에는 '@' 문자가 포함되어야 합니다 (예: tag = 'cid' + @).
256
251
  ```
257
252
 
258
- ### Authentication
253
+ ### 인증
254
+
255
+ #### 유형 1: 파일에서 인증 데이터
259
256
 
260
- #### Type 1: Authentication Data from File
257
+ - 개인 용도로만 사용합니다.
258
+ - 원시, 일반 비밀번호 문자열 (해시되지 않음).
259
+ - 각 장치에는 `deviceId`, `deviceKey`, `deviceCId`, `level`의 네 가지 값이 있습니다.
260
+ - auth_file_sample 폴더에서 `auth_file.js` 및 `auth_file.json` sample 을 찾을 수 있습니다.
261
261
 
262
- - For personal use only.
263
- - Raw, plain password strings (not hashed).
264
- - Each device has four values: `deviceId`, `deviceKey`, `deviceCId`, and `level`.
265
- - You can find sample `auth_file.js` and `auth_file.json` in the root folder.
266
262
  ```sh
267
263
  $ io-server -l 7777 -d auth_file.json
268
264
  or
269
265
  $ io-server -l 7777 -d auth_file.js
270
266
  ```
271
267
 
272
- auth_file.json structure:
273
- - `deviceId` string size limit: 8 characters.
274
- - No passphrase string limit (it will be digested to 32 bytes with SHA256).
275
- - `CID` string size limit: currently 20 characters (can be changed).
276
- - JSON files do not support comments.
268
+ `auth_file.json` 구조:
269
+ - `deviceId` 문자열 길이 제한: 8자.
270
+ - 비밀번호 문자열 길이 제한 없음 (SHA256으로 32바이트로 다이제스트됨).
271
+ - `CID` 문자열 길이 제한: 현재 20 (변경 가능).
272
+ - JSON 파일은 주석을 지원하지 않습니다.
277
273
  ```js
278
274
  [
279
- ["id","key","cid",0],
280
- ["did2","did2key","did2-cid",0],
281
- ["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]
282
280
  ]
281
+
282
+
283
283
  ```
284
284
 
285
285
  ### `auth_file.js`
286
286
 
287
- - Supports comments.
287
+ - 주석을 지원합니다.
288
288
 
289
289
  ```js
290
290
  // *.mjs file support comments.
291
291
  export const authInfo = [
292
- // device id, key, communication id, level:Number(0~255)
293
- ["did","passowrd","cid",0],
294
- ["device1","device1_key","device1_cid",0],
295
- ["root","root-key","root-cid",255], // default admin_root level is 255
296
- ["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],
297
297
  ]
298
- ```
299
298
 
300
299
 
300
+ ```
301
301
 
302
- #### Type 2: Authentication Data from Redis (or other Database)
302
+ #### 유형 2: Redis (또는 기타 데이터베이스)에서 인증 데이터
303
303
 
304
- - Recommended.
305
- - You can find source code and examples here:
304
+ - 권장됩니다.
305
+ - 소스 코드 예제는 다음에서 찾을 있습니다:
306
306
  - `iosignal`: `/src/auth/`
307
307
  - `iosignal-cli`: `/test_auth_redis/`
308
308
 
309
- 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 서버가 작동 중이고 장치 자격 증명을 등록했는지 확인하십시오. 간단한 자격 증명 등록 예제는 소스에 포함되어 있습니다.
310
310
 
311
- start server with local redis-auth-system
311
+ 로컬 Redis 인증 시스템으로 서버 시작
312
312
  ```sh
313
313
  $ io-server -l 7777 -r # redis://localhost:6379
314
314
  ```
315
315
 
316
-
317
- ### Authenticating Clients
318
- 1. Start the authentication server.
319
- 2. Connect and log in.
316
+ ### 클라이언트 인증
317
+ 1. 인증 서버를 시작합니다.
318
+ 2. 연결하고 로그인합니다.
320
319
 
321
320
  ```sh
322
321
  $ io -c localhost:7777
@@ -327,39 +326,37 @@ try manual login: uno3
327
326
  current quota: {"signalSize":255,"publishCounter":10,"trafficRate":100000}
328
327
  ready: cid: uno3-cid
329
328
 
330
- - Now the device has a (pre-registered) CID.
329
+ - 이제 장치에 (사전 등록된) CID가 있습니다.
331
330
 
332
331
  ```
333
332
 
334
- ## Support for Both Web Browsers and Arduino
333
+ ## 브라우저 Arduino 동시 지원
335
334
 
336
- ### Specifying Two Types of Ports
335
+ ### 가지 유형의 포트 지정
337
336
 
338
- 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 포트를 지정해야 합니다.
339
338
 
340
- The `-l` option specifies the WebSocket port, and the `-L` option specifies the CongSocket port for Arduino connections.
339
+ `-l` 옵션은 WebSocket 포트를 지정하고, `-L` 옵션은 Arduino 연결을 위한 CongSocket 포트를 지정합니다.
341
340
 
342
341
  ```sh
343
342
 
344
343
  $ io-server -l 7777 -L 8888
345
- # -l option for WebSocket port
346
- # -L option for CongSocket port ( Arduino connection)
344
+ # -l 옵션은 WebSocket 포트용
345
+ # -L 옵션은 CongSocket 포트용 (Arduino 연결)
347
346
  ```
348
347
 
349
- ### Local Network IP Address
348
+ ### 로컬 네트워크 IP 주소
350
349
 
351
- 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 주소가 필요한 경우 다음 명령을 사용하여 확인할 있습니다:
352
351
 
353
352
  ```sh
354
353
  $ ioip
355
354
  192.168.0.72
356
355
  ```
357
356
 
357
+ ### IOSignal Arduino 라이브러리
358
358
 
359
- ### IOSignal Arduino Library
360
-
361
- 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.
362
-
359
+ Arduino 라이브러리 관리자에서 `IOSignal`을 검색하여 설치하거나, [`iosignal-arduino`](https://github.com/remocons/iosignal-arduino) GitHub 저장소를 참조하십시오.
363
360
 
364
- ## iosignal stack
361
+ ## iosignal 스택
365
362
  ![IOSignal](./img/iosignal_architecture.png)
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": "4.0.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": "^4.0.0",
24
+ "iosignal": "^4.5.0",
25
25
  "redis": "4.7.1"
26
26
  },
27
27
  "repository": {
package/README.ko.md DELETED
@@ -1,356 +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
- ## IOSignal 클라이언트
135
-
136
- - `io-client` 명령을 사용합니다.
137
- - `io`는 `io-client`의 약어입니다.
138
-
139
- ### 사용법
140
-
141
- ```
142
- % io -h
143
- Usage: io [options] (--connect <url> )
144
-
145
- Options:
146
- -V, --version output the version number
147
- -t, --timeout <milliseconds> ping period & timeout
148
- -c, --connect <url> connect to a server
149
- -i, --id <id> userId
150
- -k, --key <key> userKey
151
- -a, --auth-idKey <idkey> auth id.key
152
- -j, --join-channel <channelName> join to channel
153
- -h, --help display help for command
154
-
155
- ```
156
-
157
- ### 연결
158
-
159
- - 서버에 연결하려면 `-c` 옵션을 사용하여 서버 주소와 포트 번호를 지정합니다.
160
- - 서버 주소는 다음 프로토콜 중 하나를 필요로 합니다: `ws`, `wss`, 또는 `cong`.
161
- - `ws://url:port` (WebSocket)
162
- - `localhost`의 경우 `ws://`는 생략할 수 있습니다.
163
- - `wss://url:port` (WebSocket TLS)
164
- - `cong://url:port` (CongSocket)
165
-
166
- ```sh
167
- % io -c ws://localhost:7777
168
- { connect: 'ws://localhost:7777' }
169
- Connecting to ws://localhost:7777
170
- ready: cid: ?cybL
171
- >
172
-
173
- ```
174
-
175
- ```sh
176
- % io -c cong://localhost:8888
177
- { connect: 'cong://localhost:8888' }
178
- Connecting to cong://localhost:8888
179
- ready: cid: ?yVAQ
180
- >
181
-
182
- ```
183
-
184
- - 클라이언트 연결에 성공하면 `cid` (통신 ID)가 `ready` 표시와 함께 표시됩니다.
185
- - CID는 서버에서 발급하는 고유한 통신 ID입니다.
186
- - 인증되지 않은 클라이언트의 CID는 연결할 때마다 변경됩니다.
187
- - 인증된 클라이언트는 고정된 사전 정의된 CID를 사용합니다.
188
- - CID를 사용하여 일대일 통신 또는 CID 구독을 할 수 있습니다.
189
-
190
- ### `io-client` CLI 명령 목록
191
-
192
- - `io-client` CLI 프로그램을 사용하여 서버에 연결하면 아래 명령을 사용하여 통신하고, 구독하고, 시그널을 발행할 수 있습니다.
193
- - CLI 프로그램은 서버에 연결된 브라우저 및 Arduino 장치와도 통신할 수 있습니다.
194
-
195
- ```
196
- io-client cli commands:
197
- .sig
198
- .signal .publish .pub is the same as .sig.
199
- .sub
200
- .subscribe is the same as .sub.
201
- .listen : subscirbe and print the received messages to the screen.
202
- .unsub
203
- .ping
204
- .pong
205
- .id
206
- .iam
207
- .open
208
- .connect
209
- .close
210
- .login
211
- .auth
212
- .quit
213
- .exit
214
- ```
215
-
216
- ## 튜토리얼
217
-
218
- ### 시그널링
219
-
220
- - **멀티캐스트**: 채널 이름을 구독/발행합니다.
221
- - **유니캐스트**: CID (통신 ID)를 사용합니다.
222
-
223
- 1. 서버 시작:
224
- ```sh
225
- $ io-server -l 7777
226
-
227
- ```
228
-
229
- 2. 클라이언트 A 시작:
230
-
231
- ```sh
232
- $ io -c localhost:7777
233
- Connecting to ws://localhost:7777
234
- ready: cid: ?c3Nr
235
-
236
- > .subscribe channel_name
237
- # 채널 구독
238
- ```
239
-
240
- 3. 클라이언트 B 시작:
241
- ```sh
242
- $ io -c localhost:7777
243
- Connecting to ws://localhost:7777
244
- ready: cid: ?rr75
245
- >
246
- # 멀티캐스트.
247
- > .signal channel_name some_message
248
-
249
- # A에게 유니캐스트.
250
- > .signal ?c3Nr@ direct_message
251
- # 중요: 유니캐스트 시그널 태그에는 '@' 문자가 포함되어야 합니다 (예: tag = 'cid' + @).
252
- ```
253
-
254
- ### 인증
255
-
256
- #### 유형 1: 파일에서 인증 데이터
257
-
258
- - 개인 용도로만 사용합니다.
259
- - 원시, 일반 비밀번호 문자열 (해시되지 않음).
260
- - 각 장치에는 `deviceId`, `deviceKey`, `deviceCId`, `level`의 네 가지 값이 있습니다.
261
- - 루트 폴더에서 샘플 `auth_file.js` 및 `auth_file.json`을 찾을 수 있습니다.
262
- ```sh
263
- $ io-server -l 7777 -d auth_file.json
264
- or
265
- $ io-server -l 7777 -d auth_file.js
266
- ```
267
-
268
- `auth_file.json` 구조:
269
- - `deviceId` 문자열 길이 제한: 8자.
270
- - 비밀번호 문자열 길이 제한 없음 (SHA256으로 32바이트로 다이제스트됨).
271
- - `CID` 문자열 길이 제한: 현재 20자 (변경 가능).
272
- - JSON 파일은 주석을 지원하지 않습니다.
273
- ```js
274
- [
275
- ["id","key","cid",0],
276
- ["did2","did2key","did2-cid",0],
277
- ["uno3","uno3-key","uno3-cid",1]
278
- ]
279
- ```
280
-
281
- ### `auth_file.js`
282
-
283
- - 주석을 지원합니다.
284
-
285
- ```js
286
- // *.mjs file support comments.
287
- export const authInfo = [
288
- // device id, key, communication id, level:Number(0~255)
289
- ["did","passowrd","cid",0],
290
- ["device1","device1_key","device1_cid",0],
291
- ["root","root-key","root-cid",255], // default admin_root level is 255
292
- ["uno","uno-key","uno",1]
293
- ]
294
- ```
295
-
296
- #### 유형 2: Redis (또는 기타 데이터베이스)에서 인증 데이터
297
-
298
- - 권장됩니다.
299
- - 소스 코드 및 예제는 다음에서 찾을 수 있습니다:
300
- - `iosignal`: `/src/auth/`
301
- - `iosignal-cli`: `/test_auth_redis/`
302
-
303
- 서버를 실행하기 전에 Redis 서버가 작동 중이고 장치 자격 증명을 등록했는지 확인하십시오. 간단한 자격 증명 등록 예제는 위 소스에 포함되어 있습니다.
304
-
305
- 로컬 Redis 인증 시스템으로 서버 시작
306
- ```sh
307
- $ io-server -l 7777 -r # redis://localhost:6379
308
- ```
309
-
310
- ### 클라이언트 인증
311
- 1. 인증 서버를 시작합니다.
312
- 2. 연결하고 로그인합니다.
313
-
314
- ```sh
315
- $ io -c localhost:7777
316
- ready: cid: ?YXDr
317
- > .login uno3 uno3-key
318
- try manual login: uno3
319
- > >> QUOTA_LEVEL : 1
320
- current quota: {"signalSize":255,"publishCounter":10,"trafficRate":100000}
321
- ready: cid: uno3-cid
322
-
323
- - 이제 장치에 (사전 등록된) CID가 있습니다.
324
-
325
- ```
326
-
327
- ## 웹 브라우저 및 Arduino 동시 지원
328
-
329
- ### 두 가지 유형의 포트 지정
330
-
331
- IOSignal은 웹 브라우저 피어 연결에 WebSocket을 사용합니다. Arduino 연결을 사용하려면 `-L` 옵션을 사용하여 CongSocket 포트를 지정해야 합니다.
332
-
333
- `-l` 옵션은 WebSocket 포트를 지정하고, `-L` 옵션은 Arduino 연결을 위한 CongSocket 포트를 지정합니다.
334
-
335
- ```sh
336
-
337
- $ io-server -l 7777 -L 8888
338
- # -l 옵션은 WebSocket 포트용
339
- # -L 옵션은 CongSocket 포트용 (Arduino 연결)
340
- ```
341
-
342
- ### 로컬 네트워크 IP 주소
343
-
344
- 로컬 네트워크에서 서버에 액세스하기 위해 서버의 IP 주소가 필요한 경우 다음 명령을 사용하여 확인할 수 있습니다:
345
-
346
- ```sh
347
- $ ioip
348
- 192.168.0.72
349
- ```
350
-
351
- ### IOSignal Arduino 라이브러리
352
-
353
- Arduino 라이브러리 관리자에서 `IOSignal`을 검색하여 설치하거나, [`iosignal-arduino`](https://github.com/remocons/iosignal-arduino) GitHub 저장소를 참조하십시오.
354
-
355
- ## iosignal 스택
356
- ![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 )