@routr/one 2.0.14 → 2.0.19

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.
@@ -0,0 +1,12 @@
1
+ import { MessageDispatcherConfig } from "@routr/dispatcher";
2
+ import { LocationConfig } from "@routr/location";
3
+ import { ConnectProcessorConfig } from "@routr/connect";
4
+ import { PostgresDataConfig } from "@routr/pgdata";
5
+ export declare const dispatcherConfig: MessageDispatcherConfig;
6
+ export declare const connectConfig: ConnectProcessorConfig;
7
+ export declare const locationConfig: LocationConfig;
8
+ export declare const rtprelayConfig: {
9
+ host: string;
10
+ port: number;
11
+ };
12
+ export declare const apiServerConfig: PostgresDataConfig;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.apiServerConfig = exports.rtprelayConfig = exports.locationConfig = exports.connectConfig = exports.dispatcherConfig = void 0;
4
+ const location_1 = require("@routr/location");
5
+ const common_1 = require("@routr/common");
6
+ const envs_1 = require("./envs");
7
+ exports.dispatcherConfig = {
8
+ bindAddr: "0.0.0.0:51901",
9
+ processors: [
10
+ {
11
+ ref: "connect-processor",
12
+ addr: "localhost:51904",
13
+ matchFunc: () => true,
14
+ methods: [
15
+ common_1.Method.REGISTER,
16
+ common_1.Method.INVITE,
17
+ common_1.Method.ACK,
18
+ common_1.Method.BYE,
19
+ common_1.Method.CANCEL
20
+ ]
21
+ }
22
+ ],
23
+ middlewares: [
24
+ {
25
+ ref: "rtprelay-middleware",
26
+ addr: "localhost:51903",
27
+ postProcessor: true
28
+ }
29
+ ]
30
+ };
31
+ exports.connectConfig = {
32
+ bindAddr: "0.0.0.0:51904",
33
+ locationAddr: "location:51902",
34
+ apiAddr: "localhost:51907"
35
+ };
36
+ exports.locationConfig = {
37
+ bindAddr: "0.0.0.0:51902",
38
+ cache: { provider: location_1.CacheProvider.MEMORY }
39
+ };
40
+ exports.rtprelayConfig = {
41
+ host: envs_1.RTPENGINE_HOST,
42
+ port: envs_1.RTPENGINE_PORT
43
+ };
44
+ exports.apiServerConfig = {
45
+ bindAddr: "0.0.0.0:51907"
46
+ };
package/dist/envs.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ export declare const BIND_ADDR: string;
2
+ export declare const PROCESSOR_ADDR: string;
3
+ export declare const EDGEPORT_RUNNER: string;
4
+ export declare const RTPENGINE_HOST: string;
5
+ export declare const RTPENGINE_PORT: number;
6
+ export declare const DOCKER: string | boolean;
package/dist/envs.js ADDED
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var _a, _b, _c, _d;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.DOCKER = exports.RTPENGINE_PORT = exports.RTPENGINE_HOST = exports.EDGEPORT_RUNNER = exports.PROCESSOR_ADDR = exports.BIND_ADDR = void 0;
5
+ /*
6
+ * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com)
7
+ * http://github.com/fonoster
8
+ *
9
+ * This file is part of Routr.
10
+ *
11
+ * Licensed under the MIT License (the "License");
12
+ * you may not use this file except in compliance with
13
+ * the License. You may obtain a copy of the License at
14
+ *
15
+ * https://opensource.org/licenses/MIT
16
+ *
17
+ * Unless required by applicable law or agreed to in writing, software
18
+ * distributed under the License is distributed on an "AS IS" BASIS,
19
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
+ * See the License for the specific language governing permissions and
21
+ * limitations under the License.
22
+ */
23
+ const common_1 = require("@routr/common");
24
+ common_1.Assertions.assertEnvsAreSet(["RTPENGINE_HOST", "DATABASE_URL"]);
25
+ exports.BIND_ADDR = (_a = process.env.BIND_ADDR) !== null && _a !== void 0 ? _a : "0.0.0.0:51904";
26
+ exports.PROCESSOR_ADDR = (_b = process.env.PROCESSOR_ADDR) !== null && _b !== void 0 ? _b : "localhost:51901";
27
+ exports.EDGEPORT_RUNNER = (_c = process.env.EDGEPORT_RUNNER) !== null && _c !== void 0 ? _c : "/opt/routr/edgeport.sh";
28
+ exports.RTPENGINE_HOST = process.env.RTPENGINE_HOST;
29
+ exports.RTPENGINE_PORT = process.env.RTPENGINE_PORT
30
+ ? parseInt(process.env.RTPENGINE_PORT)
31
+ : 2223;
32
+ exports.DOCKER = (_d = process.env.DOCKER) !== null && _d !== void 0 ? _d : false;
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/runner.js ADDED
@@ -0,0 +1,63 @@
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
+ /*
8
+ * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com)
9
+ * http://github.com/fonoster
10
+ *
11
+ * This file is part of Routr.
12
+ *
13
+ * Licensed under the MIT License (the "License");
14
+ * you may not use this file except in compliance with
15
+ * the License. You may obtain a copy of the License at
16
+ *
17
+ * https://opensource.org/licenses/MIT
18
+ *
19
+ * Unless required by applicable law or agreed to in writing, software
20
+ * distributed under the License is distributed on an "AS IS" BASIS,
21
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22
+ * See the License for the specific language governing permissions and
23
+ * limitations under the License.
24
+ */
25
+ const logger_1 = require("@fonoster/logger");
26
+ const child_process_1 = require("child_process");
27
+ const connect_1 = require("@routr/connect");
28
+ const dispatcher_1 = require("@routr/dispatcher");
29
+ const location_1 = require("@routr/location");
30
+ const pgdata_1 = require("@routr/pgdata");
31
+ const rtprelay_1 = require("@routr/rtprelay");
32
+ const envs_1 = require("./envs");
33
+ const configs_1 = require("./configs");
34
+ const fs_1 = __importDefault(require("fs"));
35
+ const logger = (0, logger_1.getLogger)({ service: "one", filePath: __filename });
36
+ logger.info("routr v2 // one distribution");
37
+ const PATH_TO_CERTS = "/etc/routr/domains-cert.jks";
38
+ if (envs_1.DOCKER && !fs_1.default.existsSync(PATH_TO_CERTS)) {
39
+ logger.info("creating a set of self-signed certs for edgeport", {
40
+ path: PATH_TO_CERTS
41
+ });
42
+ (0, child_process_1.execSync)("sh /service/generate-certs.sh /dev/null 2>&1");
43
+ (0, child_process_1.execSync)("mv domains-cert.jks /etc/routr/");
44
+ }
45
+ (0, dispatcher_1.messageDispatcher)(configs_1.dispatcherConfig);
46
+ (0, connect_1.connectProcessor)(configs_1.connectConfig);
47
+ (0, location_1.locationService)(configs_1.locationConfig);
48
+ (0, pgdata_1.pgDataService)(configs_1.apiServerConfig);
49
+ (0, rtprelay_1.rtprelay)("0.0.0.0:51903", configs_1.rtprelayConfig);
50
+ const edgeportProcess = (0, child_process_1.spawn)(envs_1.EDGEPORT_RUNNER);
51
+ edgeportProcess.stdout.on("data", (data) => {
52
+ process.stdout.write(`${data}`);
53
+ });
54
+ edgeportProcess.on("error", (err) => {
55
+ logger.error(`failed to spawn edgeport process: ${err}`);
56
+ process.exit(1);
57
+ });
58
+ edgeportProcess.on("exit", (code) => {
59
+ if (code !== 0) {
60
+ logger.error(`edgeport process exited with code ${code}`);
61
+ process.exit(code);
62
+ }
63
+ });
@@ -0,0 +1,7 @@
1
+ /**
2
+ * This function registers the instrumentations for the service.
3
+ *
4
+ * @param {string} serviceName - The name of the service.
5
+ * @return {Tracer} The tracer object.
6
+ */
7
+ export declare function init(serviceName: string): import("@opentelemetry/api").Tracer;
package/dist/tracer.js ADDED
@@ -0,0 +1,53 @@
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
+ exports.init = void 0;
7
+ /*
8
+ * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com)
9
+ * http://github.com/fonoster/routr
10
+ *
11
+ * This file is part of Routr
12
+ *
13
+ * Licensed under the MIT License (the "License")
14
+ * you may not use this file except in compliance with
15
+ * the License. You may obtain a copy of the License at
16
+ *
17
+ * https://opensource.org/licenses/MIT
18
+ *
19
+ * Unless required by applicable law or agreed to in writing, software
20
+ * distributed under the License is distributed on an "AS IS" BASIS,
21
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22
+ * See the License for the specific language governing permissions and
23
+ * limitations under the License.
24
+ */
25
+ const api_1 = __importDefault(require("@opentelemetry/api"));
26
+ const instrumentation_1 = require("@opentelemetry/instrumentation");
27
+ const sdk_trace_node_1 = require("@opentelemetry/sdk-trace-node");
28
+ const resources_1 = require("@opentelemetry/resources");
29
+ const semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
30
+ const sdk_trace_base_1 = require("@opentelemetry/sdk-trace-base");
31
+ const exporter_jaeger_1 = require("@opentelemetry/exporter-jaeger");
32
+ const instrumentation_grpc_1 = require("@opentelemetry/instrumentation-grpc");
33
+ /**
34
+ * This function registers the instrumentations for the service.
35
+ *
36
+ * @param {string} serviceName - The name of the service.
37
+ * @return {Tracer} The tracer object.
38
+ */
39
+ function init(serviceName) {
40
+ const provider = new sdk_trace_node_1.NodeTracerProvider({
41
+ resource: new resources_1.Resource({
42
+ [semantic_conventions_1.SemanticResourceAttributes.SERVICE_NAME]: serviceName
43
+ })
44
+ });
45
+ const exporter = new exporter_jaeger_1.JaegerExporter();
46
+ provider.addSpanProcessor(new sdk_trace_base_1.SimpleSpanProcessor(exporter));
47
+ provider.register();
48
+ (0, instrumentation_1.registerInstrumentations)({
49
+ instrumentations: [new instrumentation_grpc_1.GrpcInstrumentation()]
50
+ });
51
+ return api_1.default.trace.getTracer("routr-tracer");
52
+ }
53
+ exports.init = init;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@routr/one",
3
- "version": "2.0.14",
3
+ "version": "2.0.19",
4
4
  "description": "Bundle server with everything needed to run Routr Connect",
