@routr/location 2.0.8-alpha.35 → 2.0.8-alpha.36
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/dist/helper.d.ts +9 -1
- package/dist/helper.js +26 -22
- package/dist/location.d.ts +0 -1
- package/dist/location.js +3 -4
- package/package.json +3 -3
package/dist/helper.d.ts
CHANGED
|
@@ -1,2 +1,10 @@
|
|
|
1
1
|
import { MessageRequest, Route } from "@routr/common";
|
|
2
|
-
export declare
|
|
2
|
+
export declare function createRoute(request: MessageRequest): Route;
|
|
3
|
+
/**
|
|
4
|
+
* A request traversing a second EdgePort would have updated the requestUri.
|
|
5
|
+
* Therefore, we are able to re-construct the Route from the request.
|
|
6
|
+
*
|
|
7
|
+
* @param {MessageRequest} request - the request
|
|
8
|
+
* @return {Route} the route
|
|
9
|
+
*/
|
|
10
|
+
export declare function createRouteFromLastMessage(request: MessageRequest): Route;
|
package/dist/helper.js
CHANGED
|
@@ -1,35 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createRoute = void 0;
|
|
4
|
-
/*
|
|
5
|
-
* Copyright (C) 2023 by Fonoster Inc (https://fonoster.com)
|
|
6
|
-
* http://github.com/fonoster/routr
|
|
7
|
-
*
|
|
8
|
-
* This file is part of Routr
|
|
9
|
-
*
|
|
10
|
-
* Licensed under the MIT License (the "License")
|
|
11
|
-
* you may not use this file except in compliance with
|
|
12
|
-
* the License. You may obtain a copy of the License at
|
|
13
|
-
*
|
|
14
|
-
* https://opensource.org/licenses/MIT
|
|
15
|
-
*
|
|
16
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
17
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
19
|
-
* See the License for the specific language governing permissions and
|
|
20
|
-
* limitations under the License.
|
|
21
|
-
*/
|
|
3
|
+
exports.createRouteFromLastMessage = exports.createRoute = void 0;
|
|
22
4
|
const common_1 = require("@routr/common");
|
|
23
5
|
const processor_1 = require("@routr/processor");
|
|
6
|
+
/* eslint-disable require-jsdoc */
|
|
24
7
|
// TODO: Before finalizing this, consider using the old approach of saving the rport
|
|
25
8
|
// and received values (like here:
|
|
26
9
|
// https://github.com/fonoster/routr/blob/59bc98af86078088aede7e658c0d82a19fa18fa4/mod/registrar/utils.js#L87)
|
|
27
10
|
//
|
|
28
11
|
// Also consider: https://github.com/fonoster/routr/blob/ee5d339888344013939d06c734385f17f0cd75c2/mod/registrar/utils.js#L116
|
|
29
12
|
// and https://github.com/fonoster/routr/blob/ee5d339888344013939d06c734385f17f0cd75c2/mod/registrar/utils.js#L131
|
|
30
|
-
|
|
13
|
+
function buildRoute(request, uri) {
|
|
31
14
|
var _a;
|
|
32
|
-
const uri = request.message.contact.address.uri;
|
|
33
15
|
const sessionCount = processor_1.Extensions.getHeaderValue(request, common_1.CommonTypes.ExtraHeader.SESSION_COUNT)
|
|
34
16
|
? parseInt(processor_1.Extensions.getHeaderValue(request, common_1.CommonTypes.ExtraHeader.SESSION_COUNT))
|
|
35
17
|
: -1;
|
|
@@ -46,5 +28,27 @@ const createRoute = (request) => {
|
|
|
46
28
|
localnets: request.localnets,
|
|
47
29
|
externalAddrs: request.externalAddrs
|
|
48
30
|
};
|
|
49
|
-
}
|
|
31
|
+
}
|
|
32
|
+
function createRoute(request) {
|
|
33
|
+
const via = request.message.via[0];
|
|
34
|
+
const uri = {
|
|
35
|
+
host: via.received || via.host,
|
|
36
|
+
port: via.rPort !== -1 ? via.rPort : via.port,
|
|
37
|
+
transportParam: via.transport.toUpperCase(),
|
|
38
|
+
user: request.message.contact.address.uri.user
|
|
39
|
+
};
|
|
40
|
+
return buildRoute(request, uri);
|
|
41
|
+
}
|
|
50
42
|
exports.createRoute = createRoute;
|
|
43
|
+
/**
|
|
44
|
+
* A request traversing a second EdgePort would have updated the requestUri.
|
|
45
|
+
* Therefore, we are able to re-construct the Route from the request.
|
|
46
|
+
*
|
|
47
|
+
* @param {MessageRequest} request - the request
|
|
48
|
+
* @return {Route} the route
|
|
49
|
+
*/
|
|
50
|
+
function createRouteFromLastMessage(request) {
|
|
51
|
+
const uri = request.message.requestUri;
|
|
52
|
+
return buildRoute(request, uri);
|
|
53
|
+
}
|
|
54
|
+
exports.createRouteFromLastMessage = createRouteFromLastMessage;
|
package/dist/location.d.ts
CHANGED
|
@@ -10,7 +10,6 @@ export default class Location implements ILocationService {
|
|
|
10
10
|
* Creates a new Location service. Should fail if any backend has sessionAffinity and round-robin
|
|
11
11
|
*
|
|
12
12
|
* @param {ILocatorStore} store - The store to use for the location service
|
|
13
|
-
* @param {Map<string, Backend>} backends - The backends to use for the location service
|
|
14
13
|
*/
|
|
15
14
|
constructor(store: ILocatorStore);
|
|
16
15
|
/** @inheritdoc */
|
package/dist/location.js
CHANGED
|
@@ -43,7 +43,6 @@ class Location {
|
|
|
43
43
|
* Creates a new Location service. Should fail if any backend has sessionAffinity and round-robin
|
|
44
44
|
*
|
|
45
45
|
* @param {ILocatorStore} store - The store to use for the location service
|
|
46
|
-
* @param {Map<string, Backend>} backends - The backends to use for the location service
|
|
47
46
|
*/
|
|
48
47
|
constructor(store) {
|
|
49
48
|
this.store = store;
|
|
@@ -61,7 +60,7 @@ class Location {
|
|
|
61
60
|
findRoutes(request) {
|
|
62
61
|
var _a;
|
|
63
62
|
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
-
let routes = yield this.store.get(request.callId);
|
|
63
|
+
let routes = yield this.store.get(`${request.aor}:${request.callId}`);
|
|
65
64
|
if (routes.length > 0) {
|
|
66
65
|
return routes;
|
|
67
66
|
}
|
|
@@ -70,7 +69,7 @@ class Location {
|
|
|
70
69
|
: (_a = (yield this.store.get(request.aor))) !== null && _a !== void 0 ? _a : [];
|
|
71
70
|
if (request.aor.startsWith(AOR_SCHEME.SIP)) {
|
|
72
71
|
// Set call to the last route
|
|
73
|
-
this.store.put(request.callId
|
|
72
|
+
this.store.put(`${request.aor}:${request.callId}`, routes[0]);
|
|
74
73
|
return routes;
|
|
75
74
|
}
|
|
76
75
|
else if (request.aor.startsWith(AOR_SCHEME.BACKEND)) {
|
|
@@ -82,7 +81,7 @@ class Location {
|
|
|
82
81
|
? [yield this.nextWithAffinity(routes, request.sessionAffinityRef)]
|
|
83
82
|
: [this.next(routes, backend)];
|
|
84
83
|
// Next time we will get the route with callId
|
|
85
|
-
this.store.put(request.callId
|
|
84
|
+
this.store.put(`${request.aor}:${request.callId}`, r[0]);
|
|
86
85
|
return r;
|
|
87
86
|
}
|
|
88
87
|
throw new errors_1.UnsupportedSchema(request.aor);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@routr/location",
|
|
3
|
-
"version": "2.0.8-alpha.
|
|
3
|
+
"version": "2.0.8-alpha.36",
|
|
4
4
|
"description": "Creates and maintains a list of routes to all registered endpoints",
|
|
5
5
|
"author": "Pedro Sanders <psanders@fonoster.com>",
|
|
6
6
|
"homepage": "https://github.com/fonoster/routr#readme",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@opentelemetry/sdk-trace-node": "^1.0.4",
|
|
38
38
|
"@opentelemetry/semantic-conventions": "^1.0.4",
|
|
39
39
|
"@routr/common": "^2.0.8-alpha.33",
|
|
40
|
-
"@routr/processor": "^2.0.8-alpha.
|
|
40
|
+
"@routr/processor": "^2.0.8-alpha.36",
|
|
41
41
|
"ajv": "^6.12.6",
|
|
42
42
|
"fp-ts": "^2.11.8",
|
|
43
43
|
"redis": "^4.0.4"
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"bugs": {
|
|
50
50
|
"url": "https://github.com/fonoster/routr/issues"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "88b5c909892c32a5663ee3fee30910df2ecaf2aa"
|
|
53
53
|
}
|