pmcf 2.35.1 → 2.35.3

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.35.1",
3
+ "version": "2.35.3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/host.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  import { readFile } from "node:fs/promises";
2
2
  import { join } from "node:path";
3
3
  import { FileContentProvider } from "npm-pkgbuild";
4
- import { ServiceOwner, Base } from "pmcf";
5
- import { networkAddressProperties, addresses } from "./network-support.mjs";
4
+ import { ServiceOwner, Base, addresses } from "pmcf";
5
+ import { networkAddressProperties } from "./network-support.mjs";
6
6
  import {
7
7
  domainFromDominName,
8
8
  domainName,
@@ -31,3 +31,17 @@ export class NetworkAddress {
31
31
  return `${this.networkInterface.fullName} ${decodeIP(this.address)}`;
32
32
  }
33
33
  }
34
+
35
+ export function addresses(networkAddresses) {
36
+ return [
37
+ ...new Set(
38
+ [...networkAddresses].map(object =>
39
+ /*object?.name ||*/ decodeIP(object.address)
40
+ )
41
+ )
42
+ ];
43
+ }
44
+
45
+ export function cidrAddresses(networkAddresses) {
46
+ return [...networkAddresses].map(na => na.cidrAddress);
47
+ }
@@ -1,13 +1,12 @@
1
1
  import { join } from "node:path";
2
2
  import { hasWellKnownSubnet, normalizeIP } from "ip-utilties";
3
- import { Base } from "pmcf";
3
+ import { Base, cidrAddresses } from "pmcf";
4
4
  import {
5
5
  networkProperties,
6
6
  networkAddressProperties
7
7
  } from "../network-support.mjs";
8
8
  import { asArray, writeLines, sectionLines } from "../utils.mjs";
9
9
  import { addType } from "../types.mjs";
10
- import { cidrAddresses } from "../network-support.mjs";
11
10
  import { SkeletonNetworkInterface } from "./skeleton.mjs";
12
11
 
