pmcf 1.97.1 → 1.98.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmcf",
3
- "version": "1.97.1",
3
+ "version": "1.98.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -43,7 +43,7 @@
43
43
  "pkg-dir": "^8.0.0"
44
44
  },
45
45
  "devDependencies": {
46
- "@types/node": "^22.13.11",
46
+ "@types/node": "^22.13.13",
47
47
  "ava": "^6.2.0",
48
48
  "c8": "^10.1.3",
49
49
  "documentation": "^14.0.3",
package/src/dhcp.mjs CHANGED
@@ -45,6 +45,24 @@ export class DHCPService extends Base {
45
45
  }
46
46
  };
47
47
 
48
+ const commonConfig = {
49
+ "lease-database": {
50
+ type: "memfile",
51
+ "lfc-interval": 3600
52
+ },
53
+ "expired-leases-processing": {
54
+ "reclaim-timer-wait-time": 10,
55
+ "flush-reclaimed-timer-wait-time": 25,
56
+ "hold-reclaimed-time": 3600,
57
+ "max-reclaim-leases": 100,
58
+ "max-reclaim-time": 250,
59
+ "unwarned-reclaim-cycles": 5
60
+ },
61
+ "renew-timer": 900,
62
+ "rebind-timer": 1800,
63
+ "valid-lifetime": 3600
64
+ };
65
+
48
66
  const loggers = [
49
67
  {
50
68
  "output-options": [
@@ -108,24 +126,28 @@ export class DHCPService extends Base {
108
126
  */
109
127
 
110
128
  const hwmap = new Map();
129
+ const hostNames = new Set();
111
130
 
112
- for await (const {
113
- networkInterface,
114
- address,
115
- subnet,
116
- domainNames
117
- } of this.owner.networkAddresses()) {
131
+ for await (const { networkInterface } of this.owner.networkAddresses()) {
118
132
  if (networkInterface.hwaddr) {
119
- hwmap.set(networkInterface.hwaddr, networkInterface.rawAddress);
133
+ if (!hostNames.has(networkInterface.hostName)) {
134
+ hwmap.set(networkInterface.hwaddr, networkInterface);
135
+ hostNames.add(networkInterface.hostName);
136
+ }
120
137
  }
121
138
  }
122
139
 
123
- const reservations = [...hwmap].map(([k, v]) => {
124
- return { "hw-address": k, "ip-address": v };
140
+ const reservations = [...hwmap].map(([k, networkInterface]) => {
141
+ return {
142
+ "hw-address": k,
143
+ "ip-address": networkInterface.rawAddress,
144
+ hostname: networkInterface.hostName
145
+ };
125
146
  });
126
147
 
127
148
  const dhcp4 = {
128
149
  Dhcp4: {
150
+ ...commonConfig,
129
151
  "interfaces-config": {
130
152
  interfaces: ["end0"]
131
153
  },
@@ -133,21 +155,6 @@ export class DHCPService extends Base {
133
155
  "socket-type": "unix",
134
156
  "socket-name": "/run/kea/4-ctrl-socket"
135
157
  },
136
- "lease-database": {
137
- type: "memfile",
138
- "lfc-interval": 3600
139
- },
140
- "expired-leases-processing": {
141
- "reclaim-timer-wait-time": 10,
142
- "flush-reclaimed-timer-wait-time": 25,
143
- "hold-reclaimed-time": 3600,
144
- "max-reclaim-leases": 100,
145
- "max-reclaim-time": 250,
146
- "unwarned-reclaim-cycles": 5
147
- },
148
- "renew-timer": 900,
149
- "rebind-timer": 1800,
150
- "valid-lifetime": 3600,
151
158
  "option-data": [
152
159
  {
153
160
  name: "domain-name-servers",
@@ -177,14 +184,8 @@ export class DHCPService extends Base {
177
184
  }
178
185
  ],
179
186
  reservations /*: [
180
- {
181
- "hw-address": "1a:1b:1c:1d:1e:1f",
182
- "ip-address": "192.168.1.199"
183
- },
184
187
  {
185
188
  "client-id": "01:11:22:33:44:55:66",
186
- "ip-address": "192.168.1.198",
187
- hostname: "special-snowflake"
188
189
  }
189
190
  ]*/
190
191
  }
@@ -194,6 +195,7 @@ export class DHCPService extends Base {
194
195
  };
195
196
  const dhcp6 = {
196
197
  Dhcp6: {
198
+ ...commonConfig,
197
199
  "interfaces-config": {
198
200
  interfaces: []
199
201
  },
@@ -201,22 +203,7 @@ export class DHCPService extends Base {
201
203
  "socket-type": "unix",
202
204
  "socket-name": "/run/kea/6-ctrl-socket"
203
205
  },
204
- "lease-database": {
205
- type: "memfile",
206
- "lfc-interval": 3600
207
- },
208
- "expired-leases-processing": {
209
- "reclaim-timer-wait-time": 10,
210
- "flush-reclaimed-timer-wait-time": 25,
211
- "hold-reclaimed-time": 3600,
212
- "max-reclaim-leases": 100,
213
- "max-reclaim-time": 250,
214
- "unwarned-reclaim-cycles": 5
215
- },
216
- "renew-timer": 1000,
217
- "rebind-timer": 2000,
218
206
  "preferred-lifetime": 3000,
219
- "valid-lifetime": 4000,
220
207
  "option-data": [
221
208
  {
222
209
  name: "dns-servers",
package/src/host.mjs CHANGED
@@ -96,18 +96,32 @@ export class Host extends Base {
96
96
  this.finalize(() => {
97
97
  for (const host of this.extends) {
98
98
  host.execFinalize();
99
- this.depends = host.depends;
100
- this.provides = host.provides;
101
- this.replaces = host.replaces;
102
-
103
- for (const service of host.services) {
104
- this.services = service.forOwner(this);
105
- }
99
+ this._applyExtends(host);
106
100
  }
107
101
  });
108
102
  }
109
103
  }
110
104
 
105
+ _applyExtends(host) {
106
+ /* this.depends = host.depends;
107
+ this.provides = host.provides;
108
+ this.replaces = host.replaces;
109
+ */
110
+ for (const service of host.services) {
111
+ this.services = service.forOwner(this);
112
+ }
113
+
114
+ for (const [name, ni] of host.networkInterfaces) {
115
+ const present = this.#networkInterfaces.get(name);
116
+ if (present) {
117
+ this.info("ALREADY THERE", name);
118
+ } else {
119
+ this.info("CLONE NI", name);
120
+ this.#networkInterfaces.set(name, ni.forOwner(this));
121
+ }
122
+ }
123
+ }
124
+
111
125
  _traverse(...args) {
112
126
  if (super._traverse(...args)) {
113
127
  for (const ni of this.networkInterfaces.values()) {
@@ -481,15 +495,26 @@ export class NetworkInterface extends Base {
481
495
  #psk;
482
496
  #network;
483
497
  #kind;
498
+ #hostName;
484
499
  arpbridge;
485
500
  hwaddr;
486
- hostName;
487
501
 
488
502
  constructor(owner, data) {
489
503
  super(owner, data);
490
504
  this.read(data, NetworkInterfaceTypeDefinition);
491
505
  }
492
506
 
507
+ forOwner(owner) {
508
+ if (this.owner !== owner) {
509
+ const data = { name: this.name };
510
+
511
+ // @ts-ignore
512
+ return new this.constructor(owner, data);
513
+ }
514
+
515
+ return this;
516
+ }
517
+
493
518
  addSubnet(address) {
494
519
  if (!this.network) {
495
520
  if (!hasWellKnownSubnet(address)) {
@@ -562,6 +587,14 @@ export class NetworkInterface extends Base {
562
587
  }
563
588
  }
564
589
 
590
+ get hostName() {
591
+ return this.#hostName || this.host.hostName;
592
+ }
593
+
594
+ set hostName(value) {
595
+ this.#hostName = value;
596
+ }
597
+
565
598
  get domainNames() {
566
599
  return this.hostName
567
600
  ? new Set([[this.hostName, this.host.domain].join(".")])
@@ -9,6 +9,7 @@ export const networkProperties = {
9
9
  };
10
10
 
11
11
  export const networkAddressProperties = {
12
+ hostName: { type: "string", collection: false, writeable: true },
12
13
  cidrAddresses: { type: "string", collection: true, writeable: false },
13
14
  cidrAddress: { type: "string", collection: false, writeable: false },
14
15
  rawAddresses: { type: "string", collection: true, writeable: false },
@@ -383,6 +383,11 @@ export class Cluster extends Host {
383
383
  collection: boolean;
384
384
  writeable: boolean;
385
385
  };
386
+ hostName: {
387
+ type: string;
388
+ collection: boolean;
389
+ writeable: boolean;
390
+ };
386
391
  cidrAddresses: {
387
392
  type: string;
388
393
  collection: boolean;
package/types/host.d.mts CHANGED
@@ -141,6 +141,11 @@ export class Host extends Base {
141
141
  collection: boolean;
142
142
  writeable: boolean;
143
143
  };
144
+ hostName: {
145
+ type: string;
146
+ collection: boolean;
147
+ writeable: boolean;
148
+ };
144
149
  cidrAddresses: {
145
150
  type: string;
146
151
  collection: boolean;
@@ -164,12 +169,7 @@ export class Host extends Base {
164
169
  };
165
170
  };
166
171
  priority: number;
167
- set depends(value: any);
168
- get depends(): any;
169
- set provides(value: any);
170
- get provides(): any;
171
- set replaces(value: any);
172
- get replaces(): any;
172
+ _applyExtends(host: any): void;
173
173
  set services(service: any[]);
174
174
  get services(): any[];
175
175
  _traverse(...args: any[]): boolean;
@@ -190,6 +190,12 @@ export class Host extends Base {
190
190
  get aliases(): any;
191
191
  set extends(value: any[]);
192
192
  get extends(): any[];
193
+ set provides(value: any);
194
+ get provides(): any;
195
+ set replaces(value: any);
196
+ get replaces(): any;
197
+ set depends(value: any);
198
+ get depends(): any;
193
199
  set master(value: boolean);
194
200
  get master(): boolean;
195
201
  set os(value: any);
@@ -374,7 +380,6 @@ export class NetworkInterface extends Base {
374
380
  };
375
381
  arpbridge: any;
376
382
  hwaddr: any;
377
- hostName: any;
378
383
  addSubnet(address: any): any;
379
384
  set ipAddresses(value: Map<any, any>);
380
385
  get ipAddresses(): Map<any, any>;
@@ -387,6 +392,8 @@ export class NetworkInterface extends Base {
387
392
  subnetForAddress(address: any): any;
388
393
  get gateway(): any;
389
394
  get gatewayAddress(): any;
395
+ set hostName(value: any);
396
+ get hostName(): any;
390
397
  get domainNames(): any;
391
398
  get network_interface(): this;
392
399
  set network(network: any);
@@ -54,7 +54,7 @@ export namespace networkProperties {
54
54
  }
55
55
  }
56
56
  export namespace networkAddressProperties {
57
- namespace cidrAddresses {
57
+ namespace hostName {
58
58
  let type_7: string;
59
59
  export { type_7 as type };
60
60
  let collection_7: boolean;
@@ -62,7 +62,7 @@ export namespace networkAddressProperties {
62
62
  let writeable_7: boolean;
63
63
  export { writeable_7 as writeable };
64
64
  }
65
- namespace cidrAddress {
65
+ namespace cidrAddresses {
66
66
  let type_8: string;
67
67
  export { type_8 as type };
68
68
  let collection_8: boolean;
@@ -70,7 +70,7 @@ export namespace networkAddressProperties {
70
70
  let writeable_8: boolean;
71
71
  export { writeable_8 as writeable };
72
72
  }
73
- namespace rawAddresses {
73
+ namespace cidrAddress {
74
74
  let type_9: string;
75
75
  export { type_9 as type };
76
76
  let collection_9: boolean;
@@ -78,7 +78,7 @@ export namespace networkAddressProperties {
78
78
  let writeable_9: boolean;
79
79
  export { writeable_9 as writeable };
80
80
  }
81
- namespace rawAddress {
81
+ namespace rawAddresses {
82
82
  let type_10: string;
83
83
  export { type_10 as type };
84
84
  let collection_10: boolean;
@@ -86,4 +86,12 @@ export namespace networkAddressProperties {
86
86
  let writeable_10: boolean;
87
87
  export { writeable_10 as writeable };
88
88
  }
89
+ namespace rawAddress {
90
+ let type_11: string;
91
+ export { type_11 as type };
92
+ let collection_11: boolean;
93
+ export { collection_11 as collection };
94
+ let writeable_11: boolean;
95
+ export { writeable_11 as writeable };
96
+ }
89
97
  }
@@ -102,6 +102,11 @@ export class Service extends Base {
102
102
  collection: boolean;
103
103
  writeable: boolean;
104
104
  };
105
+ hostName: {
106
+ type: string;
107
+ collection: boolean;
108
+ writeable: boolean;
109
+ };
105
110
  cidrAddresses: {
106
111
  type: string;
107
112
  collection: boolean;