pmcf 2.6.7 → 2.7.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmcf",
3
- "version": "2.6.7",
3
+ "version": "2.7.0",
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.17",
46
+ "@types/node": "^22.14.0",
47
47
  "ava": "^6.2.0",
48
48
  "c8": "^10.1.3",
49
49
  "documentation": "^14.0.3",
package/src/dns-utils.mjs CHANGED
@@ -2,6 +2,7 @@ import {
2
2
  asIterator,
3
3
  decodeIPv6,
4
4
  encodeIPv6,
5
+ isIPv6Address,
5
6
  normalizeIPAddress
6
7
  } from "./utils.mjs";
7
8
 
@@ -58,3 +59,22 @@ export function dnsMergeParameters(a, b) {
58
59
  ])
59
60
  );
60
61
  }
62
+
63
+ export function reverseAddress(address) {
64
+ if (isIPv6Address(address)) {
65
+ return normalizeIPAddress(address)
66
+ .replaceAll(":", "")
67
+ .split("")
68
+ .reverse()
69
+ .join(".");
70
+ }
71
+
72
+ return address.split(".").reverse().join(".");
73
+ }
74
+
75
+ export function reverseArpaAddress(address) {
76
+ return (
77
+ reverseAddress(address) +
78
+ (isIPv6Address(address) ? ".ip6.arpa" : ".in-addr.arpa")
79
+ );
80
+ }
package/src/host.mjs CHANGED
@@ -107,6 +107,9 @@ export class Host extends Base {
107
107
  if (data.extends) {
108
108
  this.finalize(() => {
109
109
  for (const host of this.extends) {
110
+ if(host === this) {
111
+ this.error("Cant extend myself");
112
+ }
110
113
  host.execFinalize();
111
114
  this._applyExtends(host);
112
115
  }
@@ -123,6 +126,7 @@ export class Host extends Base {
123
126
  if (ni.isTemplate) {
124
127
  } else {
125
128
  let present = this._networkInterfaces.get(name);
129
+
126
130
  if (!present) {
127
131
  present = ni.forOwner(this);
128
132
  this._networkInterfaces.set(name, present);
@@ -517,9 +521,9 @@ export class NetworkInterface extends Base {
517
521
  _network;
518
522
  _kind;
519
523
  _hostName;
524
+ _hwaddr;
520
525
  extends = [];
521
526
  arpbridge;
522
- hwaddr;
523
527
 
524
528
  constructor(owner, data) {
525
529
  super(owner, data);
@@ -634,7 +638,11 @@ export class NetworkInterface extends Base {
634
638
  }
635
639
 
636
640
  get network() {
637
- return this._network ?? this.host.network;
641
+ return (
642
+ this._network ??
643
+ this.extends.find(i => i.network)?.network ??
644
+ this.host.network
645
+ );
638
646
  }
639
647
 
640
648
  set network(network) {
@@ -646,7 +654,20 @@ export class NetworkInterface extends Base {
646
654
  }
647
655
 
648
656
  get scope() {
649
- return this._scope ?? this.network?.scope ?? "global";
657
+ return (
658
+ this._scope ??
659
+ this.extends.find(i => i.scope)?.scope ??
660
+ this.network?.scope ??
661
+ "global"
662
+ );
663
+ }
664
+
665
+ set hwaddr(value) {
666
+ this._hwaddr = value;
667
+ }
668
+
669
+ get hwaddr() {
670
+ return this._hwaddr ?? this.extends.find(i => i._hwaddr)?._hwaddr;
650
671
  }
651
672
 
652
673
  set metric(value) {
@@ -662,7 +683,9 @@ export class NetworkInterface extends Base {
662
683
  }
663
684
 
664
685
  get ssid() {
665
- return this._ssid ?? this.network?.ssid;
686
+ return (
687
+ this._ssid ?? this.extends.find(i => i.ssid)?.ssid ?? this.network?.ssid
688
+ );
666
689
  }
667
690
 
668
691
  set psk(value) {
@@ -670,7 +693,7 @@ export class NetworkInterface extends Base {
670
693
  }
671
694
 
672
695
  get psk() {
673
- return this._psk ?? this.network?.psk;
696
+ return this._psk ?? this.extends.find(i => i.psk)?.psk ?? this.network?.psk;
674
697
  }
675
698
 
676
699
  set kind(value) {
@@ -678,6 +701,8 @@ export class NetworkInterface extends Base {
678
701
  }
679
702
 
680
703
  get kind() {
681
- return this._kind ?? this.network?.kind;
704
+ return (
705
+ this._kind ?? this.extends.find(i => i.kind)?.kind ?? this.network?.kind
706
+ );
682
707
  }
683
708
  }
@@ -42,6 +42,11 @@ export class DHCPService extends Service {
42
42
 
43
43
  console.log("kea", host.name, network.name);
44
44
 
45
+ const dnsServerAddreses = serviceAddresses(network, {
46
+ type: "dns",
47
+ priority: "<10"
48
+ });
49
+
45
50
  const packageData = {
46
51
  dir,
47
52
  sources: [new FileContentProvider(dir + "/")[Symbol.asyncIterator]()],
@@ -111,6 +116,16 @@ export class DHCPService extends Service {
111
116
  }
112
117
  };
113
118
 
119
+ const dnsServersSlot = domains =>
120
+ domains.map(domain => {
121
+ return {
122
+ name: domain,
123
+ "dns-servers": dnsServerAddreses.map(address => {
124
+ return { "ip-address": address };
125
+ })
126
+ };
127
+ });
128
+
114
129
  const ddns = {
115
130
  DhcpDdns: {
116
131
  "ip-address": "127.0.0.1",
@@ -120,8 +135,14 @@ export class DHCPService extends Service {
120
135
  "socket-name": "/run/kea/ddns-ctrl-socket"
121
136
  },
122
137
  "tsig-keys": [],
123
- "forward-ddns": {},
124
- "reverse-ddns": {},
138
+ "forward-ddns": {
139
+ "ddns-domains": dnsServersSlot([...this.domains])
140
+ },
141
+ /*
142
+ "reverse-ddns": {
143
+ "ddns-domains": dnsSlot()
144
+ },
145
+ */
125
146
  loggers
126
147
  }
127
148
  };
@@ -171,10 +192,7 @@ export class DHCPService extends Service {
171
192
  "option-data": [
172
193
  {
173
194
  name: "domain-name-servers",
174
- data: serviceAddresses(network, {
175
- type: "dns",
176
- priority: "<10"
177
- }).join(",")
195
+ data: dnsServerAddreses.join(",")
178
196
  },
179
197
  {
180
198
  name: "domain-search",
@@ -4,11 +4,10 @@ import { FileContentProvider } from "npm-pkgbuild";
4
4
  import {
5
5
  writeLines,
6
6
  isIPv6Address,
7
- normalizeIPAddress,
8
7
  isLinkLocal,
9
8
  isLocalhost
10
9
  } from "../utils.mjs";
11
- import { DNSRecord, dnsFullName } from "../dns-utils.mjs";
10
+ import { DNSRecord, dnsFullName, reverseArpaAddress } from "../dns-utils.mjs";
12
11
  import { addType } from "../types.mjs";
13
12
  import { ServiceTypeDefinition, serviceAddresses } from "../service.mjs";
14
13
  import {
@@ -457,22 +456,3 @@ async function generateZoneDefs(dns, location, packageData) {
457
456
  );
458
457
  }
459
458
  }
460
-
461
- export function reverseAddress(address) {
462
- if (isIPv6Address(address)) {
463
- return normalizeIPAddress(address)
464
- .replaceAll(":", "")
465
- .split("")
466
- .reverse()
467
- .join(".");
468
- }
469
-
470
- return address.split(".").reverse().join(".");
471
- }
472
-
473
- export function reverseArpaAddress(address) {
474
- return (
475
- reverseAddress(address) +
476
- (isIPv6Address(address) ? ".ip6.arpa" : ".in-addr.arpa")
477
- );
478
- }
@@ -7,3 +7,5 @@ export function dnsFormatParameters(parameters: any): string;
7
7
  export function dnsMergeParameters(a: any, b: any): {
8
8
  [k: string]: Set<any>;
9
9
  };
10
+ export function reverseAddress(address: any): any;
11
+ export function reverseArpaAddress(address: any): string;
package/types/host.d.mts CHANGED
@@ -412,9 +412,9 @@ export class NetworkInterface extends Base {
412
412
  _network: any;
413
413
  _kind: any;
414
414
  _hostName: any;
415
+ _hwaddr: any;
415
416
  extends: any[];
416
417
  arpbridge: any;
417
- hwaddr: any;
418
418
  matches(other: any): boolean;
419
419
  addSubnet(address: any): any;
420
420
  set ipAddresses(value: Map<any, any>);
@@ -436,6 +436,8 @@ export class NetworkInterface extends Base {
436
436
  get network(): any;
437
437
  set scope(value: any);
438
438
  get scope(): any;
439
+ set hwaddr(value: any);
440
+ get hwaddr(): any;
439
441
  set metric(value: any);
440
442
  get metric(): any;
441
443
  set ssid(value: any);
@@ -1,5 +1,3 @@
1
- export function reverseAddress(address: any): any;
2
- export function reverseArpaAddress(address: any): string;
3
1
  export class DNSService extends ExtraSourceService {
4
2
  static get typeDefinition(): {
5
3
  name: string;