@bobfrankston/miscassists 1.0.5 → 1.0.8
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/.vscode/settings.json +21 -1
- package/checkaddress.js +137 -0
- package/checkaddress.js.map +1 -0
- package/checkaddress.ts +158 -0
- package/dnsassist.js +35 -2
- package/dnsassist.js.map +1 -1
- package/dnsassist.ts +40 -1
- package/index.js +3 -2
- package/index.js.map +1 -1
- package/index.ts +3 -2
- package/package.json +1 -1
- package/ports.js +2 -0
- package/ports.js.map +1 -1
- package/ports.ts +4 -0
package/.vscode/settings.json
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
1
|
{
|
|
2
|
-
"workbench.colorTheme": "Visual Studio 2019 Dark"
|
|
2
|
+
"workbench.colorTheme": "Visual Studio 2019 Dark",
|
|
3
|
+
"workbench.colorCustomizations": {
|
|
4
|
+
"activityBar.activeBackground": "#77a8ff",
|
|
5
|
+
"activityBar.background": "#77a8ff",
|
|
6
|
+
"activityBar.foreground": "#15202b",
|
|
7
|
+
"activityBar.inactiveForeground": "#15202b99",
|
|
8
|
+
"activityBarBadge.background": "#df0050",
|
|
9
|
+
"activityBarBadge.foreground": "#e7e7e7",
|
|
10
|
+
"commandCenter.border": "#15202b99",
|
|
11
|
+
"sash.hoverBorder": "#77a8ff",
|
|
12
|
+
"statusBar.background": "#4488ff",
|
|
13
|
+
"statusBar.foreground": "#15202b",
|
|
14
|
+
"statusBarItem.hoverBackground": "#1168ff",
|
|
15
|
+
"statusBarItem.remoteBackground": "#4488ff",
|
|
16
|
+
"statusBarItem.remoteForeground": "#15202b",
|
|
17
|
+
"titleBar.activeBackground": "#4488ff",
|
|
18
|
+
"titleBar.activeForeground": "#15202b",
|
|
19
|
+
"titleBar.inactiveBackground": "#4488ff99",
|
|
20
|
+
"titleBar.inactiveForeground": "#15202b99"
|
|
21
|
+
},
|
|
22
|
+
"peacock.color": "4488ff"
|
|
3
23
|
}
|
package/checkaddress.js
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
// From y:\dev\homecontrol\Others\LifX\Apps\lzlan\lants-address.ts
|
|
2
|
+
// import { isIPv6 } from 'net';
|
|
3
|
+
import os, { networkInterfaces } from 'os';
|
|
4
|
+
// Quck hack - using namespace to hid this until we debug and integrate it for v6 support
|
|
5
|
+
var hidden;
|
|
6
|
+
(function (hidden) {
|
|
7
|
+
const NetworkInterfaces = []; // Need to fix this signature
|
|
8
|
+
function assureNetworkInterfaces() {
|
|
9
|
+
// Note we don't detect changes to the interfaces
|
|
10
|
+
if (networkInterfaces.length > 0)
|
|
11
|
+
return;
|
|
12
|
+
const netifs = os.networkInterfaces();
|
|
13
|
+
for (const dev in netifs) {
|
|
14
|
+
netifs[dev].forEach((info) => {
|
|
15
|
+
let family = info.family;
|
|
16
|
+
if (typeof family == "number")
|
|
17
|
+
family = `IPv${family}`; // Strange change work-around
|
|
18
|
+
if (family !== 'IPv4' || info.internal === true) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
// let info4 = info as os.NetworkInterfaceInfoIPv4;
|
|
22
|
+
// (<any>info)['broadcast'] = _getBroadcastAddress(info4);
|
|
23
|
+
const mask = ipToUnsignedInt(info.netmask);
|
|
24
|
+
const address = ipToUnsignedInt(info.address) & mask;
|
|
25
|
+
const ni = { ...info, ints: { mask, address } };
|
|
26
|
+
NetworkInterfaces.push(ni);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return NetworkInterfaces;
|
|
30
|
+
}
|
|
31
|
+
hidden.assureNetworkInterfaces = assureNetworkInterfaces;
|
|
32
|
+
;
|
|
33
|
+
function isLocalIp4Address(ip4Address) {
|
|
34
|
+
if (ip4Address == '127.0.0.1')
|
|
35
|
+
return true;
|
|
36
|
+
const ipa = ipToUnsignedInt(ip4Address);
|
|
37
|
+
assureNetworkInterfaces();
|
|
38
|
+
return NetworkInterfaces.some((ni) => (ni.ints.address & ni.ints.mask) === (ipa & ni.ints.mask));
|
|
39
|
+
}
|
|
40
|
+
hidden.isLocalIp4Address = isLocalIp4Address;
|
|
41
|
+
function ipToUnsignedInt(ipAddress) {
|
|
42
|
+
const parts = ipAddress.split('.');
|
|
43
|
+
if (parts.length !== 4) {
|
|
44
|
+
throw new Error('Invalid IP address format');
|
|
45
|
+
}
|
|
46
|
+
const num = parts.map((part) => parseInt(part, 10));
|
|
47
|
+
if (num.some((part) => isNaN(part) || part < 0 || part > 255)) {
|
|
48
|
+
throw new Error(`Invalid IP address ${ipAddress}`);
|
|
49
|
+
}
|
|
50
|
+
const signed = (num[0] << 24) + (num[1] << 16) + (num[2] << 8) + num[3];
|
|
51
|
+
const unsigned = signed >>> 0;
|
|
52
|
+
return unsigned;
|
|
53
|
+
}
|
|
54
|
+
let pretendRemote = false;
|
|
55
|
+
function isLocalIpAddress(ipAddress) {
|
|
56
|
+
// '::ffff:172.20.3.39'
|
|
57
|
+
if (pretendRemote)
|
|
58
|
+
return false;
|
|
59
|
+
ipAddress = ipAddress.toLowerCase(); // Safety
|
|
60
|
+
if (ipAddress.startsWith('fe80:'))
|
|
61
|
+
return true; // Link local
|
|
62
|
+
if (ipAddress == "::1")
|
|
63
|
+
return true;
|
|
64
|
+
ipAddress = ipAddress.replace(/^::ffff:/, ''); // If it's like V5
|
|
65
|
+
if (/^[0-9.]+$/.test(ipAddress))
|
|
66
|
+
return isLocalIp4Address(ipAddress);
|
|
67
|
+
return isIPv6LocalAddress(ipAddress);
|
|
68
|
+
// const localIps = getLocalAddresses();
|
|
69
|
+
// for (const localIp of localIps) {
|
|
70
|
+
// const range = new AddressInfo(localIp);
|
|
71
|
+
// if (range.family === 'IPv4' && net.isIPv4(ipAddress)) {
|
|
72
|
+
// if (range.address === ipAddress) {
|
|
73
|
+
// return true;
|
|
74
|
+
// }
|
|
75
|
+
// } else if (range.family === 'IPv6' && net.isIPv6(ipAddress)) {
|
|
76
|
+
// if (range.address === ipAddress) {
|
|
77
|
+
// return true;
|
|
78
|
+
// }
|
|
79
|
+
// }
|
|
80
|
+
// }
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
hidden.isLocalIpAddress = isLocalIpAddress;
|
|
84
|
+
// function isIPv6LocalAddress(ipv6Address: string): boolean {
|
|
85
|
+
// const interfaces = networkInterfaces();
|
|
86
|
+
// for (const interfaceName of Object.keys(interfaces)) {
|
|
87
|
+
// const addresses = interfaces[interfaceName].filter(
|
|
88
|
+
// (iface) => iface.family === 'IPv6'
|
|
89
|
+
// );
|
|
90
|
+
// for (const iface of addresses) {
|
|
91
|
+
// if (iface.address === ipv6Address) {
|
|
92
|
+
// return true;
|
|
93
|
+
// }
|
|
94
|
+
// }
|
|
95
|
+
// }
|
|
96
|
+
// return false;
|
|
97
|
+
// }
|
|
98
|
+
function isIPv6LocalAddress(ipv6Address) {
|
|
99
|
+
const interfaces = networkInterfaces();
|
|
100
|
+
for (const interfaceName of Object.keys(interfaces)) {
|
|
101
|
+
const addresses = interfaces[interfaceName].filter((iface) => iface.family === 'IPv6');
|
|
102
|
+
for (const iface of addresses) {
|
|
103
|
+
if (iface.cidr) {
|
|
104
|
+
const [ifaceAddress, networkMask] = iface.cidr.split('/');
|
|
105
|
+
if (isSameNetwork(ipv6Address, networkMask, ifaceAddress)) {
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
function isSameNetwork(ipv6Address, networkMaskLength, ifaceAddress) {
|
|
114
|
+
const maskLength = parseInt(networkMaskLength, 10);
|
|
115
|
+
const bufferLength = Math.ceil(maskLength / 8);
|
|
116
|
+
const addressBuffer = Buffer.from(ipv6Address.split(':').map((part) => parseInt(part, 16)));
|
|
117
|
+
const ifaceBuffer = Buffer.from(ifaceAddress.split(':').map((part) => parseInt(part, 16)));
|
|
118
|
+
for (let i = 0; i < bufferLength; i++) {
|
|
119
|
+
const maskBits = Math.min(maskLength - i * 8, 8);
|
|
120
|
+
const mask = (0xff00 >> maskBits) & 0xff;
|
|
121
|
+
if ((addressBuffer[i] & mask) !== ifaceBuffer[i]) {
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
// Example usage
|
|
128
|
+
// const ipv6AddressToCheck = 'fdb7:3df3:9615:193e:3743:1a24:69e8:127a';
|
|
129
|
+
// const isLocalAddress = isIPv6LocalAddress(ipv6AddressToCheck);
|
|
130
|
+
// console.log(`Is IPv6 Address ${ipv6AddressToCheck} on the same local network? ${isLocalAddress}`);
|
|
131
|
+
// // Example usage
|
|
132
|
+
// const ipv6AddressToCheck = 'fdb7:3df3:9615:193e:3743:1a24:69e8:127a';
|
|
133
|
+
// const networkMask = 'ffff:ffff:ffff:ffff::'; // Replace with the actual subnet mask
|
|
134
|
+
// const isLocalAddress = isIPv6LocalAddress(ipv6AddressToCheck, networkMask);
|
|
135
|
+
// console.log(`Is IPv6 Address ${ipv6AddressToCheck} on the same local network? ${isLocalAddress}`);
|
|
136
|
+
})(hidden || (hidden = {}));
|
|
137
|
+
//# sourceMappingURL=checkaddress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkaddress.js","sourceRoot":"","sources":["checkaddress.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAElE,gCAAgC;AAChC,OAAO,EAAE,EAAE,EAAE,iBAAiB,EAAE,MAAM,IAAI,CAAC;AAE3C,yFAAyF;AACzF,IAAU,MAAM,CAuJf;AAvJD,WAAU,MAAM;IAGZ,MAAM,iBAAiB,GAAc,EAAE,CAAC,CAAC,6BAA6B;IAEtE,SAAgB,uBAAuB;QACnC,iDAAiD;QACjD,IAAI,iBAAiB,CAAC,MAAM,GAAG,CAAC;YAAE,OAAO;QAEzC,MAAM,MAAM,GAAG,EAAE,CAAC,iBAAiB,EAAE,CAAC;QACtC,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE;YACtB,MAAM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homecontrol\Others\LifX\Apps\lzlan\lants-address.ts
|
|
2
|
+
|
|
3
|
+
// import { isIPv6 } from 'net';
|
|
4
|
+
import os, { networkInterfaces } from 'os';
|
|
5
|
+
|
|
6
|
+
// Quck hack - using namespace to hid this until we debug and integrate it for v6 support
|
|
7
|
+
namespace hidden {
|
|
8
|
+
type netinfo = os.NetworkInterfaceInfo & { ints: { address: number, mask: number } }
|
|
9
|
+
|
|
10
|
+
const NetworkInterfaces: netinfo[] = []; // Need to fix this signature
|
|
11
|
+
|
|
12
|
+
export function assureNetworkInterfaces() {
|
|
13
|
+
// Note we don't detect changes to the interfaces
|
|
14
|
+
if (networkInterfaces.length > 0) return;
|
|
15
|
+
|
|
16
|
+
const netifs = os.networkInterfaces();
|
|
17
|
+
for (const dev in netifs) {
|
|
18
|
+
netifs[dev].forEach((info) => {
|
|
19
|
+
|
|
20
|
+
let family = info.family;
|
|
21
|
+
|
|
22
|
+
if (typeof family == "number")
|
|
23
|
+
family = `IPv${family}`; // Strange change work-around
|
|
24
|
+
|
|
25
|
+
if (family !== 'IPv4' || info.internal === true) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
// let info4 = info as os.NetworkInterfaceInfoIPv4;
|
|
29
|
+
// (<any>info)['broadcast'] = _getBroadcastAddress(info4);
|
|
30
|
+
|
|
31
|
+
const mask = ipToUnsignedInt(info.netmask);
|
|
32
|
+
const address = ipToUnsignedInt(info.address) & mask;
|
|
33
|
+
const ni = { ...info, ints: { mask, address } };
|
|
34
|
+
NetworkInterfaces.push(ni);
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
return NetworkInterfaces;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export function isLocalIp4Address(ip4Address: string) {
|
|
41
|
+
if (ip4Address == '127.0.0.1')
|
|
42
|
+
return true;
|
|
43
|
+
const ipa = ipToUnsignedInt(ip4Address);
|
|
44
|
+
assureNetworkInterfaces();
|
|
45
|
+
return NetworkInterfaces.some((ni) => (ni.ints.address & ni.ints.mask) === (ipa & ni.ints.mask));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function ipToUnsignedInt(ipAddress: string): number {
|
|
49
|
+
const parts = ipAddress.split('.');
|
|
50
|
+
if (parts.length !== 4) {
|
|
51
|
+
throw new Error('Invalid IP address format');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const num = parts.map((part) => parseInt(part, 10));
|
|
55
|
+
if (num.some((part) => isNaN(part) || part < 0 || part > 255)) {
|
|
56
|
+
throw new Error(`Invalid IP address ${ipAddress}`);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const signed = (num[0] << 24) + (num[1] << 16) + (num[2] << 8) + num[3];
|
|
60
|
+
const unsigned = signed >>> 0;
|
|
61
|
+
return unsigned;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
let pretendRemote = false;
|
|
65
|
+
|
|
66
|
+
export function isLocalIpAddress(ipAddress: string) {
|
|
67
|
+
// '::ffff:172.20.3.39'
|
|
68
|
+
if (pretendRemote) return false;
|
|
69
|
+
ipAddress = ipAddress.toLowerCase(); // Safety
|
|
70
|
+
if (ipAddress.startsWith('fe80:'))
|
|
71
|
+
return true; // Link local
|
|
72
|
+
if (ipAddress == "::1")
|
|
73
|
+
return true;
|
|
74
|
+
ipAddress = ipAddress.replace(/^::ffff:/, ''); // If it's like V5
|
|
75
|
+
|
|
76
|
+
if (/^[0-9.]+$/.test(ipAddress))
|
|
77
|
+
return isLocalIp4Address(ipAddress)
|
|
78
|
+
return isIPv6LocalAddress(ipAddress);
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
// const localIps = getLocalAddresses();
|
|
82
|
+
|
|
83
|
+
// for (const localIp of localIps) {
|
|
84
|
+
// const range = new AddressInfo(localIp);
|
|
85
|
+
|
|
86
|
+
// if (range.family === 'IPv4' && net.isIPv4(ipAddress)) {
|
|
87
|
+
// if (range.address === ipAddress) {
|
|
88
|
+
// return true;
|
|
89
|
+
// }
|
|
90
|
+
// } else if (range.family === 'IPv6' && net.isIPv6(ipAddress)) {
|
|
91
|
+
// if (range.address === ipAddress) {
|
|
92
|
+
// return true;
|
|
93
|
+
// }
|
|
94
|
+
// }
|
|
95
|
+
// }
|
|
96
|
+
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// function isIPv6LocalAddress(ipv6Address: string): boolean {
|
|
101
|
+
// const interfaces = networkInterfaces();
|
|
102
|
+
// for (const interfaceName of Object.keys(interfaces)) {
|
|
103
|
+
// const addresses = interfaces[interfaceName].filter(
|
|
104
|
+
// (iface) => iface.family === 'IPv6'
|
|
105
|
+
// );
|
|
106
|
+
// for (const iface of addresses) {
|
|
107
|
+
// if (iface.address === ipv6Address) {
|
|
108
|
+
// return true;
|
|
109
|
+
// }
|
|
110
|
+
// }
|
|
111
|
+
// }
|
|
112
|
+
// return false;
|
|
113
|
+
// }
|
|
114
|
+
|
|
115
|
+
function isIPv6LocalAddress(ipv6Address: string): boolean {
|
|
116
|
+
const interfaces = networkInterfaces();
|
|
117
|
+
for (const interfaceName of Object.keys(interfaces)) {
|
|
118
|
+
const addresses = interfaces[interfaceName].filter((iface) => iface.family === 'IPv6');
|
|
119
|
+
for (const iface of addresses) {
|
|
120
|
+
if (iface.cidr) {
|
|
121
|
+
const [ifaceAddress, networkMask] = iface.cidr.split('/');
|
|
122
|
+
if (isSameNetwork(ipv6Address, networkMask, ifaceAddress)) {
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function isSameNetwork(ipv6Address: string, networkMaskLength: string, ifaceAddress: string): boolean {
|
|
132
|
+
const maskLength = parseInt(networkMaskLength, 10);
|
|
133
|
+
const bufferLength = Math.ceil(maskLength / 8);
|
|
134
|
+
const addressBuffer = Buffer.from(ipv6Address.split(':').map((part) => parseInt(part, 16)));
|
|
135
|
+
const ifaceBuffer = Buffer.from(ifaceAddress.split(':').map((part) => parseInt(part, 16)));
|
|
136
|
+
|
|
137
|
+
for (let i = 0; i < bufferLength; i++) {
|
|
138
|
+
const maskBits = Math.min(maskLength - i * 8, 8);
|
|
139
|
+
const mask = (0xff00 >> maskBits) & 0xff;
|
|
140
|
+
if ((addressBuffer[i] & mask) !== ifaceBuffer[i]) {
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Example usage
|
|
148
|
+
// const ipv6AddressToCheck = 'fdb7:3df3:9615:193e:3743:1a24:69e8:127a';
|
|
149
|
+
// const isLocalAddress = isIPv6LocalAddress(ipv6AddressToCheck);
|
|
150
|
+
// console.log(`Is IPv6 Address ${ipv6AddressToCheck} on the same local network? ${isLocalAddress}`);
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
// // Example usage
|
|
154
|
+
// const ipv6AddressToCheck = 'fdb7:3df3:9615:193e:3743:1a24:69e8:127a';
|
|
155
|
+
// const networkMask = 'ffff:ffff:ffff:ffff::'; // Replace with the actual subnet mask
|
|
156
|
+
// const isLocalAddress = isIPv6LocalAddress(ipv6AddressToCheck, networkMask);
|
|
157
|
+
// console.log(`Is IPv6 Address ${ipv6AddressToCheck} on the same local network? ${isLocalAddress}`);
|
|
158
|
+
}
|
package/dnsassist.js
CHANGED
|
@@ -24,6 +24,7 @@ export async function resolveLocal4(name) {
|
|
|
24
24
|
;
|
|
25
25
|
export let localIPAndMasks = null;
|
|
26
26
|
function ipv4ToInt(ip) {
|
|
27
|
+
ip = ip.replace('::ffff:', ''); // Convert IPv4-mapped IPv6 addresses to their IPv4 representation
|
|
27
28
|
const octets = ip.split(".").map(o => parseInt(o));
|
|
28
29
|
// let z8 = octets.reduce((acc, octet) => (acc << 8) + octet);
|
|
29
30
|
let x8 = arrayToUint32(octets.reverse());
|
|
@@ -35,8 +36,9 @@ function arrayToUint32(arr) {
|
|
|
35
36
|
return uint32Arr[0];
|
|
36
37
|
}
|
|
37
38
|
function assureLocalV4Address() {
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
// 2023-12-18 removed caching so we can change it on the fly
|
|
40
|
+
// if (localIPAndMasks)
|
|
41
|
+
// return localIPAndMasks;
|
|
40
42
|
localIPAndMasks = [];
|
|
41
43
|
const interfaces = os.networkInterfaces();
|
|
42
44
|
for (const name of Object.keys(interfaces)) {
|
|
@@ -53,6 +55,8 @@ function assureLocalV4Address() {
|
|
|
53
55
|
return localIPAndMasks;
|
|
54
56
|
}
|
|
55
57
|
export function isLocalIP(ip) {
|
|
58
|
+
if (isThisMachine(ip))
|
|
59
|
+
return true; // It handles special cases better
|
|
56
60
|
const ipn = ipv4ToInt(ip);
|
|
57
61
|
for (var ipm of assureLocalV4Address()) {
|
|
58
62
|
if ((ipn & ipm.mask) === ipm.ipn)
|
|
@@ -60,4 +64,33 @@ export function isLocalIP(ip) {
|
|
|
60
64
|
}
|
|
61
65
|
return false;
|
|
62
66
|
}
|
|
67
|
+
// // Function to get all IP addresses of the local machine, both IPv4 and IPv6
|
|
68
|
+
// const getLocalIPs = (): string[] => {
|
|
69
|
+
// const interfaces = os.networkInterfaces();
|
|
70
|
+
// const ips: string[] = [];
|
|
71
|
+
// for (const interfaceName in interfaces) {
|
|
72
|
+
// const iface = interfaces[interfaceName];
|
|
73
|
+
// if (iface) {P
|
|
74
|
+
// for (const alias of iface) {
|
|
75
|
+
// if ((alias.family === 'IPv4' || alias.family === 'IPv6') && !alias.internal) {
|
|
76
|
+
// // Store IPv4 addresses directly and IPv6 addresses in their full representation
|
|
77
|
+
// ips.push(alias.family === 'IPv4' ? alias.address : `::ffff:${alias.address}`);
|
|
78
|
+
// }
|
|
79
|
+
// }
|
|
80
|
+
// }
|
|
81
|
+
// }
|
|
82
|
+
// return ips;
|
|
83
|
+
// };
|
|
84
|
+
// Function to check if the IP address is from this machine
|
|
85
|
+
export function isThisMachine(ip) {
|
|
86
|
+
// Convert IPv4-mapped IPv6 addresses to their IPv4 representation
|
|
87
|
+
ip = ip.replace('::ffff:', '');
|
|
88
|
+
// Handling the case where IP is ::1 (localhost in IPv6)
|
|
89
|
+
if (ip === '::1' || ip == '127.0.0.1') {
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
const localIPs = assureLocalV4Address().map(ipm => ipm.s.ip);
|
|
93
|
+
return localIPs.includes(ip);
|
|
94
|
+
}
|
|
95
|
+
;
|
|
63
96
|
//# sourceMappingURL=dnsassist.js.map
|
package/dnsassist.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dnsassist.js","sourceRoot":"","sources":["dnsassist.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,EAAE,MAAM,IAAI,CAAA;AAEnB;;GAEG;AAEH,MAAM,CAAC,MAAM,YAAY,GAAG,QAAQ,CAAC,CAAE,UAAU;AAEjD,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,IAAY,EAAE,KAAe;IACxD,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,IAAI,IAAI,GAAG,GAAG,YAAY,CAAC,CAAG,YAAY;IAEnE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EACrD,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QACT,IAAI,GAAG;YACH,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC;QAEzB,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QAC/C,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC;YACjB,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QAC9B,IAAI,KAAK;YACL,OAAO,OAAO,CAAC,IAAI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AAC;AAED,+EAA+E;AAC/E,wCAAwC;AACxC,iDAAiD;AACjD,gCAAgC;AAEhC,gDAAgD;AAChD,mDAAmD;AACnD,wBAAwB;AACxB,2CAA2C;AAC3C,iGAAiG;AACjG,uGAAuG;AACvG,qGAAqG;AACrG,oBAAoB;AACpB,gBAAgB;AAChB,YAAY;AACZ,QAAQ;AAER,kBAAkB;AAClB,KAAK;AAEL,2DAA2D;AAC3D,MAAM,UAAU,aAAa,CAAC,EAAU;IACpC,kEAAkE;IAClE,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IAE/B,wDAAwD;IACxD,IAAI,EAAE,KAAK,KAAK,IAAI,EAAE,IAAI,WAAW,EAAE;QACnC,OAAO,IAAI,CAAC;KACf;IAED,MAAM,QAAQ,GAAG,oBAAoB,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAC7D,OAAO,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;AACjC,CAAC;AAAA,CAAC"}
|
package/dnsassist.ts
CHANGED
|
@@ -36,6 +36,7 @@ interface localIPAndMask { ipn: number, mask: number, s: { ip: string, mask: str
|
|
|
36
36
|
export let localIPAndMasks: localIPAndMask[] = null;
|
|
37
37
|
|
|
38
38
|
function ipv4ToInt(ip: string): number {
|
|
39
|
+
ip = ip.replace('::ffff:', ''); // Convert IPv4-mapped IPv6 addresses to their IPv4 representation
|
|
39
40
|
const octets = ip.split(".").map(o => parseInt(o));
|
|
40
41
|
// let z8 = octets.reduce((acc, octet) => (acc << 8) + octet);
|
|
41
42
|
let x8 = arrayToUint32(octets.reverse());
|
|
@@ -49,7 +50,9 @@ function arrayToUint32(arr: number[]): number {
|
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
function assureLocalV4Address() {
|
|
52
|
-
|
|
53
|
+
// 2023-12-18 removed caching so we can change it on the fly
|
|
54
|
+
// if (localIPAndMasks)
|
|
55
|
+
// return localIPAndMasks;
|
|
53
56
|
localIPAndMasks = [];
|
|
54
57
|
const interfaces = os.networkInterfaces();
|
|
55
58
|
|
|
@@ -66,9 +69,45 @@ function assureLocalV4Address() {
|
|
|
66
69
|
}
|
|
67
70
|
|
|
68
71
|
export function isLocalIP(ip: string) {
|
|
72
|
+
if (isThisMachine(ip))
|
|
73
|
+
return true; // It handles special cases better
|
|
69
74
|
const ipn = ipv4ToInt(ip);
|
|
70
75
|
for (var ipm of assureLocalV4Address()) {
|
|
71
76
|
if ((ipn & ipm.mask) === ipm.ipn) return true;
|
|
72
77
|
}
|
|
73
78
|
return false;
|
|
74
79
|
}
|
|
80
|
+
|
|
81
|
+
// // Function to get all IP addresses of the local machine, both IPv4 and IPv6
|
|
82
|
+
// const getLocalIPs = (): string[] => {
|
|
83
|
+
// const interfaces = os.networkInterfaces();
|
|
84
|
+
// const ips: string[] = [];
|
|
85
|
+
|
|
86
|
+
// for (const interfaceName in interfaces) {
|
|
87
|
+
// const iface = interfaces[interfaceName];
|
|
88
|
+
// if (iface) {P
|
|
89
|
+
// for (const alias of iface) {
|
|
90
|
+
// if ((alias.family === 'IPv4' || alias.family === 'IPv6') && !alias.internal) {
|
|
91
|
+
// // Store IPv4 addresses directly and IPv6 addresses in their full representation
|
|
92
|
+
// ips.push(alias.family === 'IPv4' ? alias.address : `::ffff:${alias.address}`);
|
|
93
|
+
// }
|
|
94
|
+
// }
|
|
95
|
+
// }
|
|
96
|
+
// }
|
|
97
|
+
|
|
98
|
+
// return ips;
|
|
99
|
+
// };
|
|
100
|
+
|
|
101
|
+
// Function to check if the IP address is from this machine
|
|
102
|
+
export function isThisMachine(ip: string) {
|
|
103
|
+
// Convert IPv4-mapped IPv6 addresses to their IPv4 representation
|
|
104
|
+
ip = ip.replace('::ffff:', '');
|
|
105
|
+
|
|
106
|
+
// Handling the case where IP is ::1 (localhost in IPv6)
|
|
107
|
+
if (ip === '::1' || ip == '127.0.0.1') {
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const localIPs = assureLocalV4Address().map(ipm => ipm.s.ip);
|
|
112
|
+
return localIPs.includes(ip);
|
|
113
|
+
};
|
package/index.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { resolve4, resolveLocal4, isLocalIP, default_fqdn } from './dnsassist.js';
|
|
2
|
-
export { resolve4, resolveLocal4, isLocalIP, default_fqdn } from './dnsassist.js';
|
|
1
|
+
import { resolve4, resolveLocal4, isLocalIP, isThisMachine, default_fqdn } from './dnsassist.js';
|
|
2
|
+
export { resolve4, resolveLocal4, isLocalIP, isThisMachine, default_fqdn } from './dnsassist.js';
|
|
3
3
|
import { ports, mqtt } from './ports.js';
|
|
4
4
|
export { ports, mqtt } from './ports.js';
|
|
5
5
|
export default {
|
|
6
6
|
resolve4,
|
|
7
7
|
resolveLocal4,
|
|
8
8
|
isLocalIP,
|
|
9
|
+
isThisMachine,
|
|
9
10
|
default_fqdn,
|
|
10
11
|
ports,
|
|
11
12
|
mqtt
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAChG,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAEhG,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAExC,eAAe;IACX,QAAQ;IACR,aAAa;IACb,SAAS;IACT,aAAa;IACb,YAAY;IACZ,KAAK;IACL,IAAI;CACP,CAAA"}
|
package/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { resolve4, resolveLocal4, isLocalIP, default_fqdn } from './dnsassist.js'
|
|
2
|
-
export { resolve4, resolveLocal4, isLocalIP, default_fqdn } from './dnsassist.js'
|
|
1
|
+
import { resolve4, resolveLocal4, isLocalIP, isThisMachine, default_fqdn } from './dnsassist.js'
|
|
2
|
+
export { resolve4, resolveLocal4, isLocalIP, isThisMachine, default_fqdn } from './dnsassist.js'
|
|
3
3
|
|
|
4
4
|
import { ports, mqtt } from './ports.js'
|
|
5
5
|
export { ports, mqtt } from './ports.js'
|
|
@@ -8,6 +8,7 @@ export default {
|
|
|
8
8
|
resolve4,
|
|
9
9
|
resolveLocal4,
|
|
10
10
|
isLocalIP,
|
|
11
|
+
isThisMachine,
|
|
11
12
|
default_fqdn,
|
|
12
13
|
ports,
|
|
13
14
|
mqtt
|
package/package.json
CHANGED
package/ports.js
CHANGED
package/ports.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ports.js","sourceRoot":"","sources":["ports.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,KAAK,GAAG;IACjB,OAAO,EAAG,KAAK;IACf,QAAQ,EAAE,KAAK;IAEf,SAAS,EAAE,IAAI;IACf,QAAQ,EAAE,IAAI;IAEd,OAAO,EAAE,IAAI;IACb,QAAQ,EAAE,IAAI;IAEd,OAAO,EAAE,IAAI;IACb,OAAO,EAAE,IAAI;IACb,QAAQ,EAAE,IAAI;IAEd,IAAI,EAAE,IAAI;IACV,KAAK,EAAE,IAAI;IAEX,MAAM,EAAE,IAAI;IACZ,OAAO,EAAE,IAAI;IAEb,MAAM,EAAE,IAAI;IACZ,OAAO,EAAE,IAAI;IAEb,SAAS,EAAE,IAAI;IAEf,QA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IAAI;IAEb,MAAM,EAAE,IAAI;IACZ,OAAO,EAAE,IAAI;IAEb,SAAS,EAAE,IAAI;IAEf,QAAQ,EAAE,IAAI;IACd,SAAS,EAAE,IAAI;IAEf,QAAQ,EAAE,IAAI;IACd,QAAQ,EAAE,IAAI;IAEd,MAAM,EAAE,IAAI;IAEZ,MAAM,EAAE,IAAI;IACZ,MAAM,EAAE,IAAI;IACZ,SAAS,EAAE,IAAI;IAEf,GAAG,EAAE,IAAI;IACT,MAAM,EAAE,IAAI;IACZ,SAAS,EAAE,IAAI;IAEf,MAAM,EAAE,IAAI;IAEZ,MAAM,EAAE,IAAI;IAEZ,KAAK,EAAE,KAAK,CAAY,sGAAsG;CAEjI,CAAA;AAED,MAAM,CAAC,MAAM,IAAI,GAAG;IAChB,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,IAAI;IACV,KAAK,EAAE;QACH,GAAG,EAAE,KAAK;QACV,SAAS,EAAE;YACP,OAAO,EAAE,SAAS;SACrB;KACJ;CAEJ,CAAA;AAED,iEAAiE;AACjE,2CAA2C;AAC3C,+DAA+D;AAC/D,uEAAuE;AACvE,4DAA4D;AAC5D,4CAA4C;AAC5C,2DAA2D;AAC3D,uCAAuC;AACvC,qDAAqD;AACrD,oDAAoD;AACpD,2DAA2D;AAC3D,6CAA6C;AAC7C,sCAAsC;AACtC,wDAAwD;AACxD,oDAAoD;AACpD,6DAA6D;AAC7D,uCAAuC;AACvC,yCAAyC;AACzC,uCAAuC;AACvC,8CAA8C;AAC9C,gDAAgD;AAChD,EAAE"}
|
package/ports.ts
CHANGED
|
@@ -38,6 +38,10 @@ export const ports = {
|
|
|
38
38
|
bbt: 9314, // Bulletin board test
|
|
39
39
|
backts: 9315,
|
|
40
40
|
backserve: 9316,
|
|
41
|
+
|
|
42
|
+
syncer: 9317,
|
|
43
|
+
|
|
44
|
+
lifxer: 9318,
|
|
41
45
|
|
|
42
46
|
pinst: 9299. // Used for my pings server [currently it has a local value because --install-links isn't cooperating]
|
|
43
47
|
|