pmcf 3.14.2 → 3.15.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/README.md CHANGED
@@ -14,32 +14,58 @@
14
14
 
15
15
  ## Poor mans configuration management
16
16
 
17
+ Generates system packages from config blueprint.
18
+
19
+ supported linux derivates:
20
+
21
+ - arch linux
22
+ - debian
23
+ - rpm based systems
24
+
25
+ generates config packages for:
26
+
27
+ - systemd
28
+ - networkd
29
+ - timesyncd
30
+ - resolverd
31
+ - kea
32
+ - bind
33
+ - mosquitto
34
+ - influxdb
35
+ - iwd
36
+ - chrony
37
+
17
38
  # API
18
39
 
19
40
  <!-- Generated by documentation.js. Update this documentation by updating the source code. -->
20
41
 
21
42
  ### Table of Contents
22
43
 
23
- * [Base](#base)
24
- * [Parameters](#parameters)
25
- * [extends](#extends)
26
- * [findService](#findservice)
27
- * [Parameters](#parameters-1)
28
- * [port](#port)
29
- * [socketAddress](#socketaddress)
30
- * [port](#port-1)
31
- * [SkeletonNetworkInterface](#skeletonnetworkinterface)
32
- * [networkAddresses](#networkaddresses)
33
- * [Parameters](#parameters-2)
34
- * [NetworkAddress](#networkaddress)
35
- * [Parameters](#parameters-3)
36
- * [subnet](#subnet)
37
- * [networkInterface](#networkinterface)
38
- * [address](#address)
39
- * [addresses](#addresses)
40
- * [Parameters](#parameters-4)
41
- * [serviceEndpoints](#serviceendpoints)
42
- * [Parameters](#parameters-5)
44
+ - [pmcf](#pmcf)
45
+ - [Poor mans configuration management](#poor-mans-configuration-management)
46
+ - [API](#api)
47
+ - [Table of Contents](#table-of-contents)
48
+ - [Base](#base)
49
+ - [Parameters](#parameters)
50
+ - [extends](#extends)
51
+ - [findService](#findservice)
52
+ - [Parameters](#parameters-1)
53
+ - [port](#port)
54
+ - [socketAddress](#socketaddress)
55
+ - [port](#port-1)
56
+ - [SkeletonNetworkInterface](#skeletonnetworkinterface)
57
+ - [networkAddresses](#networkaddresses)
58
+ - [Parameters](#parameters-2)
59
+ - [NetworkAddress](#networkaddress)
60
+ - [Parameters](#parameters-3)
61
+ - [subnet](#subnet)
62
+ - [networkInterface](#networkinterface)
63
+ - [address](#address)
64
+ - [addresses](#addresses)
65
+ - [Parameters](#parameters-4)
66
+ - [serviceEndpoints](#serviceendpoints)
67
+ - [Parameters](#parameters-5)
68
+ - [install](#install)
43
69
 
44
70
  ## Base
45
71
 
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "pmcf",
3
- "version": "3.14.2",
3
+ "version": "3.15.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "packageManager": "npm@11.6.0+sha512.77f3fb0dbbd881835d7bd1217deabdf7ed77fc4ec4f363df64fc3cb986404abf6c437661041080f5c5d225103508e7c9ea30cb2742b7e942675d05a10af2d7b9",
7
+ "packageManager": "npm@11.6.3+sha512.4085a763162e0e3acd19a4e9d23ad3aa0978e501ccf947dd7233c12a689ae0bb0190763c4ef12366990056b34eec438903ffed38fde4fbd722a17c2a7407ee92",
8
8
  "exports": {
9
9
  ".": {
10
10
  "default": "./src/module.mjs"
@@ -12,10 +12,12 @@
12
12
  },
13
13
  "description": "Poor mans configuration management",
14
14
  "keywords": [
15
+ "arch linux",
15
16
  "bind",
16
17
  "chrony",
17
18
  "config",
18
19
  "config management",
20
+ "debian",
19
21
  "dhcp",
20
22
  "dns",
21
23
  "influxdb",
@@ -24,7 +26,7 @@
24
26
  "keepalived",
25
27
  "mosquitto",
26
28
  "openldap",
27
- "openldap",
29
+ "rpm",
28
30
  "systemd"
29
31
  ],
30
32
  "contributors": [
@@ -51,9 +53,9 @@
51
53
  "lint:typescript": "tsc --allowJs --checkJs --noEmit --resolveJsonModule --target esnext -m esnext --module nodenext --moduleResolution nodenext ./src**/*.mjs"
52
54
  },
53
55
  "dependencies": {
54
- "ip-utilties": "^1.4.12",
55
- "npm-pkgbuild": "^19.0.2",
56
- "pacc": "^4.41.1",
56
+ "ip-utilties": "^1.4.13",
57
+ "npm-pkgbuild": "^19.0.3",
58
+ "pacc": "^4.41.2",
57
59
  "package-directory": "^8.1.0"
58
60
  },
59
61
  "devDependencies": {
package/src/endpoint.mjs CHANGED
@@ -23,6 +23,9 @@ class BaseEndpoint {
23
23
  }
24
24
  }
25
25
 
26
+ /**
27
+ * Endpoint with an ip port
28
+ */
26
29
  class PortEndpoint extends BaseEndpoint {
27
30
  _port;
28
31
  constructor(service, data) {
@@ -108,6 +111,9 @@ export class DomainNameEndpoint extends PortEndpoint {
108
111
  }
109
112
  }
110
113
 
114
+ /**
115
+ * Endpoint based on http
116
+ */
111
117
  export class HTTPEndpoint extends BaseEndpoint {
112
118
  constructor(service, address, data) {
113
119
  super(service, data);
@@ -1,6 +1,7 @@
1
1
  import { familyIP, formatCIDR, decodeIP } from "ip-utilties";
2
2
  import { Subnet } from "./subnet.mjs";
3
3
  import { Owner } from "pmcf";
4
+ import { NetworkInterface } from "./network-interfaces/network-interface.mjs";
4
5
 
5
6
  /**
6
7
  *
@@ -10,6 +11,12 @@ export class NetworkAddress {
10
11
  /** @type {NetworkInterface} */ networkInterface;
11
12
  /** @type {string|Uint8Array|Uint16Array} */ address;
12
13
 
14
+ /**
15
+ *
16
+ * @param {NetworkInterface} networkInterface
17
+ * @param {string|Uint8Array|Uint16Array} address
18
+ * @param {Subnet} subnet
19
+ */
13
20
  constructor(networkInterface, address, subnet) {
14
21
  this.networkInterface = networkInterface;
15
22
  this.address = address;
@@ -34,9 +41,9 @@ export class NetworkAddress {
34
41
  }
35
42
 
36
43
  /**
37
- *
38
- * @param {Iterable<Owner|string>} sources
39
- * @param {Object} options
44
+ *
45
+ * @param {Iterable<Owner|string>} sources
46
+ * @param {Object} options
40
47
  * @param {boolean} options.aggregate
41
48
  * @param {Object} options.filter
42
49
  * @returns {Iterable<string>} addresses
@@ -46,7 +53,7 @@ export function addresses(sources, options) {
46
53
  ...new Set(
47
54
  [...sources]
48
55
  .map(s => {
49
- if(typeof s === "string") {
56
+ if (typeof s === "string") {
50
57
  return s;
51
58
  }
52
59
  if (options?.aggregate && s instanceof Owner && s.subnets) {
@@ -58,11 +65,18 @@ export function addresses(sources, options) {
58
65
  : s;
59
66
  })
60
67
  .flat()
61
- .map(object => typeof object === "string" ? object : decodeIP(object.address))
68
+ .map(object =>
69
+ typeof object === "string" ? object : decodeIP(object.address)
70
+ )
62
71
  )
63
72
  ];
64
73
  }
65
74
 
75
+ /**
76
+ *
77
+ * @param {Array<NetworkAddress>} networkAddresses
78
+ * @returns {Array<string>}
79
+ */
66
80
  export function cidrAddresses(networkAddresses) {
67
81
  return [...networkAddresses].map(na => na.cidrAddress);
68
82
  }
@@ -134,7 +134,9 @@ export class NetworkInterface extends SkeletonNetworkInterface {
134
134
 
135
135
  get domainNames() {
136
136
  return this.hostName
137
- ? new Set([[this.hostName, this.host.domain].join(".")])
137
+ ? this.host.directDomainNames.union(
138
+ new Set([[this.hostName, this.host.domain].join(".")])
139
+ )
138
140
  : this.host.directDomainNames;
139
141
  }
140
142
 
@@ -138,6 +138,20 @@ export const ServiceTypes = {
138
138
  // adVF: "0x82"
139
139
  }
140
140
  }
141
+ },
142
+ pcp: {
143
+ // rfc6887
144
+ endpoints: [
145
+ { family: "IPv4", protocol: "udp", port: 5351, tls: false },
146
+ { family: "IPv6", protocol: "udp", port: 5351, tls: false }
147
+ ]
148
+ },
149
+ "pcp-multicast": {
150
+ // rfc6887
151
+ endpoints: [
152
+ { family: "IPv4", protocol: "udp", port: 5350, tls: false },
153
+ { family: "IPv6", protocol: "udp", port: 5350, tls: false }
154
+ ]
141
155
  }
142
156
  };
143
157
 
@@ -468,21 +468,23 @@ export class BindService extends ExtraSourceService {
468
468
  }
469
469
 
470
470
  for (const domainName of domainNames) {
471
- zone.records.add(
472
- DNSRecord(
473
- dnsFullName(domainName),
474
- dnsRecordTypeForAddressFamily(family),
475
- address
476
- )
477
- );
478
-
479
- reverseZone.records.add(
480
- DNSRecord(
481
- dnsFullName(reverseArpa(address)),
482
- "PTR",
483
- dnsFullName(domainName)
484
- )
485
- );
471
+ if (domainName[0] != "*") {
472
+ zone.records.add(
473
+ DNSRecord(
474
+ dnsFullName(domainName),
475
+ dnsRecordTypeForAddressFamily(family),
476
+ address
477
+ )
478
+ );
479
+
480
+ reverseZone.records.add(
481
+ DNSRecord(
482
+ dnsFullName(reverseArpa(address)),
483
+ "PTR",
484
+ dnsFullName(domainName)
485
+ )
486
+ );
487
+ }
486
488
  }
487
489
  }
488
490
 
package/src/utils.mjs CHANGED
@@ -45,6 +45,12 @@ export async function writeLines(dir, name, lines) {
45
45
  return writeFile(join(dir, name), data, "utf8");
46
46
  }
47
47
 
48
+ /**
49
+ *
50
+ * @param {string} sectionName
51
+ * @param {Object} values
52
+ * @returns {Array<string>}
53
+ */
48
54
  export function sectionLines(sectionName, values) {
49
55
  const lines = [`[${sectionName}]`];
50
56
 
@@ -59,10 +65,18 @@ export function bridgeToJSON(bridge) {
59
65
  return [...bridge].map(n => n.fullName || `(${n})`).sort();
60
66
  }
61
67
 
68
+ /**
69
+ * @param {any} value
70
+ * @returns {Array<any>}
71
+ */
62
72
  export function asArray(value) {
63
73
  return Array.isArray(value) ? value : value === undefined ? [] : [value];
64
74
  }
65
75
 
76
+ /**
77
+ * @param {any} value
78
+ * @returns {Iterable<any>}
79
+ */
66
80
  export function asIterator(value) {
67
81
  switch (typeof value) {
68
82
  case "undefined":
@@ -15,6 +15,9 @@ export class DomainNameEndpoint extends PortEndpoint {
15
15
  get address(): any;
16
16
  get isPool(): boolean;
17
17
  }
18
+ /**
19
+ * Endpoint based on http
20
+ */
18
21
  export class HTTPEndpoint extends BaseEndpoint {
19
22
  constructor(service: any, address: any, data: any);
20
23
  url: URL;
@@ -36,6 +39,9 @@ export class UnixEndpoint extends BaseEndpoint {
36
39
  get host(): any;
37
40
  get address(): any;
38
41
  }
42
+ /**
43
+ * Endpoint with an ip port
44
+ */
39
45
  declare class PortEndpoint extends BaseEndpoint {
40
46
  _port: any;
41
47
  protocol: any;
@@ -10,20 +10,32 @@ export function addresses(sources: Iterable<Owner | string>, options: {
10
10
  aggregate: boolean;
11
11
  filter: any;
12
12
  }): Iterable<string>;
13
- export function cidrAddresses(networkAddresses: any): any[];
13
+ /**
14
+ *
15
+ * @param {Array<NetworkAddress>} networkAddresses
16
+ * @returns {Array<string>}
17
+ */
18
+ export function cidrAddresses(networkAddresses: Array<NetworkAddress>): Array<string>;
14
19
  export function sortByFamilyAndAddress(a: any, b: any): any;
15
20
  /**
16
21
  *
17
22
  */
18
23
  export class NetworkAddress {
19
- constructor(networkInterface: any, address: any, subnet: any);
24
+ /**
25
+ *
26
+ * @param {NetworkInterface} networkInterface
27
+ * @param {string|Uint8Array|Uint16Array} address
28
+ * @param {Subnet} subnet
29
+ */
30
+ constructor(networkInterface: NetworkInterface, address: string | Uint8Array | Uint16Array, subnet: Subnet);
20
31
  /** @type {Subnet} */ subnet: Subnet;
21
32
  /** @type {NetworkInterface} */ networkInterface: NetworkInterface;
22
33
  /** @type {string|Uint8Array|Uint16Array} */ address: string | Uint8Array | Uint16Array;
23
- get domainNames(): any;
34
+ get domainNames(): Set<any>;
24
35
  get family(): any;
25
36
  get cidrAddress(): any;
26
37
  toString(): string;
27
38
  }
28
39
  import { Owner } from "pmcf";
29
40
  import { Subnet } from "./subnet.mjs";
41
+ import { NetworkInterface } from "./network-interfaces/network-interface.mjs";
@@ -183,4 +183,20 @@ export const ServiceTypes: {
183
183
  };
184
184
  };
185
185
  };
186
+ pcp: {
187
+ endpoints: {
188
+ family: string;
189
+ protocol: string;
190
+ port: number;
191
+ tls: boolean;
192
+ }[];
193
+ };
194
+ "pcp-multicast": {
195
+ endpoints: {
196
+ family: string;
197
+ protocol: string;
198
+ port: number;
199
+ tls: boolean;
200
+ }[];
201
+ };
186
202
  };
package/types/utils.d.mts CHANGED
@@ -1,7 +1,21 @@
1
1
  export function domainName(name: any, defaultDomain: any): any;
2
2
  export function domainFromDominName(domainName: any, defaultDomain: any): any;
3
3
  export function writeLines(dir: any, name: any, lines: any): Promise<void>;
4
- export function sectionLines(sectionName: any, values: any): string[];
4
+ /**
5
+ *
6
+ * @param {string} sectionName
7
+ * @param {Object} values
8
+ * @returns {Array<string>}
9
+ */
10
+ export function sectionLines(sectionName: string, values: any): Array<string>;
5
11
  export function bridgeToJSON(bridge: any): any[];
6
- export function asArray(value: any): any[];
7
- export function asIterator(value: any): any;
12
+ /**
13
+ * @param {any} value
14
+ * @returns {Array<any>}
15
+ */
16
+ export function asArray(value: any): Array<any>;
17
+ /**
18
+ * @param {any} value
19
+ * @returns {Iterable<any>}
20
+ */
21
+ export function asIterator(value: any): Iterable<any>;