pmcf 1.45.2 → 1.46.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/package.json +1 -1
- package/src/host.mjs +6 -1
- package/src/network.mjs +2 -1
- package/src/types.mjs +13 -0
- package/src/utils.mjs +7 -1
- package/types/network.d.mts +2 -1
- package/types/utils.d.mts +1 -0
package/package.json
CHANGED
package/src/host.mjs
CHANGED
|
@@ -6,7 +6,8 @@ import {
|
|
|
6
6
|
isIPv4Address,
|
|
7
7
|
isIPv6Address,
|
|
8
8
|
normalizeIPAddress,
|
|
9
|
-
formatCIDR
|
|
9
|
+
formatCIDR,
|
|
10
|
+
hasWellKnownSubnet
|
|
10
11
|
} from "./utils.mjs";
|
|
11
12
|
import { addType } from "./types.mjs";
|
|
12
13
|
|
|
@@ -375,6 +376,10 @@ export class NetworkInterface extends Base {
|
|
|
375
376
|
}
|
|
376
377
|
|
|
377
378
|
addSubnet(address) {
|
|
379
|
+
if(hasWellKnownSubnet(address)) {
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
|
|
378
383
|
if (!this.network) {
|
|
379
384
|
this.error("Missing network", address);
|
|
380
385
|
} else {
|
package/src/network.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Owner } from "./owner.mjs";
|
|
2
2
|
import { Subnet } from "./subnet.mjs";
|
|
3
3
|
import { Host } from "./host.mjs";
|
|
4
|
+
import { DNSService } from "./dns.mjs";
|
|
4
5
|
import { addType } from "./types.mjs";
|
|
5
6
|
|
|
6
7
|
export class Network extends Owner {
|
|
@@ -23,7 +24,7 @@ export class Network extends Owner {
|
|
|
23
24
|
hosts: { type: Host, collection: true },
|
|
24
25
|
clusters: { type: "cluster", collection: true },
|
|
25
26
|
subnets: { type: Subnet, collection: true },
|
|
26
|
-
dns: { type:
|
|
27
|
+
dns: { type: DNSService, collection: false }
|
|
27
28
|
//metric: { type: "number" }
|
|
28
29
|
/*kind: { type: "string" },
|
|
29
30
|
scope: { type: "string" },
|
package/src/types.mjs
CHANGED
|
@@ -5,6 +5,19 @@ export function addType(clazz) {
|
|
|
5
5
|
typeDefinition.clazz = clazz;
|
|
6
6
|
|
|
7
7
|
typesByName[typeDefinition.name] = clazz;
|
|
8
|
+
|
|
9
|
+
for (const type of types) {
|
|
10
|
+
for (const [name, property] of Object.entries(
|
|
11
|
+
type.typeDefinition.properties
|
|
12
|
+
)) {
|
|
13
|
+
if (typeof property.type === "string") {
|
|
14
|
+
const t = typesByName[property.type];
|
|
15
|
+
if (t) {
|
|
16
|
+
property.type = t;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
8
21
|
}
|
|
9
22
|
|
|
10
23
|
export const types = [];
|
package/src/utils.mjs
CHANGED
|
@@ -153,7 +153,7 @@ export function normalizeCIDR(address) {
|
|
|
153
153
|
prefixLength = 8;
|
|
154
154
|
prefix = _decode(definition, n, prefixLength);
|
|
155
155
|
} else if (n === IPV6_LOCALHOST) {
|
|
156
|
-
prefixLength =
|
|
156
|
+
prefixLength = 128;
|
|
157
157
|
prefix = _decode(definition, n, prefixLength);
|
|
158
158
|
} else {
|
|
159
159
|
return {};
|
|
@@ -164,5 +164,11 @@ export function normalizeCIDR(address) {
|
|
|
164
164
|
return { prefix, prefixLength, cidr: `${prefix}/${prefixLength}` };
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
+
export function hasWellKnownSubnet(address)
|
|
168
|
+
{
|
|
169
|
+
const n = encodeIP(address);
|
|
170
|
+
return n === IPV4_LOCALHOST || n === IPV6_LOCALHOST;
|
|
171
|
+
}
|
|
172
|
+
|
|
167
173
|
const IPV4_LOCALHOST = _encode(ipv4, "127.0.0.1");
|
|
168
174
|
const IPV6_LOCALHOST = _encode(ipv6, "::1");
|
package/types/network.d.mts
CHANGED
|
@@ -20,7 +20,7 @@ export class Network extends Owner {
|
|
|
20
20
|
collection: boolean;
|
|
21
21
|
};
|
|
22
22
|
dns: {
|
|
23
|
-
type:
|
|
23
|
+
type: typeof DNSService;
|
|
24
24
|
collection: boolean;
|
|
25
25
|
};
|
|
26
26
|
};
|
|
@@ -38,3 +38,4 @@ export class Network extends Owner {
|
|
|
38
38
|
import { Owner } from "./owner.mjs";
|
|
39
39
|
import { Host } from "./host.mjs";
|
|
40
40
|
import { Subnet } from "./subnet.mjs";
|
|
41
|
+
import { DNSService } from "./dns.mjs";
|
package/types/utils.d.mts
CHANGED