pmcf 6.65.5 → 6.66.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": "6.65.5",
3
+ "version": "6.66.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/constants.mjs CHANGED
@@ -7,4 +7,5 @@ export const PROTOCOL_QUIC = "quic";
7
7
  export const FAMILY_UNIX = "unix";
8
8
  export const FAMILY_DNS = "dns";
9
9
  export const FAMILY_IPV4_IPV6 = new Set([FAMILY_IPV4, FAMILY_IPV6]);
10
+ export const FAMILY_DNS_IPV4_IPV6 = new Set([FAMILY_DNS, FAMILY_IPV4, FAMILY_IPV6]);
10
11
 
@@ -145,6 +145,8 @@ export class CoreService extends base {
145
145
  filter = undefined;
146
146
  }
147
147
 
148
+ const seen = new Set();
149
+
148
150
  for (const e of data) {
149
151
  if (type && e.type.name !== type) {
150
152
  continue;
@@ -172,7 +174,11 @@ export class CoreService extends base {
172
174
  }
173
175
 
174
176
  if (e.scheme || e.pathname) {
175
- result.push(new HTTPEndpoint(this, na, options));
177
+ const he = new HTTPEndpoint(this, na, options);
178
+ if (!seen.has(he.url.toString())) {
179
+ seen.add(he.url.toString());
180
+ result.push(he);
181
+ }
176
182
  } else {
177
183
  result.push(new Endpoint(this, na, options));
178
184
  }
package/src/endpoint.mjs CHANGED
@@ -169,12 +169,13 @@ export class DomainNameEndpoint extends PortEndpoint {
169
169
  }
170
170
 
171
171
  /**
172
- * Endpoint based on http
172
+ * Endpoint based on url
173
173
  */
174
174
  export class HTTPEndpoint extends BaseEndpoint {
175
175
  static name = "url_endpoint";
176
176
  static attributes = {
177
- url: url_attribute
177
+ url: url_attribute,
178
+ addressType: { ...string_attribute, name: "addressType" }
178
179
  };
179
180
 
180
181
  static {
@@ -199,21 +200,22 @@ export class HTTPEndpoint extends BaseEndpoint {
199
200
  } else if (address instanceof URL) {
200
201
  this.url = address;
201
202
  } else {
203
+ this.networkAddress = address;
202
204
  this.family = data.family ?? address.family;
203
205
 
204
- const scheme = data.scheme ?
205
- `${data.scheme}://` :
206
- (data.tls ? "https://" : "http://");
207
-
208
- this.url = new URL(scheme +
209
- (data.family === FAMILY_IPV6
210
- ? "[" + address.address + "]"
211
- : address.address) +
212
- ":" +
213
- data.port +
214
- (data.pathname ?? "/")
206
+ const scheme = data.scheme ? data.scheme : data.tls ? "https" : "http";
207
+
208
+ const domainName = [...address.domainNames][0];
209
+ const hostname =
210
+ domainName ??
211
+ (data.family === FAMILY_IPV6
212
+ ? "[" + address.address + "]"
213
+ : address.address);
214
+
215
+ this.url = new URL(
216
+ `${scheme}://${hostname}:${data.port}` + (data.pathname ?? "/")
215
217
  );
216
- this.hostname = address.address;
218
+ this.hostname = domainName ?? address.address;
217
219
  }
218
220
  }
219
221
 
@@ -240,6 +242,10 @@ export class HTTPEndpoint extends BaseEndpoint {
240
242
  return PROTOCOL_TCP;
241
243
  }
242
244
 
245
+ get addressType() {
246
+ return this.networkAddress?.type;
247
+ }
248
+
243
249
  get tls() {
244
250
  return this.url.toString().startsWith("https:");
245
251
  }