@routr/edgeport 2.0.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.
- package/LICENSE +21 -0
- package/dist/assertions.d.ts +5 -0
- package/dist/assertions.js +37 -0
- package/dist/config/fs.d.ts +2 -0
- package/dist/config/fs.js +24 -0
- package/dist/config/get_config.d.ts +5 -0
- package/dist/config/get_config.js +53 -0
- package/dist/config/schema.d.ts +96 -0
- package/dist/config/schema.js +117 -0
- package/dist/create_listening_points.d.ts +2 -0
- package/dist/create_listening_points.js +44 -0
- package/dist/create_sip_provider.d.ts +2 -0
- package/dist/create_sip_provider.js +9 -0
- package/dist/create_sip_stack.d.ts +6 -0
- package/dist/create_sip_stack.js +40 -0
- package/dist/edgeport.d.ts +2 -0
- package/dist/edgeport.js +20 -0
- package/dist/runner.d.ts +2 -0
- package/dist/runner.js +15 -0
- package/dist/server_properties.d.ts +7 -0
- package/dist/server_properties.js +35 -0
- package/dist/types.d.ts +36 -0
- package/dist/types.js +2 -0
- package/package.json +32 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Fonoster Inc
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { EdgePortConfig, Transport } from "./types";
|
|
2
|
+
export declare const isSecureProto: (proto: string) => boolean;
|
|
3
|
+
export declare const assertHasSecurityContext: (config: EdgePortConfig) => void;
|
|
4
|
+
export declare const assertNoDuplicatedProto: (transports: Array<Transport>) => void;
|
|
5
|
+
export declare const assertNoDuplicatedPort: (transports: Array<Transport>) => void;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assertNoDuplicatedPort = exports.assertNoDuplicatedProto = exports.assertHasSecurityContext = exports.isSecureProto = void 0;
|
|
4
|
+
// We need to have the spec.securityContext for all secure protocol
|
|
5
|
+
var isSecureProto = function (proto) { return proto === 'wss' || proto === 'tls'; };
|
|
6
|
+
exports.isSecureProto = isSecureProto;
|
|
7
|
+
// We need to have the spec.securityContext for all secure protocol
|
|
8
|
+
var assertHasSecurityContext = function (config) {
|
|
9
|
+
var hasSecureProto = config.spec.transport.some(function (t1) { return exports.isSecureProto(t1.protocol); });
|
|
10
|
+
if (hasSecureProto && !config.spec.securityContext) {
|
|
11
|
+
throw new Error('found at least one secure protocol which requires setting the .spec.securityContext');
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
exports.assertHasSecurityContext = assertHasSecurityContext;
|
|
15
|
+
// Only one entry per protocol is allowed
|
|
16
|
+
var assertNoDuplicatedProto = function (transports) {
|
|
17
|
+
if (transports.some(function (t1) {
|
|
18
|
+
return transports.filter(function (t2) { return t1.protocol === t2.protocol; }).length > 1;
|
|
19
|
+
})) {
|
|
20
|
+
throw new Error('found duplicated entries at .spec.transport');
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
exports.assertNoDuplicatedProto = assertNoDuplicatedProto;
|
|
24
|
+
// The only protocol that can accept the same port twice are udp and tcp
|
|
25
|
+
var assertNoDuplicatedPort = function (transports) {
|
|
26
|
+
var duplicateCondition = function (t1, t2) {
|
|
27
|
+
return (t1.port === t2.port &&
|
|
28
|
+
t1.protocol !== 'udp' &&
|
|
29
|
+
t1.protocol !== 'tcp');
|
|
30
|
+
};
|
|
31
|
+
if (transports.some(function (t1) {
|
|
32
|
+
return transports.filter(function (t2) { return duplicateCondition(t1, t2); }).length > 1;
|
|
33
|
+
})) {
|
|
34
|
+
throw new Error("found the same port on more that one entry at .spec.transport");
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
exports.assertNoDuplicatedPort = assertNoDuplicatedPort;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.writeFile = exports.readFile = void 0;
|
|
4
|
+
var BufferedWriter = Java.type('java.io.BufferedWriter');
|
|
5
|
+
var FileWriter = Java.type('java.io.FileWriter');
|
|
6
|
+
var JFile = Java.type('java.io.File');
|
|
7
|
+
var Files = Java.type('java.nio.file.Files');
|
|
8
|
+
var Paths = Java.type('java.nio.file.Paths');
|
|
9
|
+
var readFile = function (path) {
|
|
10
|
+
var lines = Files.readAllLines(Paths.get(path), Java.type('java.nio.charset.StandardCharsets').UTF_8);
|
|
11
|
+
var data = [];
|
|
12
|
+
lines.forEach(function (line) {
|
|
13
|
+
data.push(line);
|
|
14
|
+
});
|
|
15
|
+
return data.join('\n').trim();
|
|
16
|
+
};
|
|
17
|
+
exports.readFile = readFile;
|
|
18
|
+
var writeFile = function (path, text) {
|
|
19
|
+
var file = new JFile(path);
|
|
20
|
+
var out = new BufferedWriter(new FileWriter(file));
|
|
21
|
+
out.write(text);
|
|
22
|
+
out.close();
|
|
23
|
+
};
|
|
24
|
+
exports.writeFile = writeFile;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import * as J from 'fp-ts/Json';
|
|
2
|
+
import * as E from 'fp-ts/Either';
|
|
3
|
+
export declare const readFile: (path: string) => E.Either<Error, string>;
|
|
4
|
+
export declare const validateConfig: (j: J.Json) => E.Either<Error, J.Json>;
|
|
5
|
+
export declare const getConfig: <C>(path: string) => E.Either<Error, C>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.getConfig = exports.validateConfig = exports.readFile = void 0;
|
|
26
|
+
var E = __importStar(require("fp-ts/Either"));
|
|
27
|
+
var F = __importStar(require("./fs"));
|
|
28
|
+
var function_1 = require("fp-ts/function");
|
|
29
|
+
var schema_1 = require("./schema");
|
|
30
|
+
var ajv_1 = __importDefault(require("ajv"));
|
|
31
|
+
var ajv = new ajv_1.default();
|
|
32
|
+
var validate = ajv.compile(schema_1.schema);
|
|
33
|
+
// Reads a file a returns as a string
|
|
34
|
+
var readFile = function (path) {
|
|
35
|
+
return E.tryCatch(function () { return F.readFile(path); }, E.toError);
|
|
36
|
+
};
|
|
37
|
+
exports.readFile = readFile;
|
|
38
|
+
// Validate Json with Ajv
|
|
39
|
+
var validateConfig = function (j) {
|
|
40
|
+
return E.tryCatch(function () {
|
|
41
|
+
if (validate(j))
|
|
42
|
+
return j;
|
|
43
|
+
throw new Error(validate.errors[0].message);
|
|
44
|
+
}, E.toError);
|
|
45
|
+
};
|
|
46
|
+
exports.validateConfig = validateConfig;
|
|
47
|
+
// Read a file and validate its content with Ajv
|
|
48
|
+
var getConfig = function (path) {
|
|
49
|
+
return function_1.pipe(path, exports.readFile, E.chain(function (value) {
|
|
50
|
+
return function_1.pipe(E.tryCatch(function () { return JSON.parse(value); }, E.toError), E.chain(exports.validateConfig));
|
|
51
|
+
}), E.map(function (v) { return v; }));
|
|
52
|
+
};
|
|
53
|
+
exports.getConfig = getConfig;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
export declare const schema: {
|
|
2
|
+
$id: string;
|
|
3
|
+
title: string;
|
|
4
|
+
description: string;
|
|
5
|
+
type: string;
|
|
6
|
+
properties: {
|
|
7
|
+
kind: {
|
|
8
|
+
description: string;
|
|
9
|
+
type: string;
|
|
10
|
+
};
|
|
11
|
+
apiVersion: {
|
|
12
|
+
enum: string[];
|
|
13
|
+
};
|
|
14
|
+
metadata: {
|
|
15
|
+
description: string;
|
|
16
|
+
type: string;
|
|
17
|
+
properties: {
|
|
18
|
+
ref: {
|
|
19
|
+
description: string;
|
|
20
|
+
type: string;
|
|
21
|
+
};
|
|
22
|
+
region: {
|
|
23
|
+
description: string;
|
|
24
|
+
type: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
required: string[];
|
|
28
|
+
};
|
|
29
|
+
spec: {
|
|
30
|
+
description: string;
|
|
31
|
+
type: string;
|
|
32
|
+
properties: {
|
|
33
|
+
bindAddr: {
|
|
34
|
+
description: string;
|
|
35
|
+
type: string;
|
|
36
|
+
};
|
|
37
|
+
advertisedAddrs: {
|
|
38
|
+
description: string;
|
|
39
|
+
type: string;
|
|
40
|
+
items: {
|
|
41
|
+
type: string;
|
|
42
|
+
};
|
|
43
|
+
uniqueItems: boolean;
|
|
44
|
+
minItems: number;
|
|
45
|
+
};
|
|
46
|
+
localnets: {
|
|
47
|
+
description: string;
|
|
48
|
+
type: string;
|
|
49
|
+
items: {
|
|
50
|
+
type: string;
|
|
51
|
+
};
|
|
52
|
+
uniqueItems: boolean;
|
|
53
|
+
minItems: number;
|
|
54
|
+
};
|
|
55
|
+
methods: {
|
|
56
|
+
description: string;
|
|
57
|
+
type: string;
|
|
58
|
+
items: {
|
|
59
|
+
type: string;
|
|
60
|
+
};
|
|
61
|
+
uniqueItems: boolean;
|
|
62
|
+
};
|
|
63
|
+
transport: {
|
|
64
|
+
description: string;
|
|
65
|
+
type: string;
|
|
66
|
+
items: {
|
|
67
|
+
type: string;
|
|
68
|
+
};
|
|
69
|
+
properties: {
|
|
70
|
+
protocol: {
|
|
71
|
+
type: string;
|
|
72
|
+
};
|
|
73
|
+
bindAddr: {
|
|
74
|
+
type: string;
|
|
75
|
+
};
|
|
76
|
+
port: {
|
|
77
|
+
type: string;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
required: string[];
|
|
81
|
+
};
|
|
82
|
+
messageRouter: {
|
|
83
|
+
description: string;
|
|
84
|
+
type: string;
|
|
85
|
+
properties: {
|
|
86
|
+
addr: {
|
|
87
|
+
type: string;
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
required: string[];
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
required: string[];
|
|
96
|
+
};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.schema = void 0;
|
|
4
|
+
/*
|
|
5
|
+
* Copyright (C) 2021 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
|
+
*/
|
|
22
|
+
exports.schema = {
|
|
23
|
+
"$id": "https://json-schema.org/draft/2020-12/schema",
|
|
24
|
+
"title": "EdgPort configuration",
|
|
25
|
+
"description": "Configuration for an EdgePort instance",
|
|
26
|
+
"type": "object",
|
|
27
|
+
"properties": {
|
|
28
|
+
"kind": {
|
|
29
|
+
"description": "Resouce type",
|
|
30
|
+
"type": "string"
|
|
31
|
+
},
|
|
32
|
+
"apiVersion": {
|
|
33
|
+
"enum": ["v2draft1", "v2.0", "v2"]
|
|
34
|
+
},
|
|
35
|
+
"metadata": {
|
|
36
|
+
"description": "Resource metadata",
|
|
37
|
+
"type": "object",
|
|
38
|
+
"properties": {
|
|
39
|
+
"ref": {
|
|
40
|
+
"description": "EdgePort reference",
|
|
41
|
+
"type": "string"
|
|
42
|
+
},
|
|
43
|
+
"region": {
|
|
44
|
+
"description": "Optional region where the EdgePort is operating",
|
|
45
|
+
"type": "string"
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"required": ["ref"]
|
|
49
|
+
},
|
|
50
|
+
"spec": {
|
|
51
|
+
"description": "Operation spec for the EdgePort",
|
|
52
|
+
"type": "object",
|
|
53
|
+
"properties": {
|
|
54
|
+
"bindAddr": {
|
|
55
|
+
"description": "Ipv4 interface to accept request on",
|
|
56
|
+
"type": "string"
|
|
57
|
+
},
|
|
58
|
+
"advertisedAddrs": {
|
|
59
|
+
"description": "EdgePort external addresses. Might be Ipv4, Hostname",
|
|
60
|
+
"type": "array",
|
|
61
|
+
"items": {
|
|
62
|
+
"type": "string"
|
|
63
|
+
},
|
|
64
|
+
"uniqueItems": true,
|
|
65
|
+
"minItems": 1,
|
|
66
|
+
},
|
|
67
|
+
"localnets": {
|
|
68
|
+
"description": "Networks considered to be in the same local network",
|
|
69
|
+
"type": "array",
|
|
70
|
+
"items": {
|
|
71
|
+
"type": "string"
|
|
72
|
+
},
|
|
73
|
+
"uniqueItems": true,
|
|
74
|
+
"minItems": 1,
|
|
75
|
+
},
|
|
76
|
+
"methods": {
|
|
77
|
+
"description": "Acceptable SIP Methods",
|
|
78
|
+
"type": "array",
|
|
79
|
+
"items": {
|
|
80
|
+
"type": "string"
|
|
81
|
+
},
|
|
82
|
+
"uniqueItems": true
|
|
83
|
+
},
|
|
84
|
+
"transport": {
|
|
85
|
+
"description": "Acceptable Transport Protocols",
|
|
86
|
+
"type": "array",
|
|
87
|
+
"items": {
|
|
88
|
+
"type": "object"
|
|
89
|
+
},
|
|
90
|
+
"properties": {
|
|
91
|
+
"protocol": {
|
|
92
|
+
"type": "string"
|
|
93
|
+
},
|
|
94
|
+
"bindAddr": {
|
|
95
|
+
"type": "string"
|
|
96
|
+
},
|
|
97
|
+
"port": {
|
|
98
|
+
"type": "integer"
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
"required": ["port", "protocol"]
|
|
102
|
+
},
|
|
103
|
+
"messageRouter": {
|
|
104
|
+
"description": "Adjacent service for message routing",
|
|
105
|
+
"type": "object",
|
|
106
|
+
"properties": {
|
|
107
|
+
"addr": {
|
|
108
|
+
"type": "string"
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
"required": ["methods", "transport", "messageRouter"]
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
"required": ["kind", "metadata", "spec", "apiVersion"]
|
|
117
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __values = (this && this.__values) || function(o) {
|
|
3
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
4
|
+
if (m) return m.call(o);
|
|
5
|
+
if (o && typeof o.length === "number") return {
|
|
6
|
+
next: function () {
|
|
7
|
+
if (o && i >= o.length) o = void 0;
|
|
8
|
+
return { value: o && o[i++], done: !o };
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
// Creates LPs for all of the given transport and throws if upstream function fails
|
|
15
|
+
function createListeningPoints(sipStack, config) {
|
|
16
|
+
var e_1, _a;
|
|
17
|
+
var listeningPoints = [];
|
|
18
|
+
try {
|
|
19
|
+
for (var _b = __values(config.spec.transport), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
20
|
+
var trans = _c.value;
|
|
21
|
+
var proto = trans.protocol.toLowerCase();
|
|
22
|
+
// If none was found we use the global bindAddr
|
|
23
|
+
if (trans.bindAddr === undefined) {
|
|
24
|
+
trans.bindAddr = config.spec.bindAddr;
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
var lp = sipStack.createListeningPoint(trans.bindAddr, trans.port, proto);
|
|
28
|
+
listeningPoints.push(lp);
|
|
29
|
+
}
|
|
30
|
+
catch (e) {
|
|
31
|
+
throw new Error("unable to bind " + proto + "://" + trans.bindAddr + ":" + trans.port);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
36
|
+
finally {
|
|
37
|
+
try {
|
|
38
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
39
|
+
}
|
|
40
|
+
finally { if (e_1) throw e_1.error; }
|
|
41
|
+
}
|
|
42
|
+
return listeningPoints;
|
|
43
|
+
}
|
|
44
|
+
exports.default = createListeningPoints;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
function createSipProvider(sipStack, listeningPoints) {
|
|
4
|
+
var _a;
|
|
5
|
+
var sipProvider = sipStack.createSipProvider(listeningPoints[0]);
|
|
6
|
+
(_a = listeningPoints === null || listeningPoints === void 0 ? void 0 : listeningPoints.filter((function (lp, index) { return index > 0; }))) === null || _a === void 0 ? void 0 : _a.forEach(function (lp) { return sipProvider.addListeningPoint(lp); });
|
|
7
|
+
return sipProvider;
|
|
8
|
+
}
|
|
9
|
+
exports.default = createSipProvider;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __values = (this && this.__values) || function(o) {
|
|
3
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
4
|
+
if (m) return m.call(o);
|
|
5
|
+
if (o && typeof o.length === "number") return {
|
|
6
|
+
next: function () {
|
|
7
|
+
if (o && i >= o.length) o = void 0;
|
|
8
|
+
return { value: o && o[i++], done: !o };
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
var SipFactory = Java.type('javax.sip.SipFactory');
|
|
15
|
+
var Properties = Java.type('java.util.Properties');
|
|
16
|
+
/**
|
|
17
|
+
* Takes a properties map and returns an instance of the
|
|
18
|
+
* Java object SipStack
|
|
19
|
+
*/
|
|
20
|
+
function createSipStack(props) {
|
|
21
|
+
var e_1, _a;
|
|
22
|
+
var properties = new Properties();
|
|
23
|
+
try {
|
|
24
|
+
for (var props_1 = __values(props), props_1_1 = props_1.next(); !props_1_1.done; props_1_1 = props_1.next()) {
|
|
25
|
+
var entry = props_1_1.value;
|
|
26
|
+
properties.setProperty(entry[0], entry[1]);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
30
|
+
finally {
|
|
31
|
+
try {
|
|
32
|
+
if (props_1_1 && !props_1_1.done && (_a = props_1.return)) _a.call(props_1);
|
|
33
|
+
}
|
|
34
|
+
finally { if (e_1) throw e_1.error; }
|
|
35
|
+
}
|
|
36
|
+
var sipFactory = SipFactory.getInstance();
|
|
37
|
+
sipFactory.setPathName('gov.nist');
|
|
38
|
+
return sipFactory.createSipStack(properties);
|
|
39
|
+
}
|
|
40
|
+
exports.default = createSipStack;
|
package/dist/edgeport.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var assertions_1 = require("./assertions");
|
|
7
|
+
var create_listening_points_1 = __importDefault(require("./create_listening_points"));
|
|
8
|
+
var create_sip_provider_1 = __importDefault(require("./create_sip_provider"));
|
|
9
|
+
var create_sip_stack_1 = __importDefault(require("./create_sip_stack"));
|
|
10
|
+
var server_properties_1 = __importDefault(require("./server_properties"));
|
|
11
|
+
var GRPCSipListener = Java.type("io.routr.GRPCSipListener");
|
|
12
|
+
function EdgePort(config) {
|
|
13
|
+
assertions_1.assertNoDuplicatedProto(config.spec.transport);
|
|
14
|
+
assertions_1.assertNoDuplicatedPort(config.spec.transport);
|
|
15
|
+
assertions_1.assertHasSecurityContext(config);
|
|
16
|
+
var sipStack = create_sip_stack_1.default(server_properties_1.default(config));
|
|
17
|
+
var sipProvider = create_sip_provider_1.default(sipStack, create_listening_points_1.default(sipStack, config));
|
|
18
|
+
sipProvider.addSipListener(new GRPCSipListener());
|
|
19
|
+
}
|
|
20
|
+
exports.default = EdgePort;
|
package/dist/runner.d.ts
ADDED
package/dist/runner.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
var edgeport_1 = __importDefault(require("./edgeport"));
|
|
8
|
+
var get_config_1 = require("./config/get_config");
|
|
9
|
+
var config = get_config_1.getConfig(System.getenv('CONFIG_DIR'));
|
|
10
|
+
if (config._tag === 'Right') {
|
|
11
|
+
edgeport_1.default(config.right);
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
console.log(config.left);
|
|
15
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { EdgePortConfig } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Returns a Map object with the properties for the server's SipStack.
|
|
4
|
+
* For more options see:
|
|
5
|
+
* https://github.com/RestComm/jain-sip/blob/master/src/gov/nist/javax/sip/SipStackImpl.java
|
|
6
|
+
*/
|
|
7
|
+
export default function getServerProperties(config: EdgePortConfig): Map<string, string>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Returns a Map object with the properties for the server's SipStack.
|
|
5
|
+
* For more options see:
|
|
6
|
+
* https://github.com/RestComm/jain-sip/blob/master/src/gov/nist/javax/sip/SipStackImpl.java
|
|
7
|
+
*/
|
|
8
|
+
function getServerProperties(config) {
|
|
9
|
+
var properties = new Map();
|
|
10
|
+
properties.set('javax.sip.STACK_NAME', 'routr');
|
|
11
|
+
properties.set('javax.sip.AUTOMATIC_DIALOG_SUPPORT', 'OFF');
|
|
12
|
+
properties.set('gov.nist.javax.sip.MESSAGE_PROCESSOR_FACTORY', 'gov.nist.javax.sip.stack.NioMessageProcessorFactory');
|
|
13
|
+
properties.set('gov.nist.javax.sip.PATCH_SIP_WEBSOCKETS_HEADERS', 'false');
|
|
14
|
+
properties.set('gov.nist.javax.sip.CACHE_CLIENT_CONNECTIONS', 'true');
|
|
15
|
+
properties.set('gov.nist.javax.sip.REENTRANT_LISTENER', 'false');
|
|
16
|
+
properties.set('gov.nist.javax.sip.THREAD_POOL_SIZE', '16');
|
|
17
|
+
properties.set('gov.nist.javax.sip.NIO_BLOCKING_MODE', 'NONBLOCKING');
|
|
18
|
+
// Guard against denial of service attack.
|
|
19
|
+
properties.set('gov.nist.javax.sip.MAX_MESSAGE_SIZE', '1048576');
|
|
20
|
+
properties.set('gov.nist.javax.sip.LOG_MESSAGE_CONTENT', 'true');
|
|
21
|
+
// Default host
|
|
22
|
+
properties.set('javax.sip.IP_ADDRESS', config.spec.bindAddr);
|
|
23
|
+
if (config.spec.securityContext) {
|
|
24
|
+
properties.set('gov.nist.javax.sip.TLS_CLIENT_PROTOCOLS', config.spec.securityContext.client.protocols.join());
|
|
25
|
+
// This must be set to 'Disabled' when using WSS
|
|
26
|
+
properties.set('gov.nist.javax.sip.TLS_CLIENT_AUTH_TYPE', config.spec.securityContext.client.authType);
|
|
27
|
+
properties.set('javax.net.ssl.keyStore', config.spec.securityContext.keyStore);
|
|
28
|
+
properties.set('javax.net.ssl.trustStore', config.spec.securityContext.trustStore);
|
|
29
|
+
properties.set('javax.net.ssl.keyStorePassword', config.spec.securityContext.keyStorePassword);
|
|
30
|
+
properties.set('javax.net.ssl.trustStorePassword', config.spec.securityContext.trustStorePassword);
|
|
31
|
+
properties.set('javax.net.ssl.keyStoreType', config.spec.securityContext.keyStoreType);
|
|
32
|
+
}
|
|
33
|
+
return properties;
|
|
34
|
+
}
|
|
35
|
+
exports.default = getServerProperties;
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export interface Transport {
|
|
2
|
+
protocol: string;
|
|
3
|
+
bindAddr?: string;
|
|
4
|
+
port: number;
|
|
5
|
+
}
|
|
6
|
+
export interface EdgePortConfig {
|
|
7
|
+
spec: {
|
|
8
|
+
bindAddr: string;
|
|
9
|
+
transport: Array<Transport>;
|
|
10
|
+
securityContext?: {
|
|
11
|
+
debugging: boolean;
|
|
12
|
+
keyStore: string;
|
|
13
|
+
trustStore: string;
|
|
14
|
+
trustStorePassword: string;
|
|
15
|
+
keyStorePassword: string;
|
|
16
|
+
keyStoreType: string;
|
|
17
|
+
client: {
|
|
18
|
+
authType: string;
|
|
19
|
+
protocols: Array<string>;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export declare interface SipStack {
|
|
25
|
+
createListeningPoint: (bindAddr: string, port: number, proto: string) => unknown;
|
|
26
|
+
createSipProvider: (lp: ListeningPoint) => SipProvider;
|
|
27
|
+
getClass: () => any;
|
|
28
|
+
}
|
|
29
|
+
export declare interface ListeningPoint {
|
|
30
|
+
}
|
|
31
|
+
export declare interface SipProvider {
|
|
32
|
+
addListeningPoint: (lp: ListeningPoint) => void;
|
|
33
|
+
addSipListener: (lp: unknown) => void;
|
|
34
|
+
}
|
|
35
|
+
export declare interface Java {
|
|
36
|
+
}
|
package/dist/types.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@routr/edgeport",
|
|
3
|
+
"version": "2.0.3",
|
|
4
|
+
"description": "SIP endpoint at the edge of the network",
|
|
5
|
+
"author": "Pedro Sanders <psanders@fonoster.com>",
|
|
6
|
+
"homepage": "https://github.com/fonoster/routr#readme",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"main": "dist/edgeport",
|
|
9
|
+
"types": "dist/edgeport",
|
|
10
|
+
"directories": {
|
|
11
|
+
"src": "src",
|
|
12
|
+
"test": "test"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"prebuild": "rimraf ./dist tsconfig.tsbuildinfo",
|
|
19
|
+
"build": "tsc -b tsconfig.json"
|
|
20
|
+
},
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public"
|
|
23
|
+
},
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "git+https://github.com/fonoster/routr.git"
|
|
27
|
+
},
|
|
28
|
+
"bugs": {
|
|
29
|
+
"url": "https://github.com/fonoster/routr/issues"
|
|
30
|
+
},
|
|
31
|
+
"gitHead": "aaacb51da7787d678a89e34a64655fa9a1990364"
|
|
32
|
+
}
|