5
5
  "author": "Pedro Sanders <psanders@fonoster.com>",
6
6
  "homepage": "https://github.com/fonoster/routr#readme",
@@ -20,12 +20,12 @@
20
20
  },
21
21
  "dependencies": {
22
22
  "@fonoster/logger": "0.3.20",
23
- "@routr/common": "^2.0.13",
24
- "@routr/connect": "^2.0.13",
25
- "@routr/dispatcher": "^2.0.13",
26
- "@routr/location": "^2.0.13",
27
- "@routr/pgdata": "^2.0.14",
28
- "@routr/rtprelay": "^2.0.13"
23
+ "@routr/common": "^2.0.18",
24
+ "@routr/connect": "^2.0.19",
25
+ "@routr/dispatcher": "^2.0.18",
26
+ "@routr/location": "^2.0.19",
27
+ "@routr/pgdata": "^2.0.18",
28
+ "@routr/rtprelay": "^2.0.18"
29
29
  },
30
30
  "files": [
31
31
  "dist"
@@ -40,5 +40,5 @@
40
40
  "bugs": {
41
41
  "url": "https://github.com/fonoster/routr/issues"
42
42
  },
43
- "gitHead": "1f0ce6c15efb17b42913e5f4c5488db8cc65d75a"
43
+ "gitHead": "bb370f83f49af10fca845a8f4b7feae5e6d21ae7"
44
44
  }