pmcf 1.102.0 → 1.102.2
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/package.json +1 -1
- package/src/service.mjs +4 -3
- package/src/services/dns.mjs +2 -3
- package/src/services/ntp.mjs +2 -1
- package/src/utils.mjs +38 -10
- package/types/service.d.mts +1 -1
- package/types/utils.d.mts +8 -8
package/package.json
CHANGED
package/src/service.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Base } from "./base.mjs";
|
|
2
2
|
import { addType } from "./types.mjs";
|
|
3
|
-
import { asArray } from "./utils.mjs";
|
|
3
|
+
import { asArray,isLocalhost } from "./utils.mjs";
|
|
4
4
|
import { networkAddressProperties } from "./network-support.mjs";
|
|
5
5
|
import {
|
|
6
6
|
DNSRecord,
|
|
@@ -277,12 +277,13 @@ export const sortByPriority = (a, b) => a.priority - b.priority;
|
|
|
277
277
|
export function serviceAddresses(
|
|
278
278
|
sources,
|
|
279
279
|
filter,
|
|
280
|
-
addressType = "rawAddresses"
|
|
280
|
+
addressType = "rawAddresses",
|
|
281
|
+
addressFilter = a=>!isLocalhost(a)
|
|
281
282
|
) {
|
|
282
283
|
return asArray(sources)
|
|
283
284
|
.map(ft => Array.from(ft.findServices(filter)))
|
|
284
285
|
.flat()
|
|
285
286
|
.sort(sortByPriority)
|
|
286
287
|
.map(s => s[addressType])
|
|
287
|
-
.flat();
|
|
288
|
+
.flat().filter(addressFilter);
|
|
288
289
|
}
|
package/src/services/dns.mjs
CHANGED
|
@@ -5,8 +5,7 @@ import {
|
|
|
5
5
|
writeLines,
|
|
6
6
|
isIPv6Address,
|
|
7
7
|
normalizeIPAddress,
|
|
8
|
-
isLinkLocal
|
|
9
|
-
isLocalhost
|
|
8
|
+
isLinkLocal
|
|
10
9
|
} from "../utils.mjs";
|
|
11
10
|
import { DNSRecord, dnsFullName } from "../dns-utils.mjs";
|
|
12
11
|
import { addType } from "../types.mjs";
|
|
@@ -158,7 +157,7 @@ export class DNSService extends Service {
|
|
|
158
157
|
DNS: serviceAddresses(this, {
|
|
159
158
|
...DNS_SERVICE_FILTER,
|
|
160
159
|
priority: "<10"
|
|
161
|
-
}).
|
|
160
|
+
}).join(" "),
|
|
162
161
|
FallbackDNS: serviceAddresses(this, {
|
|
163
162
|
...DNS_SERVICE_FILTER,
|
|
164
163
|
priority: ">=10"
|
package/src/services/ntp.mjs
CHANGED
package/src/utils.mjs
CHANGED
|
@@ -79,7 +79,12 @@ export function asIterator(value) {
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
export function isIPv4Address(address) {
|
|
82
|
-
|
|
82
|
+
switch (typeof address) {
|
|
83
|
+
case "string":
|
|
84
|
+
return address.indexOf(".") >= 0;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return false;
|
|
83
88
|
}
|
|
84
89
|
|
|
85
90
|
export function generateEU64(mac) {
|
|
@@ -123,6 +128,7 @@ const ipv4 = {
|
|
|
123
128
|
};
|
|
124
129
|
const ipv6 = {
|
|
125
130
|
separator: ":",
|
|
131
|
+
compressor: "::",
|
|
126
132
|
length: 128,
|
|
127
133
|
segmentLength: 16,
|
|
128
134
|
segmentMask: 0xffffn,
|
|
@@ -132,22 +138,44 @@ const ipv6 = {
|
|
|
132
138
|
};
|
|
133
139
|
|
|
134
140
|
function _decode(definition, address, length = definition.length) {
|
|
135
|
-
|
|
141
|
+
let result = "";
|
|
142
|
+
let compressed = 0;
|
|
136
143
|
let shift = definition.length;
|
|
144
|
+
let j, word;
|
|
145
|
+
const last = length / definition.segmentLength;
|
|
146
|
+
|
|
147
|
+
for (let i = 0; i < last; i = j + 1) {
|
|
148
|
+
for (j = i; j < last; j++) {
|
|
149
|
+
shift -= definition.segmentLength;
|
|
150
|
+
word = (address >> BigInt(shift)) & definition.segmentMask;
|
|
137
151
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
152
|
+
if (word !== 0n || !definition.compressor || compressed > 0) {
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (j > i + 1) {
|
|
158
|
+
compressed++;
|
|
159
|
+
result += definition.compressor;
|
|
160
|
+
} else {
|
|
161
|
+
if (result.length > 0) {
|
|
162
|
+
result += definition.separator;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (j < last) {
|
|
167
|
+
result += word.toString(definition.base).padStart(definition.pad, "0");
|
|
168
|
+
}
|
|
145
169
|
}
|
|
146
170
|
|
|
147
|
-
return
|
|
171
|
+
return result;
|
|
148
172
|
}
|
|
149
173
|
|
|
150
174
|
export function _encode(definition, address) {
|
|
175
|
+
if (typeof address !== "string") {
|
|
176
|
+
return address;
|
|
177
|
+
}
|
|
178
|
+
|
|
151
179
|
let res = 0n;
|
|
152
180
|
let shift = BigInt(definition.length);
|
|
153
181
|
|
package/types/service.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export function serviceAddresses(sources: any, filter: any, addressType?: string): any[];
|
|
1
|
+
export function serviceAddresses(sources: any, filter: any, addressType?: string, addressFilter?: (a: any) => boolean): any[];
|
|
2
2
|
export namespace ServiceTypeDefinition {
|
|
3
3
|
export let name: string;
|
|
4
4
|
export let owners: string[];
|
package/types/utils.d.mts
CHANGED
|
@@ -11,13 +11,13 @@ export function isIPv6Address(address: any): boolean;
|
|
|
11
11
|
export function isLinkLocal(address: any): any;
|
|
12
12
|
export function isLocalhost(address: any): boolean;
|
|
13
13
|
export function normalizeIPAddress(address: any): any;
|
|
14
|
-
export function _encode(definition: any, address: any):
|
|
14
|
+
export function _encode(definition: any, address: any): any;
|
|
15
15
|
export function decodeIPv6(address: any, length: any): string;
|
|
16
|
-
export function encodeIPv6(address: any):
|
|
16
|
+
export function encodeIPv6(address: any): any;
|
|
17
17
|
export function decodeIPv4(address: any, length: any): string;
|
|
18
|
-
export function encodeIPv4(address: any):
|
|
18
|
+
export function encodeIPv4(address: any): any;
|
|
19
19
|
export function decodeIP(address: any, length: any): string;
|
|
20
|
-
export function encodeIP(address: any):
|
|
20
|
+
export function encodeIP(address: any): any;
|
|
21
21
|
export function formatCIDR(address: any, subnet: any): any;
|
|
22
22
|
export function normalizeCIDR(address: any): {
|
|
23
23
|
prefix?: undefined;
|
|
@@ -29,7 +29,7 @@ export function normalizeCIDR(address: any): {
|
|
|
29
29
|
cidr: string;
|
|
30
30
|
};
|
|
31
31
|
export function hasWellKnownSubnet(address: any): any;
|
|
32
|
-
export const IPV4_LOCALHOST:
|
|
33
|
-
export const IPV6_LOCALHOST:
|
|
34
|
-
export const IPV6_LINK_LOCAL_BROADCAST:
|
|
35
|
-
export const IPV6_ROUTER_BROADCAST:
|
|
32
|
+
export const IPV4_LOCALHOST: any;
|
|
33
|
+
export const IPV6_LOCALHOST: any;
|
|
34
|
+
export const IPV6_LINK_LOCAL_BROADCAST: any;
|
|
35
|
+
export const IPV6_ROUTER_BROADCAST: any;
|