@bobfrankston/miscassists 1.0.53 → 1.0.55
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/dnsassist.d.ts +1 -0
- package/dnsassist.js +28 -12
- package/index.d.ts +3 -2
- package/index.js +4 -3
- package/jserve.d.ts +1 -0
- package/jserve.js +1 -1
- package/miscassists.code-workspace +20 -2
- package/package.json +1 -1
package/dnsassist.d.ts
CHANGED
|
@@ -16,3 +16,4 @@ interface localIPAndMask {
|
|
|
16
16
|
export declare let localIPAndMasks: localIPAndMask[];
|
|
17
17
|
export declare function isLocalIP(ip: string): boolean;
|
|
18
18
|
export declare function isThisMachine(ip: string): boolean;
|
|
19
|
+
export declare function getLocalSuffix(): Promise<string | null>;
|
package/dnsassist.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import os from 'os';
|
|
1
|
+
import dnsp from 'node:dns/promises';
|
|
2
|
+
import os from 'node:os';
|
|
3
3
|
import { default_fqdn } from '@bobfrankston/miscinfo';
|
|
4
4
|
/***
|
|
5
5
|
* return IPv4 address giving local addresses priority
|
|
@@ -8,16 +8,19 @@ export { default_fqdn };
|
|
|
8
8
|
export async function resolve4(name, local) {
|
|
9
9
|
if (!name?.includes('.'))
|
|
10
10
|
name += '.' + default_fqdn; // FQDN Hack
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
let ips;
|
|
12
|
+
try {
|
|
13
|
+
ips = await dnsp.resolve4(name);
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
const locals = ips.filter(ip => isLocalIP(ip));
|
|
19
|
+
if (locals.length > 0)
|
|
20
|
+
return locals[0];
|
|
21
|
+
if (local)
|
|
22
|
+
return null;
|
|
23
|
+
return ips[0];
|
|
21
24
|
}
|
|
22
25
|
export async function resolveLocal4(name) {
|
|
23
26
|
return await resolve4(name, true);
|
|
@@ -94,4 +97,17 @@ export function isThisMachine(ip) {
|
|
|
94
97
|
return localIPs.includes(ip);
|
|
95
98
|
}
|
|
96
99
|
;
|
|
100
|
+
export async function getLocalSuffix() {
|
|
101
|
+
try {
|
|
102
|
+
const [server] = dnsp.getServers();
|
|
103
|
+
if (!server)
|
|
104
|
+
return null;
|
|
105
|
+
const [name] = await dnsp.reverse(server);
|
|
106
|
+
const parts = name?.split(".") ?? [];
|
|
107
|
+
return parts.length > 1 ? parts.slice(1).join(".") : null;
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
97
113
|
//# sourceMappingURL=dnsassist.js.map
|
package/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { resolve4, resolveLocal4, isLocalIP, isThisMachine, default_fqdn } from './dnsassist.js';
|
|
1
|
+
import { resolve4, resolveLocal4, isLocalIP, isThisMachine, default_fqdn, getLocalSuffix } from './dnsassist.js';
|
|
2
2
|
import { ports, mqtt, endsWithFQDN } from '@bobfrankston/miscinfo';
|
|
3
3
|
import { makerPayload } from './maker.js';
|
|
4
|
-
export { resolve4, resolveLocal4, isLocalIP, isThisMachine, default_fqdn, ports, mqtt, makerPayload, endsWithFQDN };
|
|
4
|
+
export { resolve4, resolveLocal4, isLocalIP, isThisMachine, default_fqdn, ports, mqtt, makerPayload, endsWithFQDN, getLocalSuffix };
|
|
5
5
|
export declare const values: {
|
|
6
6
|
exitRunit: number;
|
|
7
7
|
};
|
|
@@ -73,5 +73,6 @@ declare const _default: {
|
|
|
73
73
|
exitRunit: number;
|
|
74
74
|
};
|
|
75
75
|
endsWithFQDN: typeof endsWithFQDN;
|
|
76
|
+
getLocalSuffix: typeof getLocalSuffix;
|
|
76
77
|
};
|
|
77
78
|
export default _default;
|
package/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { resolve4, resolveLocal4, isLocalIP, isThisMachine, default_fqdn } from './dnsassist.js';
|
|
1
|
+
import { resolve4, resolveLocal4, isLocalIP, isThisMachine, default_fqdn, getLocalSuffix } from './dnsassist.js';
|
|
2
2
|
import { ports, mqtt, endsWithFQDN } from '@bobfrankston/miscinfo';
|
|
3
3
|
// import { jSubSiteInfo, jpriv, jprivs } from './jserve.js';
|
|
4
|
-
export { resolve4, resolveLocal4, isLocalIP, isThisMachine, default_fqdn, ports, mqtt, endsWithFQDN
|
|
4
|
+
export { resolve4, resolveLocal4, isLocalIP, isThisMachine, default_fqdn, ports, mqtt, endsWithFQDN, getLocalSuffix
|
|
5
5
|
// , jSubSiteInfo, jpriv, jprivs
|
|
6
6
|
};
|
|
7
7
|
export const values = {
|
|
@@ -17,6 +17,7 @@ export default {
|
|
|
17
17
|
mqtt,
|
|
18
18
|
// jprivs,
|
|
19
19
|
values,
|
|
20
|
-
endsWithFQDN
|
|
20
|
+
endsWithFQDN,
|
|
21
|
+
getLocalSuffix
|
|
21
22
|
};
|
|
22
23
|
//# sourceMappingURL=index.js.map
|
package/jserve.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/jserve.js
CHANGED
|
@@ -10,7 +10,25 @@
|
|
|
10
10
|
"settings": {
|
|
11
11
|
"workbench.colorCustomizations": {
|
|
12
12
|
"statusBar.noFolderBackground": "#551913",
|
|
13
|
-
"statusBar.noFolderForeground": "#FEFCFC"
|
|
14
|
-
|
|
13
|
+
"statusBar.noFolderForeground": "#FEFCFC",
|
|
14
|
+
"activityBar.background": "#ba8be6",
|
|
15
|
+
"titleBar.activeBackground": "#a161dd",
|
|
16
|
+
"titleBar.activeForeground": "#15202b",
|
|
17
|
+
"titleBar.inactiveBackground": "#a161dd99",
|
|
18
|
+
"titleBar.inactiveForeground": "#15202b99",
|
|
19
|
+
"statusBar.background": "#a161dd",
|
|
20
|
+
"statusBar.foreground": "#15202b",
|
|
21
|
+
"activityBar.activeBackground": "#ba8be6",
|
|
22
|
+
"activityBar.foreground": "#15202b",
|
|
23
|
+
"activityBar.inactiveForeground": "#15202b99",
|
|
24
|
+
"activityBarBadge.background": "#f4e0cb",
|
|
25
|
+
"activityBarBadge.foreground": "#15202b",
|
|
26
|
+
"commandCenter.border": "#15202b99",
|
|
27
|
+
"sash.hoverBorder": "#ba8be6",
|
|
28
|
+
"statusBarItem.hoverBackground": "#8837d4",
|
|
29
|
+
"statusBarItem.remoteBackground": "#a161dd",
|
|
30
|
+
"statusBarItem.remoteForeground": "#15202b"
|
|
31
|
+
},
|
|
32
|
+
"peacock.color": "#a161dd"
|
|
15
33
|
}
|
|
16
34
|
}
|