pmcf 1.98.0 → 1.98.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmcf",
3
- "version": "1.98.0",
3
+ "version": "1.98.2",
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,27 @@ export class DHCPService extends Base {
45
45
  }
46
46
  };
47
47
 
48
+ const commonConfig = {
49
+ "interfaces-config": {
50
+ interfaces: ["end0"]
51
+ },
52
+ "lease-database": {
53
+ type: "memfile",
54
+ "lfc-interval": 3600
55
+ },
56
+ "expired-leases-processing": {
57
+ "reclaim-timer-wait-time": 10,
58
+ "flush-reclaimed-timer-wait-time": 25,
59
+ "hold-reclaimed-time": 3600,
60
+ "max-reclaim-leases": 100,
61
+ "max-reclaim-time": 250,
62
+ "unwarned-reclaim-cycles": 5
63
+ },
64
+ "renew-timer": 900,
65
+ "rebind-timer": 1800,
66
+ "valid-lifetime": 3600
67
+ };
68
+
48
69
  const loggers = [
49
70
  {
50
71
  "output-options": [
@@ -108,15 +129,14 @@ export class DHCPService extends Base {
108
129
  */
109
130
 
110
131
  const hwmap = new Map();
132
+ const hostNames = new Set();
111
133
 
112
- for await (const {
113
- networkInterface,
114
- address,
115
- subnet,
116
- domainNames
117
- } of this.owner.networkAddresses()) {
134
+ for await (const { networkInterface } of this.owner.networkAddresses()) {
118
135
  if (networkInterface.hwaddr) {
119
- hwmap.set(networkInterface.hwaddr, networkInterface);
136
+ if (!hostNames.has(networkInterface.hostName)) {
137
+ hwmap.set(networkInterface.hwaddr, networkInterface);
138
+ hostNames.add(networkInterface.hostName);
139
+ }
120
140
  }
121
141
  }
122
142
 
@@ -130,28 +150,11 @@ export class DHCPService extends Base {
130
150
 
131
151
  const dhcp4 = {
132
152
  Dhcp4: {
133
- "interfaces-config": {
134
- interfaces: ["end0"]
135
- },
153
+ ...commonConfig,
136
154
  "control-socket": {
137
155
  "socket-type": "unix",
138
156
  "socket-name": "/run/kea/4-ctrl-socket"
139
157
  },
140
- "lease-database": {
141
- type: "memfile",
142
- "lfc-interval": 3600
143
- },
144
- "expired-leases-processing": {
145
- "reclaim-timer-wait-time": 10,
146
- "flush-reclaimed-timer-wait-time": 25,
147
- "hold-reclaimed-time": 3600,
148
- "max-reclaim-leases": 100,
149
- "max-reclaim-time": 250,
150
- "unwarned-reclaim-cycles": 5
151
- },
152
- "renew-timer": 900,
153
- "rebind-timer": 1800,
154
- "valid-lifetime": 3600,
155
158
  "option-data": [
156
159
  {
157
160
  name: "domain-name-servers",
@@ -183,8 +186,6 @@ export class DHCPService extends Base {
183
186
  reservations /*: [
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,29 +195,12 @@ export class DHCPService extends Base {
194
195
  };
195
196
  const dhcp6 = {
196
197
  Dhcp6: {
197
- "interfaces-config": {
198
- interfaces: []
199
- },
198
+ ...commonConfig,
200
199
  "control-socket": {
201
200
  "socket-type": "unix",
202
201
  "socket-name": "/run/kea/6-ctrl-socket"
203
202
  },
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
203
  "preferred-lifetime": 3000,
219
- "valid-lifetime": 4000,
220
204
  "option-data": [
221
205
  {
222
206
  name: "dns-servers",
package/src/host.mjs CHANGED
@@ -96,18 +96,28 @@ 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
+ for (const service of host.services) {
107
+ this.services = service.forOwner(this);
108
+ }
109
+
110
+ for (const [name, ni] of host.networkInterfaces) {
111
+ let present = this.#networkInterfaces.get(name);
112
+ if (!present) {
113
+ present = ni.forOwner(this);
114
+ this.#networkInterfaces.set(name, present);
115
+ }
116
+
117
+ present.extends.push(ni);
118
+ }
119
+ }
120
+
111
121
  _traverse(...args) {
112
122
  if (super._traverse(...args)) {
113
123
  for (const ni of this.networkInterfaces.values()) {
@@ -482,6 +492,7 @@ export class NetworkInterface extends Base {
482
492
  #network;
483
493
  #kind;
484
494
  #hostName;
495
+ extends = [];
485
496
  arpbridge;
486
497
  hwaddr;
487
498
 
@@ -490,6 +501,17 @@ export class NetworkInterface extends Base {
490
501
  this.read(data, NetworkInterfaceTypeDefinition);
491
502
  }
492
503
 
504
+ forOwner(owner) {
505
+ if (this.owner !== owner) {
506
+ const data = { name: this.name };
507
+
508
+ // @ts-ignore
509
+ return new this.constructor(owner, data);
510
+ }
511
+
512
+ return this;
513
+ }
514
+
493
515
  addSubnet(address) {
494
516
  if (!this.network) {
495
517
  if (!hasWellKnownSubnet(address)) {
package/types/host.d.mts CHANGED
@@ -169,12 +169,7 @@ export class Host extends Base {
169
169
  };
170
170
  };
171
171
  priority: number;
172
- set depends(value: any);
173
- get depends(): any;
174
- set provides(value: any);
175
- get provides(): any;
176
- set replaces(value: any);
177
- get replaces(): any;
172
+ _applyExtends(host: any): void;
178
173
  set services(service: any[]);
179
174
  get services(): any[];
180
175
  _traverse(...args: any[]): boolean;
@@ -195,6 +190,12 @@ export class Host extends Base {
195
190
  get aliases(): any;
196
191
  set extends(value: any[]);
197
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;
198
199
  set master(value: boolean);
199
200
  get master(): boolean;
200
201
  set os(value: any);
@@ -377,6 +378,7 @@ export class NetworkInterface extends Base {
377
378
  };
378
379
  };
379
380
  };
381
+ extends: any[];
380
382
  arpbridge: any;
381
383
  hwaddr: any;
382
384
  addSubnet(address: any): any;