pmcf 2.9.1 → 2.10.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/service.mjs +14 -5
- package/src/services/dhcp.mjs +19 -24
- package/src/subnet.mjs +20 -3
- package/types/service.d.mts +1 -0
- package/types/subnet.d.mts +3 -0
package/package.json
CHANGED
package/src/service.mjs
CHANGED
|
@@ -89,7 +89,12 @@ export const ServiceTypeDefinition = {
|
|
|
89
89
|
alias: { type: "string", collection: false, writeable: true },
|
|
90
90
|
type: { type: "string", collection: false, writeable: true },
|
|
91
91
|
weight: { type: "number", collection: false, writeable: true, default: 1 },
|
|
92
|
-
tls: {
|
|
92
|
+
tls: {
|
|
93
|
+
type: "string",
|
|
94
|
+
collection: false,
|
|
95
|
+
writeable: false,
|
|
96
|
+
default: false
|
|
97
|
+
},
|
|
93
98
|
systemd: { type: "string", collection: true, writeable: true }
|
|
94
99
|
}
|
|
95
100
|
};
|
|
@@ -147,14 +152,18 @@ export class Service extends Base {
|
|
|
147
152
|
return this.rawAddresses.map(a => `${a}:${this.port}`);
|
|
148
153
|
}
|
|
149
154
|
|
|
155
|
+
get networks() {
|
|
156
|
+
return this.server.networks;
|
|
157
|
+
}
|
|
158
|
+
|
|
150
159
|
get endpoints() {
|
|
151
160
|
if (!ServiceTypes[this.type]) {
|
|
152
|
-
return [
|
|
153
|
-
{ address: this.rawAddress, port: this._port, tls: false }
|
|
154
|
-
];
|
|
161
|
+
return [{ address: this.rawAddress, port: this._port, tls: false }];
|
|
155
162
|
}
|
|
156
163
|
|
|
157
|
-
return ServiceTypes[this.type].endpoints
|
|
164
|
+
return ServiceTypes[this.type].endpoints.map(e =>
|
|
165
|
+
Object.assign({ address: this.rawAddress }, e)
|
|
166
|
+
);
|
|
158
167
|
}
|
|
159
168
|
|
|
160
169
|
set port(value) {
|
package/src/services/dhcp.mjs
CHANGED
|
@@ -63,7 +63,7 @@ export class DHCPService extends Service {
|
|
|
63
63
|
"interfaces-config": {
|
|
64
64
|
interfaces: [...host.networkInterfaces.values()]
|
|
65
65
|
.filter(ni => ni.kind !== "loopback")
|
|
66
|
-
.map(ni => ni.name)
|
|
66
|
+
.map(ni => `${ni.name}/${ni.rawAddress}`)
|
|
67
67
|
},
|
|
68
68
|
"lease-database": {
|
|
69
69
|
type: "memfile",
|
|
@@ -147,17 +147,14 @@ export class DHCPService extends Service {
|
|
|
147
147
|
}
|
|
148
148
|
};
|
|
149
149
|
|
|
150
|
-
// console.log(this.owner.name,this.owner.networks());
|
|
151
|
-
/*
|
|
152
150
|
const subnets = new Set();
|
|
153
151
|
|
|
154
|
-
for (const network of this.
|
|
152
|
+
for (const network of this.networks) {
|
|
155
153
|
for (const subnet of network.subnets()) {
|
|
156
154
|
subnets.add(subnet);
|
|
157
155
|
}
|
|
158
156
|
}
|
|
159
|
-
console.log([...subnets].map(s => s.address));
|
|
160
|
-
*/
|
|
157
|
+
//console.log([...subnets].filter(s => s.isIPv4).map(s => s.address));
|
|
161
158
|
|
|
162
159
|
const hwmap = new Map();
|
|
163
160
|
const hostNames = new Set();
|
|
@@ -199,24 +196,22 @@ export class DHCPService extends Service {
|
|
|
199
196
|
data: [...this.domains].join(",")
|
|
200
197
|
}
|
|
201
198
|
],
|
|
202
|
-
subnet4: [
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}
|
|
219
|
-
],
|
|
199
|
+
subnet4: [...subnets]
|
|
200
|
+
.filter(s => s.isIPv4)
|
|
201
|
+
.map((subnet, index) => {
|
|
202
|
+
return {
|
|
203
|
+
id: index + 1,
|
|
204
|
+
subnet: subnet.address,
|
|
205
|
+
pools: [{ pool: subnet.addressRange.join(" - ") }],
|
|
206
|
+
"option-data": [
|
|
207
|
+
{
|
|
208
|
+
name: "routers",
|
|
209
|
+
data: network.gateway.rawAddress
|
|
210
|
+
}
|
|
211
|
+
],
|
|
212
|
+
reservations
|
|
213
|
+
};
|
|
214
|
+
}),
|
|
220
215
|
loggers
|
|
221
216
|
}
|
|
222
217
|
};
|
package/src/subnet.mjs
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
normalizeCIDR,
|
|
3
|
+
isLinkLocal,
|
|
4
|
+
isIPv4Address,
|
|
5
|
+
isIPv6Address
|
|
6
|
+
} from "./utils.mjs";
|
|
2
7
|
import { Base } from "./base.mjs";
|
|
3
8
|
import { addType } from "./types.mjs";
|
|
4
9
|
|
|
@@ -48,6 +53,20 @@ export class Subnet extends Base {
|
|
|
48
53
|
return isLinkLocal(this.address);
|
|
49
54
|
}
|
|
50
55
|
|
|
56
|
+
get isIPv4() {
|
|
57
|
+
return isIPv4Address(this.address);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
get isIPv6() {
|
|
61
|
+
return isIPv6Address(this.address);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
get addressRange()
|
|
65
|
+
{
|
|
66
|
+
const l = this.prefixLength;
|
|
67
|
+
return l === 24 ? [this.prefix + '.0', this.prefix + '.255'] : [this.prefix + '.0.0', this.prefix + '.255.255']
|
|
68
|
+
}
|
|
69
|
+
|
|
51
70
|
get prefix() {
|
|
52
71
|
const [prefix] = this.name.split("/");
|
|
53
72
|
return prefix;
|
|
@@ -76,7 +95,6 @@ export class Subnet extends Base {
|
|
|
76
95
|
}
|
|
77
96
|
}
|
|
78
97
|
|
|
79
|
-
|
|
80
98
|
export function subnets(sources) {
|
|
81
99
|
const all = new Set();
|
|
82
100
|
|
|
@@ -88,4 +106,3 @@ export function subnets(sources) {
|
|
|
88
106
|
|
|
89
107
|
return all;
|
|
90
108
|
}
|
|
91
|
-
|
package/types/service.d.mts
CHANGED
package/types/subnet.d.mts
CHANGED
|
@@ -28,6 +28,9 @@ export class Subnet extends Base {
|
|
|
28
28
|
get fullName(): string;
|
|
29
29
|
matchesAddress(address: any): any;
|
|
30
30
|
get isLinkLocal(): boolean;
|
|
31
|
+
get isIPv4(): boolean;
|
|
32
|
+
get isIPv6(): boolean;
|
|
33
|
+
get addressRange(): string[];
|
|
31
34
|
get prefix(): string;
|
|
32
35
|
get prefixLength(): number;
|
|
33
36
|
get address(): string;
|