@bobfrankston/miscassists 1.0.41 → 1.0.42

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/checkaddress.js CHANGED
@@ -1,5 +1,3 @@
1
- // From y:\dev\homecontrol\Others\LifX\Apps\lzlan\lants-address.ts
2
- // import { isIPv6 } from 'net';
3
1
  import os, { networkInterfaces } from 'os';
4
2
  // Quck hack - using namespace to hid this until we debug and integrate it for v6 support
5
3
  var hidden;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/miscassists",
3
- "version": "1.0.41",
3
+ "version": "1.0.42",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "module": "main.js",
@@ -21,5 +21,9 @@
21
21
  },
22
22
  "devDependencies": {
23
23
  "@types/node": "^20.12.7"
24
+ },
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "https://github.com/BobFrankston/miscassists.git"
24
28
  }
25
29
  }
package/.gitattributes DELETED
@@ -1,12 +0,0 @@
1
- # Ensure consistent line endings
2
- * text=auto eol=lf
3
-
4
- # Explicitly declare text files
5
- *.js text eol=lf
6
- *.ts text eol=lf
7
- *.json text eol=lf
8
- *.md text eol=lf
9
-
10
- # Denote binary files
11
- *.png binary
12
- *.jpg binary
@@ -1,18 +0,0 @@
1
- {
2
- // Use IntelliSense to learn about possible attributes.
3
- // Hover to view descriptions of existing attributes.
4
- // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
- "version": "0.2.0",
6
- "configurations": [
7
- {
8
- "type": "node",
9
- "request": "launch",
10
- "name": "Launch Program",
11
- "program": "${workspaceFolder}/index.js",
12
- "skipFiles": [ "<node_internals>/**" ],
13
- "outFiles": [
14
- "${workspaceFolder}/**/*.js"
15
- ]
16
- }
17
- ]
18
- }
@@ -1,23 +0,0 @@
1
- {
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"
23
- }
@@ -1,20 +0,0 @@
1
- {
2
- "version": "2.0.0",
3
- "tasks": [
4
- {
5
- "label": "tsc: watch",
6
- "type": "shell",
7
- "command": "tsc",
8
- "args": ["--watch"],
9
- "runOptions": {
10
- "runOn": "folderOpen"
11
- },
12
- "problemMatcher": "$tsc-watch",
13
- "isBackground": true,
14
- "group": {
15
- "kind": "build",
16
- "isDefault": true
17
- }
18
- }
19
- ]
20
- }
@@ -1 +0,0 @@
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,CAAC;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AAqG;AACzG,CAAC,EAvJS,MAAM,KAAN,MAAM,QAuJf"}
package/checkaddress.ts DELETED
@@ -1,158 +0,0 @@
1
- // From y:\dev\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.map DELETED
@@ -1 +0,0 @@
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,IA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GAAG,GAAG,GAAG,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,GAAG;YAAE,OAAO,IAAI,CAAC;IAClD,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;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,CAAC;QACpC,OAAO,IAAI,CAAC;IAChB,CAAC;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 DELETED
@@ -1,113 +0,0 @@
1
- import dns from 'dns';
2
- import os from 'os'
3
-
4
- /***
5
- * return IPv4 address giving local addresses priority
6
- */
7
-
8
- export const default_fqdn = 'aaz.lt'; // For now
9
-
10
- export async function resolve4(name: string, local?: boolean): Promise<string> {
11
- if (!name?.includes('.')) name += '.' + default_fqdn; // FQDN Hack
12
-
13
- return new Promise((resolve, reject) => dns.resolve4(name,
14
- (err: any, ips) => {
15
- if (err)
16
- return resolve(null);
17
-
18
- const locals = ips.filter(ip => isLocalIP(ip));
19
- if (locals.length > 0)
20
- return resolve(locals[0]);
21
- if (local)
22
- return resolve(null);
23
-
24
- resolve(ips[0]);
25
- }
26
- ));
27
- }
28
-
29
- export async function resolveLocal4(name: string): Promise<string> {
30
- return await resolve4(name, true);
31
- }
32
-
33
- // #region Local IP address
34
-
35
- interface localIPAndMask { ipn: number, mask: number, s: { ip: string, mask: string } };
36
- export let localIPAndMasks: localIPAndMask[] = null;
37
-
38
- function ipv4ToInt(ip: string): number {
39
- ip = ip.replace('::ffff:', ''); // Convert IPv4-mapped IPv6 addresses to their IPv4 representation
40
- const octets = ip.split(".").map(o => parseInt(o));
41
- // let z8 = octets.reduce((acc, octet) => (acc << 8) + octet);
42
- let x8 = arrayToUint32(octets.reverse());
43
- return x8;
44
- }
45
-
46
- function arrayToUint32(arr: number[]): number {
47
- const uint8Arr = Uint8Array.from(arr);
48
- const uint32Arr = new Uint32Array(uint8Arr.buffer);
49
- return uint32Arr[0];
50
- }
51
-
52
- function assureLocalV4Address() {
53
- // 2023-12-18 removed caching so we can change it on the fly
54
- // if (localIPAndMasks)
55
- // return localIPAndMasks;
56
- localIPAndMasks = [];
57
- const interfaces = os.networkInterfaces();
58
-
59
- for (const name of Object.keys(interfaces)) {
60
- for (const netinterface of interfaces[name]) {
61
- if (netinterface.family !== 'IPv4') continue;
62
- if (netinterface.internal) continue;
63
- const mask = ipv4ToInt(netinterface.netmask);
64
- const ipn = ipv4ToInt(netinterface.address) & mask;
65
- localIPAndMasks.push({ ipn, mask, s: { ip: netinterface.address, mask: netinterface.netmask } });
66
- }
67
- }
68
- return localIPAndMasks;
69
- }
70
-
71
- export function isLocalIP(ip: string) {
72
- if (isThisMachine(ip))
73
- return true; // It handles special cases better
74
- const ipn = ipv4ToInt(ip);
75
- for (var ipm of assureLocalV4Address()) {
76
- if ((ipn & ipm.mask) === ipm.ipn) return true;
77
- }
78
- return false;
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.map DELETED
@@ -1 +0,0 @@
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,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAExC,OAAO,EAAuB,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1D,OAAO,EACH,QAAQ,EAAE,aAAa,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAC/D,KAAK,EAAE,IAAI,EAAqC,MAAM,EACzD,CAAC;AAEF,MAAM,CAAC,MAAM,MAAM,GAAG;IAClB,SAAS,EAAE,EAAE;CAChB,CAAA;AAED,eAAe;IACX,QAAQ;IACR,aAAa;IACb,SAAS;IACT,aAAa;IACb,YAAY;IACZ,KAAK;IACL,IAAI;IACJ,MAAM;IACN,MAAM;CACT,CAAA"}
package/index.ts DELETED
@@ -1,25 +0,0 @@
1
- import { resolve4, resolveLocal4, isLocalIP, isThisMachine, default_fqdn } from './dnsassist.js'
2
- import { ports, mqtt } from './ports.js'
3
- import { makerPayload } from './maker.js';
4
- import { jSubSiteInfo, jpriv, jprivs } from './jserve.js';
5
-
6
- export {
7
- resolve4, resolveLocal4, isLocalIP, isThisMachine, default_fqdn,
8
- ports, mqtt, makerPayload, jSubSiteInfo, jpriv, jprivs
9
- };
10
-
11
- export const values = {
12
- exitRunit: 99,
13
- }
14
-
15
- export default {
16
- resolve4,
17
- resolveLocal4,
18
- isLocalIP,
19
- isThisMachine,
20
- default_fqdn,
21
- ports,
22
- mqtt,
23
- jprivs,
24
- values
25
- }
package/jserve.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"jserve.js","sourceRoot":"","sources":["jserve.ts"],"names":[],"mappings":"AAAA,qCAAqC;AAErC,uEAAuE;AAEvE,8BAA8B;AAC9B,gDAAgD;AAChD,iEAAiE;AAEjE,MAAM,CAAC,MAAM,MAAM,GAAG;IAClB,OAAO,EAAa,iBAAiB;IACrC,MAAM,EAAc,cAAc;IAClC,OAAO,EAAa,sBAAsB;IAC1C,MAAM,EAAc,eAAe;IACnC,KAAK;CAAC,CAAC,CAAa,gBAAgB"}
package/jserve.ts DELETED
@@ -1,25 +0,0 @@
1
- // Support for connecting with jserve
2
-
3
- // This can be passed via the default value or, better, via the JExport
4
-
5
- // Note that a client entry is
6
- // name or pfx:name so you can say "ui:useful"
7
- // * means deafult so you can /subpapp rather than /subapp/name
8
-
9
- export const jprivs = [
10
- "admin", // Uber privilege
11
- "user", // Normal user
12
- "guest", // Low privilege guest
13
- "home", // Home control
14
- "bbs"]; // bbs (bbt) app
15
- export type jpriv = typeof jprivs[number];
16
-
17
- // export type jpriv = "admin" | "user" | "guest";
18
-
19
- export interface jSubSiteInfo {
20
- app: object; // Express -- so we don't nee the Express definition in miscassists
21
- AppInit?: () => Promise<void>
22
- subClients?: string[]; // Dirname or path to html file
23
- privs?: jpriv[];
24
- localLogin?: boolean; // If true, use local login. Allow remember?
25
- }
package/maker.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"maker.js","sourceRoot":"","sources":["maker.ts"],"names":[],"mappings":"AAAA,iCAAiC"}
package/maker.ts DELETED
@@ -1,14 +0,0 @@
1
- // Support for Hubitat and Devqtt
2
-
3
-
4
- export interface makerPayload {
5
- content: {
6
- name: string,
7
- value: string,
8
- displayName: string,
9
- deviceId: string,
10
- descriptionText: string,
11
- unit: object,
12
- data: object
13
- }
14
- }
package/ports.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"ports.js","sourceRoot":"","sources":["ports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,MAAM,CAAC,MAAM,KAAK,GAAG;IACjB,OAAO,EAAG,KAAK;IACf,QAAQ,EAAE,KAAK,EAAS,mDAAmD;IAE3E,SAAS,EAAE,IAAI,EAAS,+BAA+B;IACvD,QAAQ,EAAE,IAAI,EAAU,sCAAsC;IAE9D,OAAO,EAAE,IAAI,EAAW,+CAA+C;IACvE,QAAQ,EAAE,IAAI,EAAU,oDAAoD;IAE5E,OAAO,EAAE,IAAI,EAAW,oDAAoD;IAC5E,OAAO,EAAE,IAAI,EAAW,8CAA8C;IACtE,QAAQ,EAAE,IAAI,EAAU,uCAAuC;IAE/D,IAAI,EAAE,IAAI,EAAc,0CAA0C;IAClE,KAAK,EAAE,IAAI,EAAa,GAAG;IAE3B,MAAM,EAAE,IAAI,EAAY,2BAA2B;IACnD,OAAO,EAAE,IAAI;IAEb,MAAM,EAAE,IAAI;IACZ,OAAO,EAAE,IAAI,EAAW,UAAU;IAElC,SAAS,EAAE,IAAI,EAAS,mDAAmD;IAE3E,QAAQ,EAAE,IAAI;IACd,SAAS,EAAE,IAAI;IAEf,QAAQ,EAAE,IAAI,EAAU,uEAAuE;IAC/F,QAAQ,EAAE,IAAI;IAEd,MAAM,EAAE,IAAI,EAAY,mEAAmE;IAE3F,MAAM,EAAE,IAAI,EAAY,eAAe;IACvC,MAAM,EAAE,IAAI,EAAY,wBAAwB;IAChD,SAAS,EAAE,IAAI;IAEf,GAAG,EAAE,IAAI,EAAe,0BAA0B;IAClD,MAAM,EAAE,IAAI;IACZ,SAAS,EAAE,IAAI;IAEf,MAAM,EAAE,IAAI;IAEZ,MAAM,EAAE,IAAI;IACZ,KAAK,EAAE,IAAI;IAEX,KAAK,EAAE,IAAI,EAAa,sGAAsG;IAE9H,SAAS,EAAE,IAAI,EAAS,qCAAqC;IAE7D,OAAO,EAAE,IAAI;CAEhB,CAAA;AAED,MAAM,QAAQ,GAAG,MAAM,CAAC;AACxB,MAAM,QAAQ,GAAG,IAAI,CAAC;AAEtB,MAAM,CAAC,MAAM,IAAI,GAAG;IAChB,IAAI,EAAE,QAAQ;IACd,IAAI,EAAE,QAAQ;IACd,KAAK,EAAE;QACH,GAAG,EAAE,KAAK;QACV,SAAS,EAAE;YACP,OAAO,EAAE,SAAS;SACrB;QACD,MAAM,EAAE;YACJ,GAAG,EAAE,KAAK;YACV,GAAG,EAAE,QAAQ;SAChB;KACJ;IACD,GAAG,EAAE,UAAU,QAAQ,IAAI,YAAY,IAAI,QAAQ,EAAE;CACxD,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 DELETED
@@ -1,97 +0,0 @@
1
- import { default_fqdn } from "./dnsassist.js";
2
-
3
- export const ports = {
4
- jserve2: 10080,
5
- jserve2s: 10443, // For now, we use the same port for http and https
6
-
7
- devlisten: 9070, // Hubitat MakerAPI http server
8
- halisten: 9071, // Home Assistant MakerAPI http server
9
-
10
- rmfsite: 9081, // These will be phased out for the new version
11
- rmfsites: 9082, // used to be for SSL but now any port is ssl or not
12
-
13
- rmfprod: 9081, // Secondary port for production version (debugging)
14
- rmfbeta: 9082, // Secondary port for beta version (debugging)
15
- rmfalpha: 9083, // Secondary port for the alpha version
16
-
17
- shim: 9084, // Warming -- these are current forwarded!
18
- shims: 9085, //
19
-
20
- jvport: 9180, // These are copied in hlib
21
- jvports: 9143,
22
-
23
- sqltcp: 9098,
24
- sqlhttp: 9099, // For now
25
-
26
- sqlproxy2: 9097, // Replace sqlproxy and share a port for http/https
27
-
28
- sqlproxy: 9080,
29
- sqlproxys: 9043,
30
-
31
- mlplanel: 9300, // Note: This must jibe with mlpanel since we copy it to another system
32
- mlpanels: 9301,
33
-
34
- wizzer: 9310, // Work in progress Wiz control. Internal only so not https for now
35
-
36
- pserve: 9311, // Photo server
37
- vserve: 9312, // Video server from IIS
38
- checkmake: 9313,
39
-
40
- bbt: 9314, // Bulletin board test
41
- backts: 9315,
42
- backserve: 9316,
43
-
44
- syncer: 9317,
45
-
46
- lifxer: 9318,
47
- itemw: 9319,
48
-
49
- pinst: 9299, // Used for my pings server [currently it has a local value because --install-links isn't cooperating]
50
-
51
- stephanie: 9320, // For testing stephanie site locally
52
-
53
- httpudp: 9321
54
-
55
- }
56
-
57
- const mqttHost = "pi4c";
58
- const mqttPort = 1883;
59
-
60
- export const mqtt = {
61
- host: mqttHost,
62
- port: mqttPort,
63
- topic: { // Default for our own use
64
- rmf: "rmf",
65
- subtopics: {
66
- restart: "restart",
67
- },
68
- devqtt: {
69
- top: "rmf",
70
- sub: "devqtt"
71
- }
72
- },
73
- URL: `mstt://${mqttHost}.${default_fqdn}:${mqttPort}`
74
- }
75
-
76
- // <port port="9070" name="Listen for Hubitat (experimental)" />
77
- // <port port="9080" name="birdbox1:80" />
78
- // <port port="9081" name="Home port for home.rmf.vc et al" />
79
- // <port port="9082" name="Home port for home.rmf.vc et al for SSL" />
80
- // <port port="9083" name="Web Sockets for home control" />
81
- // <port port="9084" name="Insteon Shim" />
82
- // <port port="9085" name="Insteon Shim SSL (reserved)" />
83
- // <port port="9086" name="shimmer" />
84
- // <port port="9087" name="shimmer SSL (not yet)" />
85
- // <port port="9088" name="TCP For NodeSQLAssit" />
86
- // <port port="9089" name="TCP Shelly Listener (HTLog)" />
87
- // <port port="9389" name="Birdbox1:3389" />
88
- // <port port="9920" name="HC XML" />
89
- // <!-- <port port="9994" name="HC TCP Listener" /> -->
90
- // <port port="9800-9899" name="HC TCP Listener" />
91
- // <!-- <port port="9960-9969" name="HC TCP Listener" /> -->
92
- // <port port="9995" name="HC xcmd" />
93
- // <port port="9996" name="HC Manual" />
94
- // <port port="9997" name="HC HTTP" />
95
- // <port port="9970-9979" name="HC Telnet" />
96
- // <port port="9901" name="Lightify Client1" />
97
- //
package/tsconfig.json DELETED
@@ -1,14 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "esnext",
4
- "module": "esnext",
5
- "moduleResolution": "node",
6
- "sourceMap": true,
7
- "esModuleInterop": true,
8
- "forceConsistentCasingInFileNames": true,
9
- "strict": true,
10
- "strictNullChecks": false,
11
- "skipLibCheck": true,
12
- "newLine": "lf"
13
- }
14
- }