iosignal 1.6.1 → 1.7.1
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 +254 -247
- package/auth_file.json +13 -13
- package/auth_file.mjs +23 -23
- package/dist/iosignal.cjs +2 -2
- package/dist/iosignal.esm.js.map +1 -1
- package/dist/iosignal.min.js.map +1 -1
- package/index.js +19 -19
- package/indexWebBrowser.js +13 -13
- package/package.json +60 -59
- package/rollup.config.js +69 -69
- package/src/api/RedisAPI.js +65 -68
- package/src/api/api_constant.js +7 -7
- package/src/api/api_reply.js +31 -34
- package/src/api/api_sudo.js +91 -96
- package/src/auth/Auth_Env.js +76 -78
- package/src/auth/Auth_File.js +71 -75
- package/src/auth/Auth_Redis.js +44 -50
- package/src/auth/BohoAuth.js +164 -168
- package/src/client/CongPacket.js +141 -150
- package/src/client/IOCongSocket.js +81 -88
- package/src/client/IOCore.js +822 -851
- package/src/client/IOWS.js +80 -81
- package/src/client/IOWebSocket.js +111 -112
- package/src/common/constants.js +148 -159
- package/src/common/payload.js +81 -82
- package/src/common/quotaTable.js +68 -68
- package/src/common/util.js +61 -61
- package/src/server/FileLogger.js +30 -30
- package/src/server/Manager.js +433 -449
- package/src/server/Metric.js +155 -154
- package/src/server/Remote.js +207 -0
- package/src/server/{ServerRemoteCore.js → RemoteCore.js} +439 -467
- package/src/server/Server.js +163 -166
- package/src/server/serverOption.js +56 -56
- package/test-browser/favicon.ico +0 -0
- package/test-browser/index.html +96 -93
- package/test-browser/server.js +11 -11
- package/test-client-nodejs/client.cjs +17 -17
- package/test-client-nodejs/client.mjs +17 -17
- package/test-client-nodejs/client_api_reply.mjs +15 -15
- package/test-client-nodejs/stateChange.mjs +19 -19
- package/test-server/server-Auth_Env.js +19 -19
- package/test-server/server-Auth_File.js +12 -12
- package/test-server/server-api_reply.js +6 -6
- package/test-server/server-api_sudo.js +7 -7
- package/test-server/server-commonjs.cjs +8 -8
- package/test-server/server-esm.mjs +20 -19
- package/test-server/simple-server.mjs +11 -11
- package/test-signal-payloadType/signalPack.js +34 -34
- package/test-signal-payloadType/signaling.js +60 -60
- package/src/server/ServerRemote.js +0 -227
package/src/common/util.js
CHANGED
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
import { networkInterfaces } from 'os';
|
|
2
|
-
|
|
3
|
-
export function isPrivateIP(ip){
|
|
4
|
-
if(ip.indexOf("0.0.0.0") === 0) return
|
|
5
|
-
if(ip.indexOf("127.0.0.1") === 0) return
|
|
6
|
-
if(ip.indexOf("192.168.") === 0) return
|
|
7
|
-
if(ip.indexOf("10.") === 0) return
|
|
8
|
-
if(ip.indexOf("172.") === 0){
|
|
9
|
-
if(ip.indexOf("172.16.") === 0) return
|
|
10
|
-
if(ip.indexOf("172.17.") === 0) return
|
|
11
|
-
if(ip.indexOf("172.18.") === 0) return
|
|
12
|
-
if(ip.indexOf("172.19.") === 0) return
|
|
13
|
-
if(ip.indexOf("172.20.") === 0) return
|
|
14
|
-
if(ip.indexOf("172.21.") === 0) return
|
|
15
|
-
if(ip.indexOf("172.22.") === 0) return
|
|
16
|
-
if(ip.indexOf("172.23.") === 0) return
|
|
17
|
-
if(ip.indexOf("172.24.") === 0) return
|
|
18
|
-
if(ip.indexOf("172.25.") === 0) return
|
|
19
|
-
if(ip.indexOf("172.26.") === 0) return
|
|
20
|
-
if(ip.indexOf("172.27.") === 0) return
|
|
21
|
-
if(ip.indexOf("172.28.") === 0) return
|
|
22
|
-
if(ip.indexOf("172.29.") === 0) return
|
|
23
|
-
if(ip.indexOf("172.30.") === 0) return
|
|
24
|
-
if(ip.indexOf("172.31.") === 0) return
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return false
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export function numberWithCommas
|
|
31
|
-
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export function getIPv4HexString(ipStr){
|
|
35
|
-
let ipv4 = ipStr.split('.')
|
|
36
|
-
return Buffer.from(ipv4).toString('hex')
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export function getLocalAddress(){
|
|
40
|
-
const nets = networkInterfaces();
|
|
41
|
-
// console.log(nets)
|
|
42
|
-
const results = Object.create(null); // Or just '{}', an empty object
|
|
43
|
-
let localAddress =''
|
|
44
|
-
for (const name of Object.keys(nets)) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// console.log('localAddress:', localAddress)
|
|
60
|
-
return localAddress
|
|
61
|
-
}
|
|
1
|
+
import { networkInterfaces } from 'os';
|
|
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
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return false
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function numberWithCommas(x) {
|
|
31
|
+
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function getIPv4HexString(ipStr) {
|
|
35
|
+
let ipv4 = ipStr.split('.')
|
|
36
|
+
return Buffer.from(ipv4).toString('hex')
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function getLocalAddress() {
|
|
40
|
+
const nets = networkInterfaces();
|
|
41
|
+
// console.log(nets)
|
|
42
|
+
const results = Object.create(null); // Or just '{}', an empty object
|
|
43
|
+
let localAddress = ''
|
|
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
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// console.log('localAddress:', localAddress)
|
|
60
|
+
return localAddress
|
|
61
|
+
}
|
package/src/server/FileLogger.js
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import fs from 'fs'
|
|
2
|
-
|
|
3
|
-
const formatter = new Intl.DateTimeFormat('ko-KR', {
|
|
4
|
-
// hour12: true,
|
|
5
|
-
// hour: 'numeric',
|
|
6
|
-
// minute: '2-digit',
|
|
7
|
-
// second: '2-digit'
|
|
8
|
-
year: 'numeric', month: 'numeric', day: 'numeric',
|
|
9
|
-
hour: 'numeric', minute: 'numeric',
|
|
10
|
-
hour12: false,
|
|
11
|
-
timeZone: 'Asia/Seoul'
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export class FileLogger{
|
|
16
|
-
constructor(path
|
|
17
|
-
this.file = fs.openSync(path
|
|
18
|
-
console.log('new logFile', path, this.file
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
log(msg){
|
|
22
|
-
let format =formatter.format(new Date()) + " "+ msg +'\n';
|
|
23
|
-
fs.write(
|
|
24
|
-
if (err) throw err;
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
1
|
+
import fs from 'fs'
|
|
2
|
+
|
|
3
|
+
const formatter = new Intl.DateTimeFormat('ko-KR', {
|
|
4
|
+
// hour12: true,
|
|
5
|
+
// hour: 'numeric',
|
|
6
|
+
// minute: '2-digit',
|
|
7
|
+
// second: '2-digit'
|
|
8
|
+
year: 'numeric', month: 'numeric', day: 'numeric',
|
|
9
|
+
hour: 'numeric', minute: 'numeric',
|
|
10
|
+
hour12: false,
|
|
11
|
+
timeZone: 'Asia/Seoul'
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
export class FileLogger {
|
|
16
|
+
constructor(path) {
|
|
17
|
+
this.file = fs.openSync(path, 'a+')
|
|
18
|
+
console.log('new FileLogger logFile: ', path, this.file)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
log(msg) {
|
|
22
|
+
let format = formatter.format(new Date()) + " " + msg + '\n';
|
|
23
|
+
fs.write(this.file, format, (err) => {
|
|
24
|
+
if (err) throw err;
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
}
|