13
12
  export const NetworkInterfaceTypeDefinition = {
@@ -1,8 +1,7 @@
1
1
  import { join } from "node:path";
2
2
  import { writeLines, sectionLines } from "../utils.mjs";
3
- import { NetworkAddress, Host } from "pmcf";
3
+ import { NetworkAddress, Host, cidrAddresses } from "pmcf";
4
4
  import { ServiceOwner } from "../service-owner.mjs";
5
- import { cidrAddresses } from "../network-support.mjs";
6
5
 
7
6
  export class SkeletonNetworkInterface extends ServiceOwner {
8
7
  _extends = [];
@@ -38,11 +38,3 @@ export const networkAddressProperties = {
38
38
  addresses: { type: "string", collection: true, writeable: false },
39
39
  address: { type: "string", collection: false, writeable: false }
40
40
  };
41
-
42
- export function addresses(networkAddresses) {
43
- return [...networkAddresses].map(na => na.address);
44
- }
45
-
46
- export function cidrAddresses(networkAddresses) {
47
- return [...networkAddresses].map(na => na.cidrAddress);
48
- }
package/src/service.mjs CHANGED
@@ -106,7 +106,6 @@ export const ServiceTypeDefinition = {
106
106
  properties: {
107
107
  ...networkAddressProperties,
108
108
  ...endpointProperties,
109
- ipAddresses: { type: "string", collection: true, writeable: true },
110
109
  alias: { type: "string", collection: false, writeable: true },
111
110
  weight: { type: "number", collection: false, writeable: true, default: 1 },
112
111
  systemd: { type: "string", collection: true, writeable: true }
@@ -118,7 +117,6 @@ export class Service extends Base {
118
117
  _weight;
119
118
  _type;
120
119
  _port;
121
- _ipAddresses;
122
120
  _systemd;
123
121
  _extends = [];
124
122
 
@@ -165,18 +163,6 @@ export class Service extends Base {
165
163
  return this.address ?? this.domainName;
166
164
  }
167
165
 
168
- get addresses() {
169
- return this._ipAddresses ?? this.owner.addresses;
170
- }
171
-
172
- get address() {
173
- return this._ipAddresses?.[0] ?? this.host.address;
174
- }
175
-
176
- set ipAddresses(value) {
177
- this._ipAddresses = value;
178
- }
179
-
180
166
  get networks() {
181
167
  return this.host.networks;
182
168
  }
@@ -1,19 +1,23 @@
1
1
  import { join } from "node:path";
2
2
  import { createHmac } from "node:crypto";
3
3
  import { FileContentProvider } from "npm-pkgbuild";
4
- import { isLinkLocal, reverseArpa, decodeIP } from "ip-utilties";
5
- import { writeLines } from "../utils.mjs";
4
+ import { isLinkLocal, reverseArpa } from "ip-utilties";
5
+ import { writeLines, asArray } from "../utils.mjs";
6
6
  import {
7
7
  DNSRecord,
8
8
  dnsFullName,
9
9
  dnsRecordTypeForAddressFamily,
10
10
  sortZoneRecords
11
11
  } from "../dns-utils.mjs";
12
- import { ExtraSourceService, Endpoint, serviceEndpoints } from "pmcf";
12
+ import {
13
+ ExtraSourceService,
14
+ Endpoint,
15
+ serviceEndpoints,
16
+ addresses
17
+ } from "pmcf";
13
18
  import { addType } from "../types.mjs";
14
19
  import { ServiceTypeDefinition } from "../service.mjs";
15
20
  import { ExtraSourceServiceTypeDefinition } from "../extra-source-service.mjs";
16
- import { addresses } from "../network-support.mjs";
17
21
  import { addHook } from "../hooks.mjs";
18
22
 
19
23
  const address_types = ["network", "host", "network_interface"];
@@ -87,23 +91,8 @@ const statisticsEndpoint = {
87
91
  tls: false
88
92
  };
89
93
 
90
- function addressList(objects) {
91
- return Array.from(objects).map(object => {
92
- switch (typeof object) {
93
- case "string":
94
- return object;
95
- case "object":
96
- if (object.name) {
97
- return object.name;
98
- }
99
-
100
- return decodeIP(object);
101
- }
102
- });
103
- }
104
-
105
94
  function addressesStatement(prefix, objects, generateEmpty = false) {
106
- const body = addressList(objects).map(name => ` ${name};`);
95
+ const body = asArray(objects).map(name => ` ${name};`);
107
96
 
108
97
  if (body.length || generateEmpty) {
109
98
  return [`${prefix} {`, body, "};"];
@@ -235,8 +224,11 @@ export class DNSService extends ExtraSourceService {
235
224
 
236
225
  const acls = [
237
226
  addressesStatement("acl trusted", addresses(this.trusted)),
238
- addressesStatement("acl protected", addresses(this.protected)),
239
- addressesStatement("acl open", addresses(this.open), true)
227
+ addressesStatement("acl open", addresses(this.open), true),
228
+ addressesStatement("acl protected", [
229
+ ...addresses(this.protected),
230
+ "!open"
231
+ ])
240
232
  ].flat();
241
233
 
242
234
  if (acls.length) {
@@ -69,11 +69,6 @@ export class ExtraSourceService extends Service {
69
69
  specializations: {};
70
70
  factoryFor(owner: any, value: any): any;
71
71
  properties: {
72
- ipAddresses: {
73
- type: string;
74
- collection: boolean;
75
- writeable: boolean;
76
- };
77
72
  alias: {
78
73
  type: string;
79
74
  collection: boolean;
@@ -1,3 +1,5 @@
1
+ export function addresses(networkAddresses: any): any[];
2
+ export function cidrAddresses(networkAddresses: any): any[];
1
3
  /**
2
4
  *
3
5
  */
@@ -1,5 +1,3 @@
1
- export function addresses(networkAddresses: any): any[];
2
- export function cidrAddresses(networkAddresses: any): any[];
3
1
  export namespace networkProperties {
4
2
  export namespace scope {
5
3
  export let type: string;
@@ -100,11 +100,6 @@ export namespace ServiceTypeDefinition {
100
100
  export { specializations_1 as specializations };
101
101
  export function factoryFor(owner: any, value: any): any;
102
102
  export let properties: {
103
- ipAddresses: {
104
- type: string;
105
- collection: boolean;
106
- writeable: boolean;
107
- };
108
103
  alias: {
109
104
  type: string;
110
105
  collection: boolean;
@@ -225,11 +220,6 @@ export class Service extends Base {
225
220
  specializations: {};
226
221
  factoryFor(owner: any, value: any): any;
227
222
  properties: {
228
- ipAddresses: {
229
- type: string;
230
- collection: boolean;
231
- writeable: boolean;
232
- };
233
223
  alias: {
234
224
  type: string;
235
225
  collection: boolean;
@@ -299,7 +289,6 @@ export class Service extends Base {
299
289
  _weight: any;
300
290
  _type: any;
301
291
  _port: any;
302
- _ipAddresses: any;
303
292
  _systemd: any;
304
293
  _extends: any[];
305
294
  set extends(value: any[]);
@@ -308,9 +297,6 @@ export class Service extends Base {
308
297
  hosts(): Generator<any, void, any>;
309
298
  get domainName(): any;
310
299
  get ipAddressOrDomainName(): any;
311
- get addresses(): any;
312
- get address(): any;
313
- set ipAddresses(value: any);
314
300
  get networks(): Set<any>;
315
301
  endpoints(filter: any): any[];
316
302
  set alias(value: any);
@@ -55,11 +55,6 @@ export class DHCPService extends Service {
55
55
  specializations: {};
56
56
  factoryFor(owner: any, value: any): any;
57
57
  properties: {
58
- ipAddresses: {
59
- type: string;
60
- collection: boolean;
61
- writeable: boolean;
62
- };
63
58
  alias: {
64
59
  type: string;
65
60
  collection: boolean;
@@ -180,11 +175,6 @@ export class DHCPService extends Service {
180
175
  specializations: {};
181
176
  factoryFor(owner: any, value: any): any;
182
177
  properties: {
183
- ipAddresses: {
184
- type: string;
185
- collection: boolean;
186
- writeable: boolean;
187
- };
188
178
  alias: {
189
179
  type: string;
190
180
  collection: boolean;
@@ -55,11 +55,6 @@ export class DNSService extends ExtraSourceService {
55
55
  specializations: {};
56
56
  factoryFor(owner: any, value: any): any;
57
57
  properties: {
58
- ipAddresses: {
59
- type: string;
60
- collection: boolean;
61
- writeable: boolean;
62
- };
63
58
  alias: {
64
59
  type: string;
65
60
  collection: boolean;
@@ -183,11 +178,6 @@ export class DNSService extends ExtraSourceService {
183
178
  specializations: {};
184
179
  factoryFor(owner: any, value: any): any;
185
180
  properties: {
186
- ipAddresses: {
187
- type: string;
188
- collection: boolean;
189
- writeable: boolean;
190
- };
191
181
  alias: {
192
182
  type: string;
193
183
  collection: boolean;
@@ -55,11 +55,6 @@ export class NTPService extends ExtraSourceService {
55
55
  specializations: {};
56
56
  factoryFor(owner: any, value: any): any;
57
57
  properties: {
58
- ipAddresses: {
59
- type: string;
60
- collection: boolean;
61
- writeable: boolean;
62
- };
63
58
  alias: {
64
59
  type: string;
65
60
  collection: boolean;
@@ -183,11 +178,6 @@ export class NTPService extends ExtraSourceService {
183
178
  specializations: {};
184
179
  factoryFor(owner: any, value: any): any;
185
180
  properties: {
186
- ipAddresses: {
187
- type: string;
188
- collection: boolean;
189
- writeable: boolean;
190
- };
191
181
  alias: {
192
182
  type: string;
193
183
  collection: boolean;
@@ -55,11 +55,6 @@ export class SystemdJournalService extends Service {
55
55
  specializations: {};
56
56
  factoryFor(owner: any, value: any): any;
57
57
  properties: {
58
- ipAddresses: {
59
- type: string;
60
- collection: boolean;
61
- writeable: boolean;
62
- };
63
58
  alias: {
64
59
  type: string;
65
60
  collection: boolean;
@@ -180,11 +175,6 @@ export class SystemdJournalService extends Service {
180
175
  specializations: {};
181
176
  factoryFor(owner: any, value: any): any;
182
177
  properties: {
183
- ipAddresses: {
184
- type: string;
185
- collection: boolean;
186
- writeable: boolean;
187
- };
188
178
  alias: {
189
179
  type: string;
190
180
  collection: boolean;
@@ -55,11 +55,6 @@ export class SystemdResolvedService extends ExtraSourceService {
55
55
  specializations: {};
56
56
  factoryFor(owner: any, value: any): any;
57
57
  properties: {
58
- ipAddresses: {
59
- type: string;
60
- collection: boolean;
61
- writeable: boolean;
62
- };
63
58
  alias: {
64
59
  type: string;
65
60
  collection: boolean;
@@ -180,11 +175,6 @@ export class SystemdResolvedService extends ExtraSourceService {
180
175
  specializations: {};
181
176
  factoryFor(owner: any, value: any): any;
182
177
  properties: {
183
- ipAddresses: {
184
- type: string;
185
- collection: boolean;
186
- writeable: boolean;
187
- };
188
178
  alias: {
189
179
  type: string;
190
180
  collection: boolean;
@@ -55,11 +55,6 @@ export class SystemdTimesyncdService extends ExtraSourceService {
55
55
  specializations: {};
56
56
  factoryFor(owner: any, value: any): any;
57
57
  properties: {
58
- ipAddresses: {
59
- type: string;
60
- collection: boolean;
61
- writeable: boolean;
62
- };
63
58
  alias: {
64
59
  type: string;
65
60
  collection: boolean;
@@ -180,11 +175,6 @@ export class SystemdTimesyncdService extends ExtraSourceService {
180
175
  specializations: {};
181
176
  factoryFor(owner: any, value: any): any;
182
177
  properties: {
183
- ipAddresses: {
184
- type: string;
185
- collection: boolean;
186
- writeable: boolean;
187
- };
188
178
  alias: {
189
179
  type: string;
190
180
  collection: boolean;