iosignal 1.6.0 → 1.7.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.
Files changed (45) hide show
  1. package/dist/iosignal.cjs +2 -2
  2. package/dist/iosignal.esm.js +1 -1
  3. package/dist/iosignal.esm.js.map +1 -1
  4. package/dist/iosignal.min.js +1 -1
  5. package/dist/iosignal.min.js.map +1 -1
  6. package/indexWebBrowser.js +1 -1
  7. package/package.json +2 -2
  8. package/src/api/RedisAPI.js +23 -26
  9. package/src/api/api_reply.js +12 -15
  10. package/src/api/api_sudo.js +67 -72
  11. package/src/auth/Auth_Env.js +7 -9
  12. package/src/auth/Auth_File.js +31 -35
  13. package/src/auth/Auth_Redis.js +15 -21
  14. package/src/auth/BohoAuth.js +68 -72
  15. package/src/client/CongPacket.js +15 -24
  16. package/src/client/IOCongSocket.js +26 -33
  17. package/src/client/IOCore.js +6 -35
  18. package/src/client/IOWS.js +22 -23
  19. package/src/client/IOWebSocket.js +11 -7
  20. package/src/common/constants.js +21 -32
  21. package/src/common/payload.js +47 -48
  22. package/src/common/quotaTable.js +10 -10
  23. package/src/common/util.js +38 -38
  24. package/src/server/FileLogger.js +9 -9
  25. package/src/server/Manager.js +39 -55
  26. package/src/server/Metric.js +54 -53
  27. package/src/server/Remote.js +207 -0
  28. package/src/server/{ServerRemoteCore.js → RemoteCore.js} +53 -81
  29. package/src/server/Server.js +22 -25
  30. package/src/server/serverOption.js +10 -10
  31. package/test-browser/index.html +30 -26
  32. package/test-browser/server.js +1 -1
  33. package/test-client-nodejs/client.cjs +6 -6
  34. package/test-client-nodejs/client.mjs +6 -6
  35. package/test-client-nodejs/client_api_reply.mjs +8 -8
  36. package/test-client-nodejs/stateChange.mjs +7 -7
  37. package/test-server/server-Auth_Env.js +2 -2
  38. package/test-server/server-Auth_File.js +1 -1
  39. package/test-server/server-api_reply.js +2 -2
  40. package/test-server/server-api_sudo.js +3 -3
  41. package/test-server/server-esm.mjs +9 -8
  42. package/test-server/simple-server.mjs +6 -6
  43. package/test-signal-payloadType/signalPack.js +1 -1
  44. package/test-signal-payloadType/signaling.js +4 -4
  45. package/src/server/ServerRemote.js +0 -227
@@ -2,16 +2,16 @@ import { IOCore } from "./IOCore.js";
2
2
  import { WebSocket } from "ws";
3
3
 
4
4
  // Node.js 'ws' websocket
