@routr/common 2.31.2 → 2.31.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.
@@ -87,6 +87,8 @@ message MessageRequest {
87
87
  string edge_port_version = 10;
88
88
  // Local socket the EdgePort received the message on
89
89
  NetInterface received_on = 11;
90
+ // Hostnames this EdgePort answers to (spec.aliases)
91
+ repeated string aliases = 12;
90
92
  }
91
93
 
92
94
  message MessageResponse {
@@ -26,6 +26,16 @@ export declare const isExternalHost: (req: MessageRequest, host?: string) => boo
26
26
  */
27
27
  export declare const isInternalHost: (req: MessageRequest, host?: string) => boolean;
28
28
  export declare const isOwnHost: (req: MessageRequest, host?: string) => boolean;
29
+ /**
30
+ * Whether a host is one of the names the proxy answers to (spec.aliases),
31
+ * compared case-insensitively. Aliases are never advertised, so only rules
32
+ * about Route entries pointing at the proxy use this.
33
+ *
34
+ * @param {MessageRequest} req - The recorded request
35
+ * @param {string} host - Host to test
36
+ * @return {boolean} True for an alias
37
+ */
38
+ export declare const isAliasHost: (req: MessageRequest, host?: string) => boolean;
29
39
  export declare const requestsIn: (call: TraceRecord[]) => TraceRecord[];
30
40
  /**
31
41
  * Identifies the party that sent a request: its From URI and tag. Both are
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.uriOf = exports.isE164 = exports.directionOf = exports.requestsIn = exports.isOwnHost = exports.isInternalHost = exports.isExternalHost = exports.topBranch = exports.topVia = exports.cseqOf = exports.headerValues = exports.statusOf = exports.isInDialog = exports.isRelayed = exports.isForwarded = exports.isResponse = exports.isRequest = exports.outbound = exports.inbound = void 0;
3
+ exports.uriOf = exports.isE164 = exports.directionOf = exports.requestsIn = exports.isAliasHost = exports.isOwnHost = exports.isInternalHost = exports.isExternalHost = exports.topBranch = exports.topVia = exports.cseqOf = exports.headerValues = exports.statusOf = exports.isInDialog = exports.isRelayed = exports.isForwarded = exports.isResponse = exports.isRequest = exports.outbound = exports.inbound = void 0;
4
4
  const types_1 = require("../types");
5
5
  const status_1 = require("../status");
6
6
  /*
@@ -64,6 +64,18 @@ const isInternalHost = (req, host) => {
64
64
  exports.isInternalHost = isInternalHost;
65
65
  const isOwnHost = (req, host) => (0, exports.isExternalHost)(req, host) || (0, exports.isInternalHost)(req, host);
66
66
  exports.isOwnHost = isOwnHost;
67
+ /**
68
+ * Whether a host is one of the names the proxy answers to (spec.aliases),
69
+ * compared case-insensitively. Aliases are never advertised, so only rules
70
+ * about Route entries pointing at the proxy use this.
71
+ *
72
+ * @param {MessageRequest} req - The recorded request
73
+ * @param {string} host - Host to test
74
+ * @return {boolean} True for an alias
75
+ */
76
+ const isAliasHost = (req, host) => !!host &&
77
+ (req.aliases || []).some((a) => a.toLowerCase() === host.toLowerCase());
78
+ exports.isAliasHost = isAliasHost;
67
79
  const inNet = (host, net) => {
68
80
  const [base, bitsRaw] = net.split("/");
69
81
  const bits = bitsRaw === undefined ? 32 : parseInt(bitsRaw, 10);
@@ -31,7 +31,11 @@ exports.default = (0, types_1.defineRule)({
31
31
  var _a;
32
32
  if (!(0, facts_1.isForwarded)(record))
33
33
  return;
34
- const own = (((_a = (0, facts_1.outbound)(record)) === null || _a === void 0 ? void 0 : _a.route) || []).find((r) => { var _a, _b; return (0, facts_1.isOwnHost)(record.request, (_b = (_a = r.address) === null || _a === void 0 ? void 0 : _a.uri) === null || _b === void 0 ? void 0 : _b.host); });
34
+ const own = (((_a = (0, facts_1.outbound)(record)) === null || _a === void 0 ? void 0 : _a.route) || []).find((r) => {
35
+ var _a, _b, _c, _d;
36
+ return (0, facts_1.isOwnHost)(record.request, (_b = (_a = r.address) === null || _a === void 0 ? void 0 : _a.uri) === null || _b === void 0 ? void 0 : _b.host) ||
37
+ (0, facts_1.isAliasHost)(record.request, (_d = (_c = r.address) === null || _c === void 0 ? void 0 : _c.uri) === null || _d === void 0 ? void 0 : _d.host);
38
+ });
35
39
  if (own) {
36
40
  return fail(`outgoing request still carries a Route to ${own.address.uri.host}, one of the proxy's interfaces`, "out", "Route");
37
41
  }
@@ -100,6 +100,12 @@ export declare const traceRecordSchema: {
100
100
  type: string;
101
101
  };
102
102
  };
103
+ aliases: {
104
+ type: string;
105
+ items: {
106
+ type: string;
107
+ };
108
+ };
103
109
  message: {
104
110
  type: string;
105
111
  properties: {
@@ -108,6 +108,7 @@ const request = {
108
108
  listeningPoints: { type: "array" },
109
109
  externalAddrs: { type: "array", items: { type: "string" } },
110
110
  localnets: { type: "array", items: { type: "string" } },
111
+ aliases: { type: "array", items: { type: "string" } },
111
112
  message: sipMessage,
112
113
  metadata: stringMap,
113
114
  edgePortVersion: { type: "string" },
package/dist/types.d.ts CHANGED
@@ -69,6 +69,7 @@ export interface MessageRequest {
69
69
  metadata?: Record<string, string>;
70
70
  edgePortVersion?: string;
71
71
  receivedOn?: NetInterface;
72
+ aliases?: string[];
72
73
  }
73
74
  export interface MessageResponse {
74
75
  message: Record<string, unknown>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@routr/common",
3
- "version": "2.31.2",
3
+ "version": "2.31.3",
4
4
  "description": "Common package",
5
5
  "author": "Pedro Sanders <psanders@fonoster.com>",
6
6
  "homepage": "https://github.com/fonoster/routr#readme",
@@ -61,5 +61,5 @@
61
61
  "devDependencies": {
62
62
  "@types/js-yaml": "^4.0.5"
63
63
  },
64
- "gitHead": "170b3eff626b866f5ce79807a6748258da687e82"
64
+ "gitHead": "7178a8d1ad402c3a00b31b55c8b63ecd2527c975"
65
65
  }