pmcf 6.66.5 → 6.66.7

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": "6.66.5",
3
+ "version": "6.66.7",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -51,7 +51,7 @@
51
51
  },
52
52
  "dependencies": {
53
53
  "aggregated-map": "^1.0.11",
54
- "content-entry-transform": "^1.7.9",
54
+ "content-entry-transform": "^1.7.10",
55
55
  "filtered-map": "^1.0.0",
56
56
  "ip-utilties": "^3.13.1",
57
57
  "npm-pkgbuild": "^22.2.9",
@@ -17,7 +17,7 @@ import {
17
17
  host,
18
18
  Endpoint,
19
19
  DomainNameEndpoint,
20
- HTTPEndpoint,
20
+ url_endpoint,
21
21
  unix_endpoint
22
22
  } from "pmcf";
23
23
  import { addType } from "./type.mjs";
@@ -127,7 +127,7 @@ export class CoreService extends base {
127
127
  }
128
128
 
129
129
  get url() {
130
- return this.endpoint()?.url;
130
+ return this.endpoints().find(e => e.url)?.url;
131
131
  }
132
132
 
133
133
  get serviceTypeEndpoints() {
@@ -166,15 +166,17 @@ export class CoreService extends base {
166
166
  delete options.kind;
167
167
 
168
168
  for (const na of this.host.networkAddresses()) {
169
- if (
170
- (e.family && e.family !== na.family) ||
171
- (e.kind && e.kind !== na.networkInterface.kind)
172
- ) {
173
- continue;
169
+ if (e.family !== FAMILY_DNS) {
170
+ if (
171
+ (e.family && e.family !== na.family) ||
172
+ (e.kind && e.kind !== na.networkInterface.kind)
173
+ ) {
174
+ continue;
175
+ }
174
176
  }
175
177
 
176
178
  if (e.scheme || e.pathname) {
177
- const he = new HTTPEndpoint(this, na, options);
179
+ const he = new url_endpoint(this, na, options);
178
180
  if (!seen.has(he.url.toString())) {
179
181
  seen.add(he.url.toString());
180
182
  result.push(he);
@@ -332,43 +334,45 @@ export class CoreService extends base {
332
334
  }
333
335
  }
334
336
 
335
- const dnsRecord = ServiceTypes[this.type]?.dnsRecord;
336
- if (dnsRecord) {
337
- let parameters = dnsRecord.parameters;
338
-
339
- if (parameters) {
340
- for (const service of this.services) {
341
- if (service !== this) {
342
- const serviceType = ServiceTypes[service.type];
343
- /*if(!serviceType) {
344
- throw new Error(`Unknown service '${service.type}'`);
345
- }*/
346
- const r = serviceType?.dnsRecord;
347
-
348
- if (r?.type === dnsRecord.type) {
349
- parameters = dnsMergeParameters(parameters, r.parameters);
337
+ for (const st of this.types) {
338
+ const dnsRecord = ServiceTypes[st]?.dnsRecord;
339
+ if (dnsRecord) {
340
+ let parameters = dnsRecord.parameters;
341
+
342
+ if (parameters) {
343
+ for (const service of this.services) {
344
+ if (service !== this) {
345
+ const serviceType = ServiceTypes[service.type];
346
+ /*if(!serviceType) {
347
+ throw new Error(`Unknown service '${service.type}'`);
348
+ }*/
349
+ const r = serviceType?.dnsRecord;
350
+
351
+ if (r?.type === dnsRecord.type) {
352
+ parameters = dnsMergeParameters(parameters, r.parameters);
353
+ }
350
354
  }
351
355
  }
352
- }
353
356
 
354
- records.push(
355
- DNSRecord(
356
- dnsFullName(domainName),
357
- dnsRecord.type,
358
- dnsPriority(this.priority),
359
- ".",
360
- dnsFormatParameters(parameters)
361
- )
362
- );
363
- } else {
364
- records.push(
365
- DNSRecord(
366
- "@",
367
- dnsRecord.type,
368
- dnsPriority(this.priority),
369
- dnsFullName(domainName)
370
- )
371
- );
357
+ records.push(
358
+ DNSRecord(
359
+ dnsFullName(domainName),
360
+ dnsRecord.type,
361
+ dnsPriority(this.priority),
362
+ ".",
363
+ dnsFormatParameters(parameters)
364
+ )
365
+ );
366
+ } else {
367
+ records.push(
368
+ DNSRecord(
369
+ "@",
370
+ dnsRecord.type,
371
+ dnsPriority(this.priority),
372
+ dnsFullName(domainName)
373
+ )
374
+ );
375
+ }
372
376
  }
373
377
  }
374
378
 
package/src/endpoint.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { getAttribute, string_attribute, url_attribute } from "pacc";
2
- import { FAMILY_IPV6 } from "ip-utilties";
2
+ import { FAMILY_IPV6, FAMILY_IPV4 } from "ip-utilties";
3
3
  import { addType } from "./type.mjs";
4
4
  import { CoreService } from "./core-service.mjs";
5
5
  import { family_attribute, endpointAttributes } from "./common-attributes.mjs";
@@ -171,8 +171,7 @@ export class DomainNameEndpoint extends PortEndpoint {
171
171
  /**
172
172
  * Endpoint based on url
173
173
  */
174
- export class HTTPEndpoint extends BaseEndpoint {
175
- static name = "url_endpoint";
174
+ export class url_endpoint extends BaseEndpoint {
176
175
  static attributes = {
177
176
  url: url_attribute,
178
177
  addressType: { ...string_attribute, name: "addressType" }
@@ -205,17 +204,25 @@ export class HTTPEndpoint extends BaseEndpoint {
205
204
 
206
205
  const scheme = data.scheme ? data.scheme : data.tls ? "https" : "http";
207
206
 
208
- const domainName = [...address.domainNames][0];
209
- const hostname =
210
- domainName ??
211
- (data.family === FAMILY_IPV6
212
- ? "[" + address.address + "]"
213
- : address.address);
214
-
207
+ let hostname;
208
+
209
+ switch (this.family) {
210
+ case FAMILY_DNS:
211
+ hostname = [...address.domainNames][0];
212
+ this.hostname = hostname;
213
+ break;
214
+ case FAMILY_IPV4:
215
+ hostname = address.address;
216
+ this.hostname = address.address;
217
+ break;
218
+ case FAMILY_IPV6:
219
+ hostname = "[" + address.address + "]";
220
+ this.hostname = address.address;
221
+ break;
222
+ }
215
223
  this.url = new URL(
216
224
  `${scheme}://${hostname}:${data.port}` + (data.pathname ?? "/")
217
225
  );
218
- this.hostname = domainName ?? address.address;
219
226
  }
220
227
  }
221
228
 
@@ -3,6 +3,7 @@ import { FAMILY_IPV6 } from "ip-utilties";
3
3
  import {
4
4
  FAMILY_UNIX,
5
5
  FAMILY_IPV4_IPV6,
6
+ FAMILY_DNS_IPV4_IPV6,
6
7
  PROTOCOL_UDP,
7
8
  PROTOCOL_TCP
8
9
  } from "./constants.mjs";
@@ -103,7 +104,7 @@ export const ServiceTypes = {
103
104
  ldap: {
104
105
  endpoints: [
105
106
  {
106
- family: FAMILY_IPV4_IPV6,
107
+ family: FAMILY_DNS_IPV4_IPV6,
107
108
  scheme: "ldap",
108
109
  protocol: PROTOCOL_TCP,
109
110
  port: 389,
@@ -114,7 +115,7 @@ export const ServiceTypes = {
114
115
  ldaps: {
115
116
  endpoints: [
116
117
  {
117
- family: FAMILY_IPV4_IPV6,
118
+ family: FAMILY_DNS_IPV4_IPV6,
118
119
  scheme: "ldaps",
119
120
  protocol: PROTOCOL_TCP,
120
121
  port: 636,
@@ -128,7 +129,7 @@ export const ServiceTypes = {
128
129
  http: {
129
130
  endpoints: [
130
131
  {
131
- family: FAMILY_IPV4_IPV6,
132
+ family: FAMILY_DNS_IPV4_IPV6,
132
133
  scheme: "http",
133
134
  protocol: PROTOCOL_TCP,
134
135
  port: 80,
@@ -139,7 +140,7 @@ export const ServiceTypes = {
139
140
  https: {
140
141
  endpoints: [
141
142
  {
142
- family: FAMILY_IPV4_IPV6,
143
+ family: FAMILY_DNS_IPV4_IPV6,
143
144
  scheme: "https",
144
145
  protocol: PROTOCOL_TCP,
145
146
  port: 443,
@@ -151,7 +152,7 @@ export const ServiceTypes = {
151
152
  http3: {
152
153
  endpoints: [
153
154
  {
154
- family: FAMILY_IPV4_IPV6,
155
+ family: FAMILY_DNS_IPV4_IPV6,
155
156
  scheme: "https",
156
157
  protocol: PROTOCOL_UDP,
157
158
  port: 443,
@@ -3,7 +3,7 @@ import { stringify } from "yaml";
3
3
  import { boolean_attribute_writable_true } from "pacc";
4
4
  import { CoreService, addType } from "pmcf";
5
5
  import { writeLines, filterConfigurable } from "../utils.mjs";
6
- import { FAMILY_IPV4_IPV6, PROTOCOL_TCP } from "../constants.mjs";
6
+ import { FAMILY_DNS_IPV4_IPV6, PROTOCOL_TCP } from "../constants.mjs";
7
7
 
8
8
  export class influxdb extends CoreService {
9
9
  static attributes = {
@@ -17,11 +17,11 @@ export class influxdb extends CoreService {
17
17
  static service = {
18
18
  endpoints: [
19
19
  {
20
- family: FAMILY_IPV4_IPV6,
20
+ family: FAMILY_DNS_IPV4_IPV6,
21
21
  port: 8086,
22
22
  protocol: PROTOCOL_TCP,
23
23
  tls: false,
24
- pathname: "/"
24
+ scheme: "http"
25
25
  }
26
26
  ]
27
27
  };
@@ -136,8 +136,8 @@ export class kea extends CoreService {
136
136
  {
137
137
  family: FAMILY_IPV4,
138
138
  port: 53003,
139
- pathname: "/",
140
139
  protocol: PROTOCOL_TCP,
140
+ scheme: "http",
141
141
  tls: false
142
142
  }
143
143
  ]
@@ -165,8 +165,8 @@ export class kea extends CoreService {
165
165
  {
166
166
  family: FAMILY_IPV6,
167
167
  port: 53004,
168
- pathname: "/",
169
168
  protocol: PROTOCOL_TCP,
169
+ scheme: "http",
170
170
  tls: false
171
171
  }
172
172
  ]