5
- export class IOWS extends IOCore{
6
- constructor(url ) {
5
+ export class IOWS extends IOCore {
6
+ constructor(url) {
7
7
  super(url);
8
- if(url) this.open();
8
+ if (url) this.open();
9
9
  }
10
10
 
11
-
11
+
12
12
 
13
13
  close() {
14
- if(this.socket ){
14
+ if (this.socket) {
15
15
  this.socket.onclose = null
16
16
  this.socket.onmessage = null
17
17
  this.socket.onerror = null
@@ -28,52 +28,51 @@ export class IOWS extends IOCore{
28
28
  clearInterval(this.connectionCheckerIntervalID);
29
29
  this.connectionCheckerIntervalID = null
30
30
  }
31
-
31
+
32
32
  keepAlive() {
33
- if ( !this.socket || this.socket?.readyState === 3 ) { //closed
33
+ if (!this.socket || this.socket?.readyState === 3) {
34
34
  this.open();
35
35
  }
36
36
  }
37
37
 
38
38
 
39
- createConnection(url){
39
+ createConnection(url) {
40
40
  // node WebSocket
41
- this.socket = new WebSocket ( url );
41
+ this.socket = new WebSocket(url);
42
42
  this.stateChange('opening')
43
43
 
44
44
  this.socket.onopen = () => {
45
- this.socket.on('message', this.onWebSocketMessage.bind(this) );
46
- this.emit('open' );
45
+ this.socket.on('message', this.onWebSocketMessage.bind(this));
46
+ this.emit('open');
47
47
  };
48
48
 
49
- this.socket.onerror = (e)=>{
49
+ this.socket.onerror = (e) => {
50
50
  this.emit('error', e)
51
51
  }
52
52
 
53
- this.socket.onclose = ()=>{
54
- this.emit('close' );
53
+ this.socket.onclose = () => {
54
+ this.emit('close');
55
55
  }
56
56
  }
57
57
 
58
- onWebSocketMessage( data ) {
58
+ onWebSocketMessage(data) {
59
59
  this.rxCounter++;
60
60
  this.lastTxRxTime = Date.now();
61
61
  this.rxBytes += data.byteLength
62
- this.emit('socket_data', data );
62
+ this.emit('socket_data', data);
63
63
  }
64
64
 
65
- socket_send(data) {
66
- if( this.socket?.readyState === 1 ){ //open
67
- // console.log('websocket send', data)
68
- this.socket.send( data )
65
+ socket_send(data) {
66
+ if (this.socket?.readyState === 1) {
67
+ this.socket.send(data)
69
68
  this.txCounter++;
70
69
  this.txBytes += data.byteLength
71
70
  this.lastTxRxTime = Date.now();
72
- }else{
73
- console.log('')
71
+ } else {
72
+ console.log('.')
74
73
  }
75
74
  }
76
-
75
+
77
76
  }
78
77
 
79
78
 
@@ -40,7 +40,7 @@ export class IO extends IOCore {
40
40
 
41
41
 
42
42
  keepAlive() {
43
- if (!this.socket || this.socket?.readyState === 3) { //closed
43
+ if (!this.socket || this.socket?.readyState === 3) {
44
44
  this.open();
45
45
  }
46
46
  }
@@ -73,7 +73,7 @@ export class IO extends IOCore {
73
73
  }
74
74
 
75
75
  onWebSocketMessage(event) {
76
- // event.data is arrayBuffer
76
+ // event.data is arrayBuffer or text_message
77
77
  this.rxCounter++;
78
78
  this.lastTxRxTime = Date.now();
79
79
  let buffer = Buffer.from(event.data)
@@ -82,18 +82,22 @@ export class IO extends IOCore {
82
82
  }
83
83
 
84
84
  async onWebSocketMessageBlob(event) {
85
- // event.data is Blob
85
+ // event.data is Blob or text_message
86
86
  this.rxCounter++;
87
87
  this.lastTxRxTime = Date.now();
88
- let ab = await event.data.arrayBuffer()
89
- let buffer = Buffer.from(ab)
88
+ let buffer;
89
+ if (event.data instanceof Blob) {
90
+ let ab = await event.data.arrayBuffer()
91
+ buffer = Buffer.from(ab)
92
+ } else {
93
+ buffer = Buffer.from(event.data)
94
+ }
90
95
  this.rxBytes += buffer.byteLength
91
96
  this.emit('socket_data', buffer);
92
97
  }
93
98
 
94
99
  socket_send(data) {
95
- if (this.socket?.readyState === 1) { //open
96
- // console.log('websocket send', data)
100
+ if (this.socket?.readyState === 1) {
97
101
  this.socket.send(data)
98
102
  this.txCounter++;
99
103
  this.txBytes += data.byteLength
@@ -1,5 +1,5 @@
1
1
 
2
- // IOclient state
2
+ // Client STATES: name and number
3
3
  export const STATES = {
4
4
  OPENING: 0,
5
5
  OPEN: 1,
@@ -45,24 +45,17 @@ export const SIZE_LIMIT = {
45
45
  }
46
46
 
47
47
  export let PAYLOAD_TYPE = {
48
- EMPTY: 0,
48
+ EMPTY: 0,
49
49
  TEXT: 1,
50
- BINARY: 2,
51
- OBJECT: 3, // one stringify able object. no buffer.
52
- MJSON: 4, // multiple stringify able obejct. JSON string. with top levle array , no buffer
53
- MBA: 5 // "meta_buffer_arguments" arbitary types. buffer included.
50
+ BINARY: 2,
51
+ OBJECT: 3, // one stringifiable object. it's string.
52
+ MJSON: 4, // multiple stringifiable obejct. it's top-level array JSON string.
53
+ MBA: 5 // "meta_buffer_arguments" arbitary types. it's meta-buffer-pack.
54
54
  }
55
55
  for (let c in PAYLOAD_TYPE) { PAYLOAD_TYPE[PAYLOAD_TYPE[c]] = c }
56
- // console.log( PAYLOAD_TYPE )
57
56
 
58
- // MJSON: multiple arguments
59
- // accepet only string, number, root depth js primittive object,
60
- // unpack and will send to receiver handler with multiple params.
61
57
 
62
- // MBA: buffer pack of multiple arguments. check "meta-buffer-pack" module.
63
- // MBA: when armuents includes raw Buffer( TypedArray )
64
-
65
- // IO message pack one byte header.
58
+ // IO message's one-byte headers.
66
59
  export let IOMsg = {
67
60
 
68
61
  /*
@@ -71,7 +64,7 @@ export let IOMsg = {
71
64
  * 32~126: ascii charactor
72
65
  * 127: DEL
73
66
  */
74
-
67
+
75
68
  // ADMIN_REQ: 0xA0,
76
69
 
77
70
  // DO NOT USE: 0xB0~ 0xBF
@@ -89,38 +82,38 @@ export let IOMsg = {
89
82
 
90
83
  // C. IO status contorl.
91
84
  SERVER_READY: 0xC0,
92
- CID_REQ: 0xC1,
93
- CID_RES: 0xC2,
85
+ CID_REQ: 0xC1,
86
+ CID_RES: 0xC2,
94
87
  QUOTA_LEVEL: 0xC3,
95
- SERVER_CLEAR_AUTH: 0xC4,
88
+ SERVER_CLEAR_AUTH: 0xC4,
96
89
  SERVER_REDIRECT: 0xC5,
97
90
 
98
91
  // ..
99
92
  LOOP: 0xCB,
100
93
  ECHO: 0xCC,
101
- PING: 0xCD,
94
+ PING: 0xCD,
102
95
  PONG: 0xCE,
103
96
  CLOSE: 0xCF,
104
97
  // ~CF
105
98
 
106
99
 
107
100
  // D. IO data signaling
108
- SIGNAL: 0xD0,
109
- SIGNAL_REQ: 0xD1,
110
- SIGNAL_E2E: 0xD2,
101
+ SIGNAL: 0xD0,
102
+ SIGNAL_REQ: 0xD1,
103
+ SIGNAL_E2E: 0xD2,
111
104
  SUBSCRIBE: 0xD3,
112
- SUBSCRIBE_REQ: 0xD4,
113
- UNSUBSCRIBE: 0xD5,
114
- SERVER_SIGNAL: 0xD6,
105
+ SUBSCRIBE_REQ: 0xD4,
106
+ UNSUBSCRIBE: 0xD5,
107
+ SERVER_SIGNAL: 0xD6,
115
108
 
116
109
  // ..
117
110
  IAM: 0xD9,
118
111
  IAM_RES: 0xDA,
119
-
112
+
120
113
  //..
121
114
  SET: 0xDB, //
122
- RESPONSE_CODE: 0xDC,
123
- RESPONSE_MBP: 0xDD,
115
+ RESPONSE_CODE: 0xDC,
116
+ RESPONSE_MBP: 0xDD,
124
117
 
125
118
  REQUEST: 0xDE, //client public
126
119
  RESPONSE: 0xDF,
@@ -139,17 +132,13 @@ export let IOMsg = {
139
132
  }
140
133
 
141
134
  for (let c in IOMsg) { IOMsg[IOMsg[c]] = c }
142
-
143
135
  // console.log( IOMsg );
144
136
 
145
-
146
137
  export const API_TYPE = {
147
138
  'REQUEST_RESPONSE': 'requet_response',
148
139
  'ONE_WAY': 'one_way'
149
140
  }
150
141
 
151
-
152
-
153
142
  // api response status code
154
143
  export const STATUS = {
155
144
  OK: 0,
@@ -3,81 +3,80 @@ import { PAYLOAD_TYPE, IOMsg } from "./constants.js";
3
3
  const encoder = new TextEncoder()
4
4
 
5
5
 
6
- export function getSignalPack( tag, ...args ){
7
- if( typeof tag !== 'string') throw TypeError('tag should be string.')
8
- let tagEncoded = encoder.encode( tag)
9
- let payload = parsePayload( args )
6
+ export function getSignalPack(tag, ...args) {
7
+ if (typeof tag !== 'string') throw TypeError('tag should be string.')
8
+ let tagEncoded = encoder.encode(tag)
9
+ let payload = parsePayload(args)
10
10
 
11
11
  let sigPack;
12
- if( payload.type == PAYLOAD_TYPE.EMPTY ){
13
- sigPack = MBP.pack(
14
- MBP.MB('#MsgType','8', IOMsg.SIGNAL) ,
15
- MBP.MB('#tagLen','8', tagEncoded.byteLength),
12
+ if (payload.type == PAYLOAD_TYPE.EMPTY) {
13
+ sigPack = MBP.pack(
14
+ MBP.MB('#MsgType', '8', IOMsg.SIGNAL),
15
+ MBP.MB('#tagLen', '8', tagEncoded.byteLength),
16
16
  MBP.MB('#tag', tagEncoded),
17
- MBP.MB('#payloadType', '8', payload.type )
18
- )
19
- }else if( payload.type == PAYLOAD_TYPE.MBA ){
20
- let mbaBuffer = MBP.pack( MBP.MBA(...args))
21
- sigPack = MBP.pack(
22
- MBP.MB('#MsgType','8', IOMsg.SIGNAL) ,
23
- MBP.MB('#tagLen','8', tagEncoded.byteLength),
17
+ MBP.MB('#payloadType', '8', payload.type)
18
+ )
19
+ } else if (payload.type == PAYLOAD_TYPE.MBA) {
20
+ let mbaBuffer = MBP.pack(MBP.MBA(...args))
21
+ sigPack = MBP.pack(
22
+ MBP.MB('#MsgType', '8', IOMsg.SIGNAL),
23
+ MBP.MB('#tagLen', '8', tagEncoded.byteLength),
24
24
  MBP.MB('#tag', tagEncoded),
25
- MBP.MB('#payloadType', '8', payload.type ),
26
- MBP.MB('#mbaBuffer', mbaBuffer )
27
- )
28
- }else {
29
- sigPack = MBP.pack(
30
- MBP.MB('#MsgType','8', IOMsg.SIGNAL) ,
31
- MBP.MB('#tagLen','8', tagEncoded.byteLength),
25
+ MBP.MB('#payloadType', '8', payload.type),
26
+ MBP.MB('#mbaBuffer', mbaBuffer)
27
+ )
28
+ } else {
29
+ sigPack = MBP.pack(
30
+ MBP.MB('#MsgType', '8', IOMsg.SIGNAL),
31
+ MBP.MB('#tagLen', '8', tagEncoded.byteLength),
32
32
  MBP.MB('#tag', tagEncoded),
33
- MBP.MB('#payloadType', '8', payload.type ),
34
- MBP.MB('#payload', payload.buffer )
35
- )
33
+ MBP.MB('#payloadType', '8', payload.type),
34
+ MBP.MB('#payload', payload.buffer)
35
+ )
36
36
  }
37
37
  return sigPack
38
38
  }
39
39
 
40
40
 
41
- export function parsePayload( args){
41
+ export function parsePayload(args) {
42
42
  let type, pack;
43
- if( args.length == 0){
44
- type = PAYLOAD_TYPE.EMPTY
43
+ if (args.length == 0) {
44
+ type = PAYLOAD_TYPE.EMPTY
45
45
  pack = null
46
- }else if( args.length == 1){
47
- if( typeof args[0] === 'string' || typeof args[0] === 'number'){
48
- type = PAYLOAD_TYPE.TEXT
49
- pack = encoder.encode( args[0] + ".") // add null area.
50
- pack[pack.byteLength - 1 ] = 0 // set null.
46
+ } else if (args.length == 1) {
47
+ if (typeof args[0] === 'string' || typeof args[0] === 'number') {
48
+ type = PAYLOAD_TYPE.TEXT
49
+ pack = encoder.encode(args[0] + ".") // add null byte area.
50
+ pack[pack.byteLength - 1] = 0 // set byte-zero : '\0' in C/C++
51
51
 
52
- }else if( ArrayBuffer.isView( args[0]) || args[0] instanceof ArrayBuffer ){ //one buffer
52
+ } else if (ArrayBuffer.isView(args[0]) || args[0] instanceof ArrayBuffer) {
53
53
  type = PAYLOAD_TYPE.BINARY
54
- pack = MBP.B8( args[0 ] )
55
- }else if(typeof args[0] === 'object'){
54
+ pack = MBP.B8(args[0])
55
+ } else if (typeof args[0] === 'object') {
56
56
  type = PAYLOAD_TYPE.OBJECT
57
- pack = encoder.encode( JSON.stringify( args[0]) )
58
- }else{
57
+ pack = encoder.encode(JSON.stringify(args[0]))
58
+ } else {
59
59
  throw new Error('unknown payload arguments')
60
60
  }
61
- }else{ // args 2 and more
61
+ } else { // two or more arguments.
62
62
  let containsBuffer = false
63
- args.forEach( item =>{
64
- if( ArrayBuffer.isView( item ) || item instanceof ArrayBuffer ) containsBuffer = true;
63
+ args.forEach(item => {
64
+ if (ArrayBuffer.isView(item) || item instanceof ArrayBuffer) containsBuffer = true;
65
65
  })
66
66
 
67
- if( containsBuffer ){
67
+ if (containsBuffer) {
68
68
  type = PAYLOAD_TYPE.MBA;
69
- }else{
69
+ } else {
70
70
  type = PAYLOAD_TYPE.MJSON;
71
- // args is array
72
- pack = encoder.encode( JSON.stringify( args ) )
71
+ pack = encoder.encode(JSON.stringify(args))
73
72
  }
74
-
73
+
75
74
  }
76
-
75
+
77
76
  return { type: type, buffer: pack }
78
77
  }
79
78
 
80
- export function getPayloadFromSignalPack( signalPack ){
79
+ export function getPayloadFromSignalPack(signalPack) {
81
80
  let tagLen = signalPack.readUint8(1)
82
81
  return signalPack.subarray(3 + tagLen)
83
82
  }
@@ -24,42 +24,42 @@ export let quotaTable = {
24
24
 
25
25
  // WebSocket (browser and node app)
26
26
  3: { // authorized basic.
27
- signalSize: 1048576,
27
+ signalSize: 1048576,
28
28
  publishCounter: 10,
29
29
  trafficRate: 1048576 * 20
30
30
  },
31
31
 
32
32
  // WebSocket (browser and node app)
33
33
  10: { // anonymouse
34
- signalSize: 1500,
34
+ signalSize: 1500,
35
35
  publishCounter: 5,
36
36
  trafficRate: 1048576 * 20
37
37
  },
38
38
 
39
39
  11: { // authorized basic.
40
- signalSize: 65535,
40
+ signalSize: 65535,
41
41
  publishCounter: 10,
42
42
  trafficRate: 1048576 * 20
43
43
  },
44
-
44
+
45
45
  12: { // authorized power.
46
- signalSize: 1048576,
46
+ signalSize: 1048576,
47
47
  publishCounter: 100,
48
48
  trafficRate: 1048576 * 20
49
49
  },
50
-
51
- // you can add your custom quota level.
50
+
51
+ // you can add your custom quota levels.
52
52
 
53
53
  // Remote service node
54
54
  // High Quota, No root permission.
55
- 200: {
55
+ 200: {
56
56
  signalSize: 1048576 * 20,
57
57
  publishCounter: 10000,
58
58
  trafficRate: 1048576 * 100
59
59
  },
60
60
  // super admin or root user.
61
- // to monitor, metric, sudo command, db acess
62
- 255: {
61
+ // to monitor, metric, sudo command, db access.
62
+ 255: {
63
63
  signalSize: 1048576 * 20,
64
64
  publishCounter: 10000,
65
65
  trafficRate: 1048576 * 100
@@ -1,61 +1,61 @@
1
1
  import { networkInterfaces } from 'os';
2
2
 
3
- export function isPrivateIP(ip){
4
- if(ip.indexOf("0.0.0.0") === 0) return true
5
- if(ip.indexOf("127.0.0.1") === 0) return true
6
- if(ip.indexOf("192.168.") === 0) return true
7
- if(ip.indexOf("10.") === 0) return true
8
- if(ip.indexOf("172.") === 0){
9
- if(ip.indexOf("172.16.") === 0) return true
10
- if(ip.indexOf("172.17.") === 0) return true
11
- if(ip.indexOf("172.18.") === 0) return true
12
- if(ip.indexOf("172.19.") === 0) return true
13
- if(ip.indexOf("172.20.") === 0) return true
14
- if(ip.indexOf("172.21.") === 0) return true
15
- if(ip.indexOf("172.22.") === 0) return true
16
- if(ip.indexOf("172.23.") === 0) return true
17
- if(ip.indexOf("172.24.") === 0) return true
18
- if(ip.indexOf("172.25.") === 0) return true
19
- if(ip.indexOf("172.26.") === 0) return true
20
- if(ip.indexOf("172.27.") === 0) return true
21
- if(ip.indexOf("172.28.") === 0) return true
22
- if(ip.indexOf("172.29.") === 0) return true
23
- if(ip.indexOf("172.30.") === 0) return true
24
- if(ip.indexOf("172.31.") === 0) return true
3
+ export function isPrivateIP(ip) {
4
+ if (ip.indexOf("0.0.0.0") === 0) return true
5
+ if (ip.indexOf("127.0.0.1") === 0) return true
6
+ if (ip.indexOf("192.168.") === 0) return true
7
+ if (ip.indexOf("10.") === 0) return true
8
+ if (ip.indexOf("172.") === 0) {
9
+ if (ip.indexOf("172.16.") === 0) return true
10
+ if (ip.indexOf("172.17.") === 0) return true
11
+ if (ip.indexOf("172.18.") === 0) return true
12
+ if (ip.indexOf("172.19.") === 0) return true
13
+ if (ip.indexOf("172.20.") === 0) return true
14
+ if (ip.indexOf("172.21.") === 0) return true
15
+ if (ip.indexOf("172.22.") === 0) return true
16
+ if (ip.indexOf("172.23.") === 0) return true
17
+ if (ip.indexOf("172.24.") === 0) return true
18
+ if (ip.indexOf("172.25.") === 0) return true
19
+ if (ip.indexOf("172.26.") === 0) return true
20
+ if (ip.indexOf("172.27.") === 0) return true
21
+ if (ip.indexOf("172.28.") === 0) return true
22
+ if (ip.indexOf("172.29.") === 0) return true
23
+ if (ip.indexOf("172.30.") === 0) return true
24
+ if (ip.indexOf("172.31.") === 0) return true
25
25
  }
26
26
 
27
27
  return false
28
28
  }
29
29
 
30
- export function numberWithCommas (x) {
30
+ export function numberWithCommas(x) {
31
31
  return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')
32
32
  }
33
33
 
34
- export function getIPv4HexString(ipStr){
34
+ export function getIPv4HexString(ipStr) {
35
35
  let ipv4 = ipStr.split('.')
36
36
  return Buffer.from(ipv4).toString('hex')
37
37
  }
38
38
 
39
- export function getLocalAddress(){
39
+ export function getLocalAddress() {
40
40
  const nets = networkInterfaces();
41
41
  // console.log(nets)
42
42
  const results = Object.create(null); // Or just '{}', an empty object
43
- let localAddress =''
43
+ let localAddress = ''
44
44
  for (const name of Object.keys(nets)) {
45
- for (const net of nets[name]) {
46
- // Skip over non-IPv4 and internal (i.e. 127.0.0.1) addresses
47
- // 'IPv4' is in Node <= 17, from 18 it's a number 4 or 6
48
- const familyV4Value = typeof net.family === 'string' ? 'IPv4' : 4
49
- if (net.family === familyV4Value && !net.internal) {
50
- if (!results[name]) {
51
- results[name] = [];
52
- }
53
- results[name].push(net.address);
54
- localAddress = net.address
55
- }
45
+ for (const net of nets[name]) {
46
+ // Skip over non-IPv4 and internal (i.e. 127.0.0.1) addresses
47
+ // 'IPv4' is in Node <= 17, from 18 it's a number 4 or 6
48
+ const familyV4Value = typeof net.family === 'string' ? 'IPv4' : 4
49
+ if (net.family === familyV4Value && !net.internal) {
50
+ if (!results[name]) {
51
+ results[name] = [];
52
+ }
53
+ results[name].push(net.address);
54
+ localAddress = net.address
56
55
  }
56
+ }
57
57
  }
58
-
58
+
59
59
  // console.log('localAddress:', localAddress)
60
60
  return localAddress
61
61
  }
@@ -6,21 +6,21 @@ const formatter = new Intl.DateTimeFormat('ko-KR', {
6
6
  // minute: '2-digit',
7
7
  // second: '2-digit'
8
8
  year: 'numeric', month: 'numeric', day: 'numeric',
9
- hour: 'numeric', minute: 'numeric',
9
+ hour: 'numeric', minute: 'numeric',
10
10
  hour12: false,
11
11
  timeZone: 'Asia/Seoul'
12
12
  });
13
13
 
14
14
 
15
- export class FileLogger{
16
- constructor(path ){
17
- this.file = fs.openSync(path ,'a+')
18
- console.log('new logFile', path, this.file )
15
+ export class FileLogger {
16
+ constructor(path) {
17
+ this.file = fs.openSync(path, 'a+')
18
+ console.log('new FileLogger logFile: ', path, this.file)
19
19
  }
20
-
21
- log(msg){
22
- let format =formatter.format(new Date()) + " "+ msg +'\n';
23
- fs.write( this.file, format , (err) => {
20
+
21
+ log(msg) {
22
+ let format = formatter.format(new Date()) + " " + msg + '\n';
23
+ fs.write(this.file, format, (err) => {
24
24
  if (err) throw err;
25
25
  })
26
26