pmcf 2.24.2 → 2.25.0
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/endpoint.mjs +37 -0
- package/src/module.mjs +6 -4
- package/src/network-address.mjs +33 -0
- package/src/network-interface.mjs +4 -40
- package/src/service.mjs +4 -39
- package/src/services/dhcp.mjs +9 -10
- package/src/services/ntp.mjs +8 -4
- package/types/endpoint.d.mts +13 -0
- package/types/module.d.mts +6 -4
- package/types/network-address.d.mts +17 -0
- package/types/network-interface.d.mts +3 -19
- package/types/service.d.mts +1 -13
- package/types/services/dhcp.d.mts +1 -1
package/package.json
CHANGED
package/src/endpoint.mjs
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export class Endpoint {
|
|
2
|
+
constructor(service, networkAddress, data) {
|
|
3
|
+
this.service = service;
|
|
4
|
+
this.networkAddress = networkAddress;
|
|
5
|
+
Object.assign(this, data);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
toString() {
|
|
9
|
+
return `${this.address}[${this.port}]`;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
get socketAddress() {
|
|
13
|
+
return `${this.address}:${this.port}`;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
get hostName() {
|
|
17
|
+
return this.networkAddress.networkInterface.hostName;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
#address;
|
|
21
|
+
|
|
22
|
+
get address() {
|
|
23
|
+
return this.#address ?? this.networkAddress.address;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
set address(value) {
|
|
27
|
+
this.#address = value;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
get family() {
|
|
31
|
+
return this.networkAddress.family;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
get networkInterface() {
|
|
35
|
+
return this.networkAddress.networkInterface;
|
|
36
|
+
}
|
|
37
|
+
}
|
package/src/module.mjs
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
export * from "./base.mjs";
|
|
2
|
-
export * from "./service.mjs";
|
|
3
|
-
export * from "./services/dns.mjs";
|
|
4
|
-
export * from "./services/ntp.mjs";
|
|
5
|
-
export * from "./services/dhcp.mjs";
|
|
6
2
|
export * from "./cluster.mjs";
|
|
7
3
|
export * from "./owner.mjs";
|
|
8
4
|
export * from "./location.mjs";
|
|
@@ -10,7 +6,13 @@ export * from "./root.mjs";
|
|
|
10
6
|
export * from "./address.mjs";
|
|
11
7
|
export * from "./subnet.mjs";
|
|
12
8
|
export * from "./network.mjs";
|
|
9
|
+
export * from "./network-address.mjs";
|
|
13
10
|
export * from "./network-support.mjs";
|
|
14
11
|
export * from "./network-interface.mjs";
|
|
15
12
|
export * from "./host.mjs";
|
|
13
|
+
export * from "./service.mjs";
|
|
14
|
+
export * from "./endpoint.mjs";
|
|
15
|
+
export * from "./services/dns.mjs";
|
|
16
|
+
export * from "./services/ntp.mjs";
|
|
17
|
+
export * from "./services/dhcp.mjs";
|
|
16
18
|
export * from "./types.mjs";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { familyIP, formatCIDR } from "ip-utilties";
|
|
2
|
+
import { Subnet } from "./subnet.mjs";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @property {NetworkInterface} networkInterface
|
|
6
|
+
* @property {string|Uint8Array|Uint16Array} address
|
|
7
|
+
* @property {string} family
|
|
8
|
+
* @property {Subnet} subnet
|
|
9
|
+
* @property {Set<string>} domainNames
|
|
10
|
+
*/
|
|
11
|
+
export class NetworkAddress {
|
|
12
|
+
/** @type {Subnet} */ subnet;
|
|
13
|
+
/** @type {NetworkInterface} */ networkInterface;
|
|
14
|
+
/** @type {string|Uint8Array|Uint16Array} */ address;
|
|
15
|
+
|
|
16
|
+
constructor(networkInterface, address, subnet) {
|
|
17
|
+
this.networkInterface = networkInterface;
|
|
18
|
+
this.address = address;
|
|
19
|
+
this.subnet = subnet;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
get domainNames() {
|
|
23
|
+
return this.networkInterface.domainNames;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
get family() {
|
|
27
|
+
return familyIP(this.address);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
get cidrAddress() {
|
|
31
|
+
return formatCIDR(this.address, this.subnet.prefixLength);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -1,15 +1,10 @@
|
|
|
1
|
+
import { hasWellKnownSubnet, normalizeIP } from "ip-utilties";
|
|
1
2
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
familyIP,
|
|
5
|
-
formatCIDR
|
|
6
|
-
} from "ip-utilties";
|
|
7
|
-
import { Base } from "./base.mjs";
|
|
8
|
-
import {
|
|
9
|
-
Subnet,
|
|
3
|
+
NetworkAddress,
|
|
4
|
+
Base,
|
|
10
5
|
SUBNET_LOCALHOST_IPV4,
|
|
11
6
|
SUBNET_LOCALHOST_IPV6
|
|
12
|
-
} from "
|
|
7
|
+
} from "pmcf";
|
|
13
8
|
import {
|
|
14
9
|
networkProperties,
|
|
15
10
|
networkAddressProperties
|
|
@@ -17,37 +12,6 @@ import {
|
|
|
17
12
|
import { asArray } from "./utils.mjs";
|
|
18
13
|
import { addType } from "./types.mjs";
|
|
19
14
|
|
|
20
|
-
/**
|
|
21
|
-
* @property {NetworkInterface} networkInterface
|
|
22
|
-
* @property {string|Uint8Array|Uint16Array} address
|
|
23
|
-
* @property {string} family
|
|
24
|
-
* @property {Subnet} subnet
|
|
25
|
-
* @property {Set<string>} domainNames
|
|
26
|
-
*/
|
|
27
|
-
export class NetworkAddress {
|
|
28
|
-
/** @type {Subnet} */ subnet;
|
|
29
|
-
/** @type {NetworkInterface} */ networkInterface;
|
|
30
|
-
/** @type {string|Uint8Array|Uint16Array} */ address;
|
|
31
|
-
|
|
32
|
-
constructor(networkInterface, address, subnet) {
|
|
33
|
-
this.networkInterface = networkInterface;
|
|
34
|
-
this.address = address;
|
|
35
|
-
this.subnet = subnet;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
get domainNames() {
|
|
39
|
-
return this.networkInterface.domainNames;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
get family() {
|
|
43
|
-
return familyIP(this.address);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
get cidrAddress() {
|
|
47
|
-
return formatCIDR(this.address, this.subnet.prefixLength);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
15
|
class SkeletonNetworkInterface extends Base {
|
|
52
16
|
_extends = [];
|
|
53
17
|
_network;
|
package/src/service.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { isLocalhost
|
|
2
|
-
import { Base } from "
|
|
1
|
+
import { isLocalhost } from "ip-utilties";
|
|
2
|
+
import { Base, Endpoint } from "pmcf";
|
|
3
3
|
import { addType } from "./types.mjs";
|
|
4
4
|
import { asArray } from "./utils.mjs";
|
|
5
5
|
import { networkAddressProperties } from "./network-support.mjs";
|
|
@@ -189,12 +189,11 @@ export class Service extends Base {
|
|
|
189
189
|
];
|
|
190
190
|
|
|
191
191
|
const result = [...this.server.networkAddresses()]
|
|
192
|
-
.map(
|
|
192
|
+
.map(na =>
|
|
193
193
|
data.map(
|
|
194
194
|
d =>
|
|
195
|
-
new Endpoint(this,
|
|
195
|
+
new Endpoint(this, na, {
|
|
196
196
|
...d,
|
|
197
|
-
address: sa.address,
|
|
198
197
|
...local
|
|
199
198
|
})
|
|
200
199
|
)
|
|
@@ -310,40 +309,6 @@ export class Service extends Base {
|
|
|
310
309
|
}
|
|
311
310
|
}
|
|
312
311
|
|
|
313
|
-
export class Endpoint {
|
|
314
|
-
constructor(service, networkInterface, data) {
|
|
315
|
-
this.service = service;
|
|
316
|
-
this.networkInterface = networkInterface;
|
|
317
|
-
Object.assign(this, data);
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
toString() {
|
|
321
|
-
return `${this.address}[${this.port}]`;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
get socketAddress() {
|
|
325
|
-
return `${this.address}:${this.port}`;
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
get hostName() {
|
|
329
|
-
return this.networkInterface.hostName;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
#address;
|
|
333
|
-
|
|
334
|
-
get address() {
|
|
335
|
-
return this.#address ?? this.networkInterface.address;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
set address(value) {
|
|
339
|
-
this.#address = value;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
get family() {
|
|
343
|
-
return familyIP(this.address);
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
|
|
347
312
|
export const sortByPriority = (a, b) => a.priority - b.priority;
|
|
348
313
|
|
|
349
314
|
export function serviceAddresses(
|
package/src/services/dhcp.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
ServiceTypeDefinition,
|
|
6
6
|
Endpoint,
|
|
7
7
|
serviceEndpoints
|
|
8
|
-
} from "
|
|
8
|
+
} from "pmcf";
|
|
9
9
|
import { addType } from "../types.mjs";
|
|
10
10
|
import { writeLines } from "../utils.mjs";
|
|
11
11
|
|
|
@@ -52,17 +52,16 @@ export class DHCPService extends Service {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
endpoints(filter) {
|
|
55
|
-
const
|
|
55
|
+
const endpoints = super.endpoints(filter);
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
];
|
|
57
|
+
for (const na of this.server.networkAddresses(
|
|
58
|
+
na => na.networkInterface.kind === "localhost"
|
|
59
|
+
)) {
|
|
60
|
+
endpoints.push(new Endpoint(this, na, controlAgentEndpoint));
|
|
61
|
+
endpoints.push(new Endpoint(this, na, ddnsEndpoint));
|
|
63
62
|
}
|
|
64
63
|
|
|
65
|
-
return
|
|
64
|
+
return endpoints;
|
|
66
65
|
}
|
|
67
66
|
|
|
68
67
|
async *preparePackages(dir) {
|
|
@@ -256,7 +255,7 @@ export class DHCPService extends Service {
|
|
|
256
255
|
}
|
|
257
256
|
],
|
|
258
257
|
subnet4: [...subnets]
|
|
259
|
-
.filter(s => s.family===
|
|
258
|
+
.filter(s => s.family === "IPv4")
|
|
260
259
|
.map((subnet, index) => {
|
|
261
260
|
return {
|
|
262
261
|
id: index + 1,
|
package/src/services/ntp.mjs
CHANGED
|
@@ -85,10 +85,14 @@ export class NTPService extends ExtraSourceService {
|
|
|
85
85
|
};
|
|
86
86
|
|
|
87
87
|
const lines = [
|
|
88
|
-
...serviceEndpoints(
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
88
|
+
...serviceEndpoints(
|
|
89
|
+
this,
|
|
90
|
+
{
|
|
91
|
+
...NTP_SERVICE_FILTER,
|
|
92
|
+
priority: ">=10"
|
|
93
|
+
},
|
|
94
|
+
e => e.family === 'IPv4' && e.networkInterface.kind !== "loopback"
|
|
95
|
+
).map(
|
|
92
96
|
endpoint =>
|
|
93
97
|
`${endpoint.service.isPool ? "pool" : "server"} ${
|
|
94
98
|
endpoint.address
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export class Endpoint {
|
|
2
|
+
constructor(service: any, networkAddress: any, data: any);
|
|
3
|
+
service: any;
|
|
4
|
+
networkAddress: any;
|
|
5
|
+
toString(): string;
|
|
6
|
+
get socketAddress(): string;
|
|
7
|
+
get hostName(): any;
|
|
8
|
+
set address(value: any);
|
|
9
|
+
get address(): any;
|
|
10
|
+
get family(): any;
|
|
11
|
+
get networkInterface(): any;
|
|
12
|
+
#private;
|
|
13
|
+
}
|
package/types/module.d.mts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
export * from "./base.mjs";
|
|
2
|
-
export * from "./service.mjs";
|
|
3
|
-
export * from "./services/dns.mjs";
|
|
4
|
-
export * from "./services/ntp.mjs";
|
|
5
|
-
export * from "./services/dhcp.mjs";
|
|
6
2
|
export * from "./cluster.mjs";
|
|
7
3
|
export * from "./owner.mjs";
|
|
8
4
|
export * from "./location.mjs";
|
|
@@ -10,7 +6,13 @@ export * from "./root.mjs";
|
|
|
10
6
|
export * from "./address.mjs";
|
|
11
7
|
export * from "./subnet.mjs";
|
|
12
8
|
export * from "./network.mjs";
|
|
9
|
+
export * from "./network-address.mjs";
|
|
13
10
|
export * from "./network-support.mjs";
|
|
14
11
|
export * from "./network-interface.mjs";
|
|
15
12
|
export * from "./host.mjs";
|
|
13
|
+
export * from "./service.mjs";
|
|
14
|
+
export * from "./endpoint.mjs";
|
|
15
|
+
export * from "./services/dns.mjs";
|
|
16
|
+
export * from "./services/ntp.mjs";
|
|
17
|
+
export * from "./services/dhcp.mjs";
|
|
16
18
|
export * from "./types.mjs";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @property {NetworkInterface} networkInterface
|
|
3
|
+
* @property {string|Uint8Array|Uint16Array} address
|
|
4
|
+
* @property {string} family
|
|
5
|
+
* @property {Subnet} subnet
|
|
6
|
+
* @property {Set<string>} domainNames
|
|
7
|
+
*/
|
|
8
|
+
export class NetworkAddress {
|
|
9
|
+
constructor(networkInterface: any, address: any, subnet: any);
|
|
10
|
+
/** @type {Subnet} */ subnet: Subnet;
|
|
11
|
+
/** @type {NetworkInterface} */ networkInterface: NetworkInterface;
|
|
12
|
+
/** @type {string|Uint8Array|Uint16Array} */ address: string | Uint8Array | Uint16Array;
|
|
13
|
+
get domainNames(): any;
|
|
14
|
+
get family(): any;
|
|
15
|
+
get cidrAddress(): any;
|
|
16
|
+
}
|
|
17
|
+
import { Subnet } from "./subnet.mjs";
|
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @property {NetworkInterface} networkInterface
|
|
3
|
-
* @property {string|Uint8Array|Uint16Array} address
|
|
4
|
-
* @property {string} family
|
|
5
|
-
* @property {Subnet} subnet
|
|
6
|
-
* @property {Set<string>} domainNames
|
|
7
|
-
*/
|
|
8
|
-
export class NetworkAddress {
|
|
9
|
-
constructor(networkInterface: any, address: any, subnet: any);
|
|
10
|
-
/** @type {Subnet} */ subnet: Subnet;
|
|
11
|
-
/** @type {NetworkInterface} */ networkInterface: NetworkInterface;
|
|
12
|
-
/** @type {string|Uint8Array|Uint16Array} */ address: string | Uint8Array | Uint16Array;
|
|
13
|
-
get domainNames(): any;
|
|
14
|
-
get family(): any;
|
|
15
|
-
get cidrAddress(): any;
|
|
16
|
-
}
|
|
17
1
|
export namespace NetworkInterfaceTypeDefinition {
|
|
18
2
|
export let name: string;
|
|
19
3
|
export let priority: number;
|
|
@@ -695,7 +679,7 @@ export class LoopbackNetworkInterface extends SkeletonNetworkInterface {
|
|
|
695
679
|
get kind(): string;
|
|
696
680
|
get scope(): string;
|
|
697
681
|
get hostName(): string;
|
|
698
|
-
get ipAddresses(): Map<string, Subnet>;
|
|
682
|
+
get ipAddresses(): Map<string, import("pmcf").Subnet>;
|
|
699
683
|
}
|
|
700
684
|
export class WireguardNetworkInterface extends SkeletonNetworkInterface {
|
|
701
685
|
static get typeDefinition(): {
|
|
@@ -1022,7 +1006,6 @@ export class WireguardNetworkInterface extends SkeletonNetworkInterface {
|
|
|
1022
1006
|
};
|
|
1023
1007
|
get kind(): string;
|
|
1024
1008
|
}
|
|
1025
|
-
import { Subnet } from "./subnet.mjs";
|
|
1026
1009
|
declare class SkeletonNetworkInterface extends Base {
|
|
1027
1010
|
_extends: any[];
|
|
1028
1011
|
_network: any;
|
|
@@ -1044,5 +1027,6 @@ declare class SkeletonNetworkInterface extends Base {
|
|
|
1044
1027
|
get address(): any;
|
|
1045
1028
|
get addresses(): any[];
|
|
1046
1029
|
}
|
|
1047
|
-
import { Base } from "
|
|
1030
|
+
import { Base } from "pmcf";
|
|
1031
|
+
import { NetworkAddress } from "pmcf";
|
|
1048
1032
|
export {};
|
package/types/service.d.mts
CHANGED
|
@@ -329,17 +329,5 @@ export class Service extends Base {
|
|
|
329
329
|
toString: (maxKeyLength?: number, ttl?: string) => string;
|
|
330
330
|
}[];
|
|
331
331
|
}
|
|
332
|
-
export class Endpoint {
|
|
333
|
-
constructor(service: any, networkInterface: any, data: any);
|
|
334
|
-
service: any;
|
|
335
|
-
networkInterface: any;
|
|
336
|
-
toString(): string;
|
|
337
|
-
get socketAddress(): string;
|
|
338
|
-
get hostName(): any;
|
|
339
|
-
set address(value: any);
|
|
340
|
-
get address(): any;
|
|
341
|
-
get family(): any;
|
|
342
|
-
#private;
|
|
343
|
-
}
|
|
344
332
|
export function sortByPriority(a: any, b: any): number;
|
|
345
|
-
import { Base } from "
|
|
333
|
+
import { Base } from "pmcf";
|