@routr/common 2.0.8-alpha.0 → 2.0.8-alpha.2
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 -0
- package/dist/helper.js +19 -1
- package/dist/ip_utils.d.ts +1 -0
- package/dist/ip_utils.js +4 -2
- package/dist/protos/location.proto +1 -1
- package/dist/protos/processor.proto +2 -2
- package/dist/types.d.ts +8 -8
- package/dist/types.js +6 -6
- package/package.json +2 -2
package/dist/helper.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MessageRequest, Transport } from "./types";
|
|
1
2
|
/**
|
|
2
3
|
* Makes a deep copy of an object.
|
|
3
4
|
*
|
|
@@ -5,3 +6,11 @@
|
|
|
5
6
|
* @return {object} The deep copy of the source object.
|
|
6
7
|
*/
|
|
7
8
|
export declare const deepCopy: <T>(source: T) => T;
|
|
9
|
+
/**
|
|
10
|
+
* Gets a listening point from a request.
|
|
11
|
+
*
|
|
12
|
+
* @param {MessageRequest} request - The source object.
|
|
13
|
+
* @param {Transport} transport - The source object.
|
|
14
|
+
* @return {NetInterface} transport The deep copy of the source object.
|
|
15
|
+
*/
|
|
16
|
+
export declare const getListeningPoint: (request: MessageRequest, transport: Transport) => import("./types").NetInterface;
|
package/dist/helper.js
CHANGED
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
* limitations under the License.
|
|
19
19
|
*/
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.deepCopy = void 0;
|
|
21
|
+
exports.getListeningPoint = exports.deepCopy = void 0;
|
|
22
|
+
const types_1 = require("./types");
|
|
22
23
|
/**
|
|
23
24
|
* Makes a deep copy of an object.
|
|
24
25
|
*
|
|
@@ -40,3 +41,20 @@ const deepCopy = (source) => {
|
|
|
40
41
|
: source;
|
|
41
42
|
};
|
|
42
43
|
exports.deepCopy = deepCopy;
|
|
44
|
+
/**
|
|
45
|
+
* Gets a listening point from a request.
|
|
46
|
+
*
|
|
47
|
+
* @param {MessageRequest} request - The source object.
|
|
48
|
+
* @param {Transport} transport - The source object.
|
|
49
|
+
* @return {NetInterface} transport The deep copy of the source object.
|
|
50
|
+
*/
|
|
51
|
+
const getListeningPoint = (request, transport) => {
|
|
52
|
+
const listeningPoint = transport
|
|
53
|
+
? request.listeningPoints.find((lp) => lp.transport.toLowerCase() === transport.toLowerCase())
|
|
54
|
+
: request.listeningPoints.find((lp) => lp.transport.toLowerCase() === types_1.Transport.UDP);
|
|
55
|
+
if (!listeningPoint) {
|
|
56
|
+
throw new Error(`no listening point found for transport ${transport}`);
|
|
57
|
+
}
|
|
58
|
+
return listeningPoint;
|
|
59
|
+
};
|
|
60
|
+
exports.getListeningPoint = getListeningPoint;
|
package/dist/ip_utils.d.ts
CHANGED
|
@@ -2,3 +2,4 @@ export declare const formatNet: (net: string) => string;
|
|
|
2
2
|
export declare const hasIp: (net: string, addr: string) => boolean;
|
|
3
3
|
export declare const addressCount: (net: string) => number;
|
|
4
4
|
export declare const isLocalnet: (nets: string[], addr: string) => boolean;
|
|
5
|
+
export declare const getLocalnetIp: (nets: string[], addr: string) => string;
|
package/dist/ip_utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isLocalnet = exports.addressCount = exports.hasIp = exports.formatNet = void 0;
|
|
3
|
+
exports.getLocalnetIp = exports.isLocalnet = exports.addressCount = exports.hasIp = exports.formatNet = void 0;
|
|
4
4
|
/*
|
|
5
5
|
* Copyright (C) 2022 by Fonoster Inc (https://fonoster.com)
|
|
6
6
|
* http://github.com/fonoster/routr
|
|
@@ -39,5 +39,7 @@ const hasIp = (net, addr) => (0, ip_utils_1.subnet)((0, exports.formatNet)(net))
|
|
|
39
39
|
exports.hasIp = hasIp;
|
|
40
40
|
const addressCount = (net) => (0, ip_utils_1.cidrInfo)((0, exports.formatNet)(net)).inclusiveNumberHosts;
|
|
41
41
|
exports.addressCount = addressCount;
|
|
42
|
-
const isLocalnet = (nets, addr) => nets
|
|
42
|
+
const isLocalnet = (nets, addr) => (nets === null || nets === void 0 ? void 0 : nets.filter((net) => (0, exports.hasIp)(net, addr)).length) > 0;
|
|
43
43
|
exports.isLocalnet = isLocalnet;
|
|
44
|
+
const getLocalnetIp = (nets, addr) => { var _a; return (_a = nets === null || nets === void 0 ? void 0 : nets.filter((net) => (0, exports.hasIp)(net, addr))[0]) === null || _a === void 0 ? void 0 : _a.split("/")[0]; };
|
|
45
|
+
exports.getLocalnetIp = getLocalnetIp;
|
|
@@ -44,7 +44,7 @@ message Route {
|
|
|
44
44
|
int32 expires = 6;
|
|
45
45
|
int32 session_count = 7;
|
|
46
46
|
string edge_port_ref = 8;
|
|
47
|
-
fonoster.routr.processor.v2draft1.NetInterface
|
|
47
|
+
fonoster.routr.processor.v2draft1.NetInterface egress_listening_point = 9;
|
|
48
48
|
// During route creation, an endpoint can request to add labels than can later be
|
|
49
49
|
// used as selectors. For example, a Softphone can add a label `priority=1` to indicate
|
|
50
50
|
// that it is the prefered endpoint for the given AOR.
|
|
@@ -78,11 +78,11 @@ message MessageRequest {
|
|
|
78
78
|
string edge_port_ref = 2;
|
|
79
79
|
Method method = 3;
|
|
80
80
|
NetInterface sender = 4;
|
|
81
|
-
NetInterface
|
|
81
|
+
repeated NetInterface listening_points = 5;
|
|
82
82
|
repeated string external_addrs = 6;
|
|
83
83
|
repeated string localnets = 7;
|
|
84
84
|
fonoster.routr.sipmessage.v2draft1.SIPMessage message = 8;
|
|
85
|
-
// .google.protobuf.Struct metadata =
|
|
85
|
+
// .google.protobuf.Struct metadata = 9;
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
message MessageResponse {
|
package/dist/types.d.ts
CHANGED
|
@@ -13,12 +13,12 @@ export declare enum Method {
|
|
|
13
13
|
OPTIONS = "OPTIONS"
|
|
14
14
|
}
|
|
15
15
|
export declare enum Transport {
|
|
16
|
-
TCP = "
|
|
17
|
-
UDP = "
|
|
18
|
-
TLS = "
|
|
19
|
-
SCTP = "
|
|
20
|
-
WS = "
|
|
21
|
-
WSS = "
|
|
16
|
+
TCP = "tcp",
|
|
17
|
+
UDP = "udp",
|
|
18
|
+
TLS = "tls",
|
|
19
|
+
SCTP = "sctp",
|
|
20
|
+
WS = "ws",
|
|
21
|
+
WSS = "wss"
|
|
22
22
|
}
|
|
23
23
|
export declare enum ExtraHeader {
|
|
24
24
|
REQUEST_URI = "X-Request-Uri",
|
|
@@ -40,7 +40,7 @@ export interface MessageRequest {
|
|
|
40
40
|
edgePortRef: string;
|
|
41
41
|
method: Method;
|
|
42
42
|
sender: NetInterface;
|
|
43
|
-
|
|
43
|
+
listeningPoints: NetInterface[];
|
|
44
44
|
externalAddrs: string[];
|
|
45
45
|
localnets: string[];
|
|
46
46
|
message: SIPMessage;
|
|
@@ -113,7 +113,7 @@ export interface Route {
|
|
|
113
113
|
sessionCount?: number;
|
|
114
114
|
expires?: number;
|
|
115
115
|
edgePortRef: string;
|
|
116
|
-
|
|
116
|
+
egressListeningPoint: NetInterface;
|
|
117
117
|
labels?: Map<string, string>;
|
|
118
118
|
headers?: HeaderModifier[];
|
|
119
119
|
}
|
package/dist/types.js
CHANGED
|
@@ -17,12 +17,12 @@ var Method;
|
|
|
17
17
|
})(Method = exports.Method || (exports.Method = {}));
|
|
18
18
|
var Transport;
|
|
19
19
|
(function (Transport) {
|
|
20
|
-
Transport["TCP"] = "
|
|
21
|
-
Transport["UDP"] = "
|
|
22
|
-
Transport["TLS"] = "
|
|
23
|
-
Transport["SCTP"] = "
|
|
24
|
-
Transport["WS"] = "
|
|
25
|
-
Transport["WSS"] = "
|
|
20
|
+
Transport["TCP"] = "tcp";
|
|
21
|
+
Transport["UDP"] = "udp";
|
|
22
|
+
Transport["TLS"] = "tls";
|
|
23
|
+
Transport["SCTP"] = "sctp";
|
|
24
|
+
Transport["WS"] = "ws";
|
|
25
|
+
Transport["WSS"] = "wss";
|
|
26
26
|
})(Transport = exports.Transport || (exports.Transport = {}));
|
|
27
27
|
var ExtraHeader;
|
|
28
28
|
(function (ExtraHeader) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@routr/common",
|
|
3
|
-
"version": "2.0.8-alpha.
|
|
3
|
+
"version": "2.0.8-alpha.2",
|
|
4
4
|
"description": "Common package",
|
|
5
5
|
"author": "Pedro Sanders <psanders@fonoster.com>",
|
|
6
6
|
"homepage": "https://github.com/fonoster/routr#readme",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"bugs": {
|
|
46
46
|
"url": "https://github.com/fonoster/routr/issues"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "28ab976b0ef8b5cd34e278ea6fda13c518d7d052"
|
|
49
49
|
}
|