pmcf 1.98.0 → 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.98.0",
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,15 +126,14 @@ 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);
133
+ if (!hostNames.has(networkInterface.hostName)) {
134
+ hwmap.set(networkInterface.hwaddr, networkInterface);
135
+ hostNames.add(networkInterface.hostName);
136
+ }
120
137
  }
121
138
  }
122
139
 
@@ -130,6 +147,7 @@ export class DHCPService extends Base {
130
147
 
131
148
  const dhcp4 = {
132
149
  Dhcp4: {
150
+ ...commonConfig,
133
151
  "interfaces-config": {
134
152
  interfaces: ["end0"]
135
153
  },
@@ -137,21 +155,6 @@ export class DHCPService extends Base {
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,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()) {
@@ -490,6 +504,17 @@ export class NetworkInterface extends Base {
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)) {
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);