diff --git a/.scripts/custom-jre.sh b/.scripts/custom-jre.sh index e9fbda214..9fcb6a49e 100644 --- a/.scripts/custom-jre.sh +++ b/.scripts/custom-jre.sh @@ -19,5 +19,5 @@ echo "" $JAVA_HOME/bin/jlink -c --no-man-pages --no-header-files -G \ --module-path $TARGET_HOME/jmods/ \ --add-modules \ - java.base,java.management,java.naming,java.sql,java.instrument,jdk.crypto.cryptoki,jdk.scripting.nashorn,jdk.unsupported,jdk.management.agent,jdk.unsupported.desktop,jdk.crypto.ec,java.security.jgss,jdk.jartool \ + java.base,java.management,java.naming,java.sql,java.instrument,jdk.crypto.cryptoki,jdk.unsupported,jdk.management.agent,jdk.unsupported.desktop,jdk.crypto.ec,java.security.jgss,jdk.jartool,java.scripting \ --output jre diff --git a/.scripts/tag-changelog-config.js b/.scripts/tag-changelog-config.js index 0c933cde2..c0ba4c08b 100644 --- a/.scripts/tag-changelog-config.js +++ b/.scripts/tag-changelog-config.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster * * This file is part of Routr. diff --git a/CONNECT.md b/CONNECT.md index a41fffd20..a242155ea 100644 --- a/CONNECT.md +++ b/CONNECT.md @@ -122,7 +122,7 @@ Furthermore, an Agent can utilize the custom header X-Connect-Token to transmit { "ref": "agent-01", "aor": "sip:1001@sip.local", - "aorLink": "backend:voice", + "aorLink": "sip:voice@sip.local", "domain": "sip.local", "domainRef": "domain-01", "allowedMethods": [ "INVITE", "REGISTER"], @@ -245,7 +245,7 @@ Numbers represent virtual numbers that route calls from/to the PSTN via a Trunk. "trunkRef": "trunk-01", "location": { "telUrl": "tel:+17066041487", - "aorLink": "backend:conference", + "aorLink": "sip:conference@sip.local", "sessionAffinityHeader": "X-Room-Id", "extraHeaders": [{ "name": "X-Room-Id", @@ -268,7 +268,7 @@ Like Agents, Peers represent SIP endpoints such as Media Servers. Unlike Agents, }, "spec": { "username": "asterisk", - "aor": "backend:conference", + "aor": "sip:conference@sip.local", "contactAddr": "192.168.1.2:6060", "credentialsRef": "credentials-01", "loadBalancing": { diff --git a/CORE.md b/CORE.md index c43c64c01..587bf8963 100644 --- a/CORE.md +++ b/CORE.md @@ -1,6 +1,6 @@ # Routr Specification -### Version 0.1.4 (Draft) +### Version 0.1.5 (Draft)
Table of Contents @@ -700,7 +700,7 @@ The following functions are MUST have for an implementation of a *Location Servi - *Accept gRPC Requests* - Accept gRPC Requests - *Find Routes* - Find all the routes to an endpoint - *Filtering Labels* - MUST be able to store endpoints using labels (for filtering) -- *Backend or Endpoint* - MUST allow AOR the "sip:" and "backend:" schemes +- *Backend or Endpoint* - MUST allow AOR the "sip:" and "backend:" schemes ("backend:" is deprecated since v0.1.5) - *Balancing Algorithm* - Implements `round-robin` and `least-sessions` - *Session Affinity* - Implements session base affinity - *Cache* - Caching must be done via "providers" that are easily replaceable (e.g.: `Memory`, `Redis`, etc.) @@ -708,6 +708,8 @@ The following functions are MUST have for an implementation of a *Location Servi - *M.E.L.T* - Must be capable of collecting and sending M.E.L.T to external systems - *Service Port* - The default gRPC port at the Location Service SHOULD be `51902` +> Since SPEC v0.1.5 using "backend:" scheme is deprecated. The Location Service will continue to support it for backward compatibility. + **Non-functional Requirements** The following requirements are essential to have for an implementation of a *Location Service*: diff --git a/Dockerfile b/Dockerfile index eccca36bd..f188909c5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,17 @@ ## ## Build and pack the service ## -FROM alpine:3.18 as builder +FROM alpine:3.19 as builder LABEL maintainer="Pedro Sanders " -ENV JAVA_HOME=/usr/lib/jvm/java-11-openjdk +ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk WORKDIR /work COPY mods/one . COPY mods/pgdata/schema.prisma . COPY .scripts/custom-jre.sh . -RUN apk add --no-cache --update npm nodejs curl git tini python3 make cmake g++ openjdk11-jdk \ +RUN apk add --no-cache --update npm nodejs curl git tini python3 make cmake g++ openjdk17-jdk \ && sh custom-jre.sh \ && npm install --omit=dev \ && mv schema.prisma node_modules/@routr/pgdata/ \ @@ -23,7 +23,7 @@ RUN apk add --no-cache --update npm nodejs curl git tini python3 make cmake g++ ## ## Runner ## -FROM alpine:3.18 as runner +FROM alpine:3.19 as runner ARG PKCS_PASSWORD=changeme ARG POSTGRES_USER=postgres @@ -42,8 +42,7 @@ ENV PKCS_PASSWORD=$PKCS_PASSWORD \ CA_CERT_SUBJECT=$CA_CERT_SUBJECT \ SERVER_CERT_SUBJECT=$SERVER_CERT_SUBJECT \ DATABASE_URL=postgres://$POSTGRES_USER:$POSTGRES_PASSWORD@localhost:5432/routr \ - IGNORE_LOOPBACK_FROM_LOCALNETS=true \ - LOG4J2=/etc/routr/log4j2.yaml + IGNORE_LOOPBACK_FROM_LOCALNETS=true WORKDIR /service diff --git a/config/resources/numbers.yaml b/config/resources/numbers.yaml index 9fc0e331c..72b8fd0d5 100644 --- a/config/resources/numbers.yaml +++ b/config/resources/numbers.yaml @@ -11,7 +11,7 @@ trunkRef: trunk-01 location: telUrl: tel:+17066041487 - aorLink: backend:conference + aorLink: sip:conference@sip.local sessionAffinityHeader: X-Room-Id extraHeaders: - name: X-Room-Id @@ -60,7 +60,7 @@ trunkRef: trunk-03 location: telUrl: tel:+18095863314 - aorLink: backend:voice + aorLink: sip:voice@sip.local - apiVersion: v2beta1 kind: Number @@ -75,4 +75,4 @@ trunkRef: trunk-01 location: telUrl: tel:+14045551212 - aorLink: backend:voice + aorLink: sip:voice@sip.local diff --git a/config/resources/peers.yaml b/config/resources/peers.yaml index 5a7c427b1..8827756dc 100644 --- a/config/resources/peers.yaml +++ b/config/resources/peers.yaml @@ -4,19 +4,20 @@ metadata: name: Asterisk (Media Server) spec: - aor: backend:conference + aor: sip:conference@sip.local username: asterisk credentialsRef: credentials-03 loadBalancing: withSessionAffinity: true algorithm: least-sessions + - apiVersion: v2beta1 kind: Peer ref: peer-02 metadata: name: FS Voice Feature Server spec: - aor: backend:voice + aor: sip:voice@sip.local username: freeswitch credentialsRef: credentials-05 loadBalancing: diff --git a/docs/docs/connect/command-line/ctl.md b/docs/docs/connect/command-line/ctl.md index 024ef7869..98d777cd3 100644 --- a/docs/docs/connect/command-line/ctl.md +++ b/docs/docs/connect/command-line/ctl.md @@ -757,8 +757,8 @@ DESCRIPTION EXAMPLES $ rctl peers get - Ref Name Username AOR Balancing Algorithm Session Affinity - 6f941c63-880c-419a-a72a-4a107cbaf5c5 Asterisk Conference conference backend:conference ROUND_ROBIN Yes + Ref Name Username AOR Balancing Algorithm Session Affinity + 6f941c63-880c-419a-a72a-4a107cbaf5c5 Asterisk Conference conference sip:conference@sip.local ROUND_ROBIN Yes ``` _See code: [dist/commands/peers/get.ts](https://github.com/fonoster/routr/blob/v2.1.11/dist/commands/peers/get.ts)_ diff --git a/docs/docs/connect/nodesdk/sdk.md b/docs/docs/connect/nodesdk/sdk.md index 1f8c79620..6cdd6c310 100644 --- a/docs/docs/connect/nodesdk/sdk.md +++ b/docs/docs/connect/nodesdk/sdk.md @@ -958,7 +958,7 @@ const peers = new SDK.Peers() const request = { name: "Asterisk Conference Server", username: "conference", - aor: "backend:conference", + aor: "sip:conference@sip.local", contactAddr: "10.0.0.1:5060", accessControlListRef: "4671371b-ff5d-48b1-aabe-d3c5ca5317a3", credentialsRef: "4671371b-ff5d-48b1-aabe-d3c5ca5317a3", @@ -1004,7 +1004,7 @@ Creates a new Peer on Routr. const request = { name: "Asterisk Conference Server", username: "conference", - aor: "backend:conference", + aor: "sip:conference@sip.local", contactAddr: "10.0.0.1:5060", accessControlListRef: "4671371b-ff5d-48b1-aabe-d3c5ca5317a3", credentialsRef: "4671371b-ff5d-48b1-aabe-d3c5ca5317a3", diff --git a/docs/docs/development/components/apiserver.md b/docs/docs/development/components/apiserver.md index c61df6777..00fffe538 100644 --- a/docs/docs/development/components/apiserver.md +++ b/docs/docs/development/components/apiserver.md @@ -157,7 +157,7 @@ Filename: `numbers.yaml` trunkRef: trunk-01 location: telUrl: tel:+17066041487 - aorLink: backend:conference + aorLink: sip:conference@sip.local sessionAffinityHeader: X-Room-Id extraHeaders: - name: X-Room-Id @@ -251,7 +251,7 @@ Filename: `peers.yaml` metadata: name: Asterisk (Media Server) spec: - aor: backend:conference + aor: sip:conference@sip.local username: asterisk credentialsRef: credentials-03 loadBalancing: diff --git a/docs/docs/development/components/location.md b/docs/docs/development/components/location.md index d0004d4eb..8af55487f 100644 --- a/docs/docs/development/components/location.md +++ b/docs/docs/development/components/location.md @@ -19,7 +19,7 @@ ref: peer-01 metadata: name: Asterisk (Media Server) spec: - aor: backend:conference + aor: sip:conference@sip.local username: asterisk credentialsRef: credentials-01 loadBalancing: @@ -29,7 +29,7 @@ spec: Notice that the load balancing section sets the `withSessionAffinity` to `true`. We need session affinity to ensure that all calls related to the conference arrive on the same Asterisk server. -Every Asterisk server that registers using the `asterisk` username will join the same group under the `backend:conference` Address of Record (AOR). +Every Asterisk server that registers using the `asterisk` username will join the same group under the `sip:conference@sip.local` Address of Record (AOR). ## Configuration Spec diff --git a/docs/docs/overview/concepts.md b/docs/docs/overview/concepts.md index 2a2e1b167..72ff4fcb4 100644 --- a/docs/docs/overview/concepts.md +++ b/docs/docs/overview/concepts.md @@ -125,7 +125,7 @@ ref: peer-01 metadata: name: Asterisk (Media Server) spec: - aor: backend:conference + aor: sip:conference@sip.local username: asterisk credentialsRef: credentials-01 loadBalancing: @@ -135,7 +135,7 @@ spec: Notice that the load balancing section sets the `withSessionAffinity` to `true`. We need session affinity to ensure that all calls related to the conference arrive on the same Asterisk server. -Every Asterisk server that registers using the `asterisk` username will join the same group under the `backend:conference` Address of Record (AOR). +Every Asterisk server that registers using the `asterisk` username will join the same group under the `sip:conference@sip.local` Address of Record (AOR). ## Middlewares diff --git a/docs/docusaurus.config.js b/docs/docusaurus.config.js index e951d847c..e54c88e20 100644 --- a/docs/docusaurus.config.js +++ b/docs/docusaurus.config.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/common/src/assertions.ts b/mods/common/src/assertions.ts index a57edb175..a0aef54d8 100644 --- a/mods/common/src/assertions.ts +++ b/mods/common/src/assertions.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/common/src/auth.ts b/mods/common/src/auth.ts index 6dd4ddaab..1bb4da3b4 100644 --- a/mods/common/src/auth.ts +++ b/mods/common/src/auth.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr @@ -16,16 +16,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { AuthChallengeResponse, ResponseType } from "./types" +import { AuthChallengeResponse } from "./types" import crypto from "crypto" -const DEFAULT_ALGORITHM = "MD5" +export const DEFAULT_ALGORITHM = "MD5" const md5hex = (str: string, algorithm = DEFAULT_ALGORITHM) => crypto.createHash(algorithm).update(str).digest("hex") -const decToHex = (dec: number) => - (dec + Math.pow(16, 8)).toString(16).substr(-8) +const decToHex = (dec: number) => (dec + Math.pow(16, 8)).toString(16).slice(-8) export const generateNonce = (algorithm: string = DEFAULT_ALGORITHM) => md5hex(`${new Date().getTime()}${Math.random()}`, algorithm) @@ -54,61 +53,3 @@ export const getCredentials = ( username: string, users: { username: string; secret: string }[] ) => users.find((user) => user.username === username) - -export const createUnauthorizedResponse = ( - realm: string, - params: { - qop: string - algorithm: string - } = { qop: "auth", algorithm: DEFAULT_ALGORITHM } -) => { - return { - message: { - responseType: ResponseType.UNAUTHORIZED, - reasonPhrase: "Unauthorized", - wwwAuthenticate: { - scheme: "Digest", - realm: realm, - qop: params.qop, - opaque: "", - stale: false, - nonce: generateNonce(), - algorithm: params.algorithm - } - } - } -} - -export const createUnauthorizedResponseWithoutChallenge = ( - metadata?: Record -) => { - return { - metadata, - message: { - responseType: ResponseType.UNAUTHORIZED, - reasonPhrase: "Unauthorized" - } - } -} - -export const createServerInternalErrorResponse = ( - metadata?: Record -) => { - return { - metadata, - message: { - responseType: ResponseType.SERVER_INTERNAL_ERROR, - reasonPhrase: "Server Internal Error" - } - } -} - -export const createForbideenResponse = (metadata?: Record) => { - return { - metadata, - message: { - responseType: ResponseType.FORBIDDEN, - reasonPhrase: "Forbidden" - } - } -} diff --git a/mods/common/src/connect/api/client.ts b/mods/common/src/connect/api/client.ts index e401f3d5c..26ec5c55a 100644 --- a/mods/common/src/connect/api/client.ts +++ b/mods/common/src/connect/api/client.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/common/src/connect/api/index.ts b/mods/common/src/connect/api/index.ts index d4450ddd1..80bc0f7a4 100644 --- a/mods/common/src/connect/api/index.ts +++ b/mods/common/src/connect/api/index.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/common/src/connect/api/types.ts b/mods/common/src/connect/api/types.ts index 94b96f1e6..4f28a5036 100644 --- a/mods/common/src/connect/api/types.ts +++ b/mods/common/src/connect/api/types.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/common/src/connect/assertions.ts b/mods/common/src/connect/assertions.ts index 0e98af931..86edc4267 100644 --- a/mods/common/src/connect/assertions.ts +++ b/mods/common/src/connect/assertions.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. @@ -17,7 +17,6 @@ * limitations under the License. */ import { BadRequestError } from "../errors" -import { LoadBalancingAlgorithm } from "../types" import { TrunkURI } from "./types" import { hasACLRules, @@ -38,7 +37,6 @@ import { hasValidHeaders, isValidAOR, isValidAORLink, - isValidBalancingAlgorithm, isValidContactAddress, isValidDomainUri, isValidE164, @@ -74,16 +72,6 @@ export const hasValidHeadersOrThrow = ( } } -export const isValidBalancingAlgorithmOrThrow = ( - aor: string, - algorithm: LoadBalancingAlgorithm -) => { - const E = isValidBalancingAlgorithm(aor, algorithm) - if (E instanceof BadRequestError) { - throw E - } -} - export const hasACLRulesOrThrow = (acl: { deny: string[]; allow: string[] }) => validOrThrow(hasACLRules, acl) diff --git a/mods/common/src/connect/client.ts b/mods/common/src/connect/client.ts index 7d14b30bb..4c6cb419d 100644 --- a/mods/common/src/connect/client.ts +++ b/mods/common/src/connect/client.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr @@ -18,9 +18,9 @@ */ /* eslint-disable require-jsdoc */ import * as grpc from "@grpc/grpc-js" -import protoLoader = require("@grpc/proto-loader") -import { toPascaleCase } from "../helper" +import { toPascalCase } from "../helper" import { Kind, KindWithoutUnknown } from "./types" +import protoLoader = require("@grpc/proto-loader") const protoOptions = { keepCase: false, @@ -63,7 +63,7 @@ export function createConnectClient(options: { ) default: return new base[options.kind + "s"].v2beta1[ - toPascaleCase(options.kind) + "s" + toPascalCase(options.kind) + "s" ](options.apiAddr, options.credentials) } } @@ -79,6 +79,6 @@ export function createConnectService(kind: KindWithoutUnknown) { case Kind.CREDENTIALS: return base.credentials.v2beta1.CredentialsService.service default: - return base[kind + "s"].v2beta1[toPascaleCase(kind) + "s"].service + return base[kind + "s"].v2beta1[toPascalCase(kind) + "s"].service } } diff --git a/mods/common/src/connect/config.ts b/mods/common/src/connect/config.ts index 6b1f53def..beb65ebf0 100644 --- a/mods/common/src/connect/config.ts +++ b/mods/common/src/connect/config.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. @@ -42,6 +42,8 @@ export interface AgentConfig extends ConfigBase { domainRef: string credentialsRef: string privacy: Privacy + maxContacts?: number + expires?: number enabled: boolean } } @@ -54,6 +56,8 @@ export interface PeerConfig extends ConfigBase { credentialsRef?: string contactAddr?: string enabled?: boolean + maxContacts?: number + expires?: number loadBalancing?: { algorithm: LoadBalancingAlgorithm withSessionAffinity: boolean diff --git a/mods/common/src/connect/connect_error.ts b/mods/common/src/connect/connect_error.ts index 85ce03c5d..eb9020fbf 100644 --- a/mods/common/src/connect/connect_error.ts +++ b/mods/common/src/connect/connect_error.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/common/src/connect/index.ts b/mods/common/src/connect/index.ts index a804999f5..c65625d8e 100644 --- a/mods/common/src/connect/index.ts +++ b/mods/common/src/connect/index.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/common/src/connect/mappers/acl.ts b/mods/common/src/connect/mappers/acl.ts index bf335f10a..b324684e1 100644 --- a/mods/common/src/connect/mappers/acl.ts +++ b/mods/common/src/connect/mappers/acl.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/common/src/connect/mappers/agent.ts b/mods/common/src/connect/mappers/agent.ts index e3d345a3f..7f0708508 100644 --- a/mods/common/src/connect/mappers/agent.ts +++ b/mods/common/src/connect/mappers/agent.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. @@ -36,6 +36,8 @@ export function mapToAgent(config: AgentConfig): Agent { privacy: config.spec.privacy ?? Privacy.NONE, enabled: config.spec.enabled as boolean, domainRef: config.spec.domainRef, - credentialsRef: config.spec.credentialsRef + credentialsRef: config.spec.credentialsRef, + maxContacts: config.spec.maxContacts, + expires: config.spec.expires } } diff --git a/mods/common/src/connect/mappers/assertions.ts b/mods/common/src/connect/mappers/assertions.ts index 4277e6619..78552359b 100644 --- a/mods/common/src/connect/mappers/assertions.ts +++ b/mods/common/src/connect/mappers/assertions.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. @@ -17,7 +17,7 @@ * limitations under the License. */ import { getLogger } from "@fonoster/logger" -import { PeerConfig, UserConfig } from "../config" +import { UserConfig } from "../config" const logger = getLogger({ service: "common", filePath: __filename }) export const assertValidSchema = ( @@ -36,20 +36,3 @@ export const assertValidSchema = ( process.exit(1) } } - -export const assertValidAorSchema = (config: UserConfig) => { - const spec = (config as PeerConfig).spec - if (spec.aor.startsWith("backend:") && !spec.loadBalancing) { - logger.error( - "found a bad resource: balancing algorithm is required for `backend:` aors" - ) - process.exit(1) - } - - if (spec.aor.startsWith("sip:") && spec.loadBalancing) { - logger.error( - "found a bad resource: balancing algorithm is not allowed for `sip:` aors" - ) - process.exit(1) - } -} diff --git a/mods/common/src/connect/mappers/credentials.ts b/mods/common/src/connect/mappers/credentials.ts index bf4d3b25d..36a1ff097 100644 --- a/mods/common/src/connect/mappers/credentials.ts +++ b/mods/common/src/connect/mappers/credentials.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/common/src/connect/mappers/domain.ts b/mods/common/src/connect/mappers/domain.ts index 2ebfa06d9..dfaf4958b 100644 --- a/mods/common/src/connect/mappers/domain.ts +++ b/mods/common/src/connect/mappers/domain.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/common/src/connect/mappers/index.ts b/mods/common/src/connect/mappers/index.ts index a06dbc0be..d34bc764d 100644 --- a/mods/common/src/connect/mappers/index.ts +++ b/mods/common/src/connect/mappers/index.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/common/src/connect/mappers/number.ts b/mods/common/src/connect/mappers/number.ts index fcfe87fea..9322f149b 100644 --- a/mods/common/src/connect/mappers/number.ts +++ b/mods/common/src/connect/mappers/number.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/common/src/connect/mappers/peer.ts b/mods/common/src/connect/mappers/peer.ts index 510d38dd5..428efa5ef 100644 --- a/mods/common/src/connect/mappers/peer.ts +++ b/mods/common/src/connect/mappers/peer.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. @@ -21,13 +21,12 @@ import { LoadBalancingAlgorithm } from "../../types" import { PeerConfig } from "../config" import { schemaValidators } from "../schemas" import { Peer, Kind } from "../types" -import { assertValidAorSchema, assertValidSchema } from "./assertions" +import { assertValidSchema } from "./assertions" const valid = schemaValidators.get(Kind.PEER) export function mapToPeer(config: PeerConfig): Peer { assertValidSchema(config, valid) - assertValidAorSchema(config) const normalizeAlgorithm = (algorithm: string) => algorithm?.replace(/-/g, "_").toUpperCase() as LoadBalancingAlgorithm @@ -43,6 +42,8 @@ export function mapToPeer(config: PeerConfig): Peer { balancingAlgorithm: normalizeAlgorithm( config.spec.loadBalancing?.algorithm ), - withSessionAffinity: config.spec.loadBalancing?.withSessionAffinity + withSessionAffinity: config.spec.loadBalancing?.withSessionAffinity, + maxContacts: config.spec.maxContacts, + expires: config.spec.expires } } diff --git a/mods/common/src/connect/mappers/trunk.ts b/mods/common/src/connect/mappers/trunk.ts index 964608205..6299f9282 100644 --- a/mods/common/src/connect/mappers/trunk.ts +++ b/mods/common/src/connect/mappers/trunk.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/common/src/connect/protos/acl.proto b/mods/common/src/connect/protos/acl.proto index 0129be15e..470986fa0 100644 --- a/mods/common/src/connect/protos/acl.proto +++ b/mods/common/src/connect/protos/acl.proto @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/common/src/connect/protos/agents.proto b/mods/common/src/connect/protos/agents.proto index 88fd75b25..a0bc495a7 100644 --- a/mods/common/src/connect/protos/agents.proto +++ b/mods/common/src/connect/protos/agents.proto @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr @@ -64,6 +64,10 @@ message Agent { int32 created_at = 7; // The updated_at timestamp of the Agent int32 updated_at = 8; + // The maximum number of contacts that can be created for this Agent + int32 max_contacts = 12; + // Value to override the expires requested by the Agent + int32 expires = 13; // The domain of the Agent fonoster.routr.connect.domains.v2beta1.Domain domain = 9; // The credentials of the Agent @@ -86,8 +90,12 @@ message CreateAgentRequest { string domain_ref = 5; // Reference to the Credentials of the Agent string credentials_ref = 6; + // The maximum number of contacts that can be created for this Agent + int32 max_contacts = 8; + // Value to override the expires requested by the Agent + int32 expires = 9; // The extended attributes of the Agent - .google.protobuf.Struct extended = 7; + .google.protobuf.Struct extended = 7; } // The request message for the Agents.Update method @@ -104,6 +112,10 @@ message UpdateAgentRequest { string domain_ref = 5; // Reference to the Credentials of the Agent string credentials_ref = 6; + // The maximum number of contacts that can be created for this Agent + int32 max_contacts = 8; + // Value to override the expires requested by the Agent + int32 expires = 9; // The extended attributes of the Agent .google.protobuf.Struct extended = 7; } diff --git a/mods/common/src/connect/protos/credentials.proto b/mods/common/src/connect/protos/credentials.proto index 9df6f7db7..a9cf62c39 100644 --- a/mods/common/src/connect/protos/credentials.proto +++ b/mods/common/src/connect/protos/credentials.proto @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/common/src/connect/protos/domains.proto b/mods/common/src/connect/protos/domains.proto index e380d4311..5799e2c8f 100644 --- a/mods/common/src/connect/protos/domains.proto +++ b/mods/common/src/connect/protos/domains.proto @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/common/src/connect/protos/numbers.proto b/mods/common/src/connect/protos/numbers.proto index 5f0c1c4ea..87f526357 100644 --- a/mods/common/src/connect/protos/numbers.proto +++ b/mods/common/src/connect/protos/numbers.proto @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/common/src/connect/protos/peers.proto b/mods/common/src/connect/protos/peers.proto index 030041c4f..a5ca9fea1 100644 --- a/mods/common/src/connect/protos/peers.proto +++ b/mods/common/src/connect/protos/peers.proto @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr @@ -79,6 +79,10 @@ message Peer { fonoster.routr.connect.acl.v2beta1.AccessControlList access_control_list = 12; // The credentials of the Peer fonoster.routr.connect.credentials.v2beta1.Credentials credentials = 13; + // The maximum number of contacts that can be created for this Peer + int32 max_contacts = 15; + // Value to override the expires requested by the Peer + int32 expires = 16; // The extended attributes of the Peer .google.protobuf.Struct extended = 14; } @@ -103,6 +107,10 @@ message CreatePeerRequest { string credentials_ref = 8; // The status of the Peer bool enabled = 9; + // The maximum number of contacts that can be created for this Peer + int32 max_contacts = 11; + // Value to override the expires requested by the Peer + int32 expires = 12; // The extended attributes of the Peer .google.protobuf.Struct extended = 10; } @@ -127,6 +135,10 @@ message UpdatePeerRequest { string credentials_ref = 8; // The status of the Peer bool enabled = 9; + // The maximum number of contacts that can be created for this Peer + int32 max_contacts = 11; + // Value to override the expires requested by the Peer + int32 expires = 12; // The extended attributes of the Peer .google.protobuf.Struct extended = 10; } diff --git a/mods/common/src/connect/protos/trunks.proto b/mods/common/src/connect/protos/trunks.proto index cc6ddd96a..a360d57c1 100644 --- a/mods/common/src/connect/protos/trunks.proto +++ b/mods/common/src/connect/protos/trunks.proto @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/common/src/connect/schemas/acl.ts b/mods/common/src/connect/schemas/acl.ts index 9f087222e..6e744d0cb 100644 --- a/mods/common/src/connect/schemas/acl.ts +++ b/mods/common/src/connect/schemas/acl.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/common/src/connect/schemas/agent.ts b/mods/common/src/connect/schemas/agent.ts index e2c9bd0e1..139990344 100644 --- a/mods/common/src/connect/schemas/agent.ts +++ b/mods/common/src/connect/schemas/agent.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. @@ -63,6 +63,16 @@ export default { description: "The credential the Agent uses to authenticate", type: "string" }, + maxContacts: { + description: + "The maximum number of contacts acceptable for this Agent", + type: "integer" + }, + expires: { + description: + "Time, in seconds, to override the expires requested by the Agent", + type: "integer" + }, enabled: { description: "Whether the Agent is enabled (reserved for future use)", type: "boolean" diff --git a/mods/common/src/connect/schemas/crendentials.ts b/mods/common/src/connect/schemas/crendentials.ts index 0642cf3a1..bb4bffa77 100644 --- a/mods/common/src/connect/schemas/crendentials.ts +++ b/mods/common/src/connect/schemas/crendentials.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/common/src/connect/schemas/domain.ts b/mods/common/src/connect/schemas/domain.ts index aae7ff5d5..64cb4cbda 100644 --- a/mods/common/src/connect/schemas/domain.ts +++ b/mods/common/src/connect/schemas/domain.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/common/src/connect/schemas/index.ts b/mods/common/src/connect/schemas/index.ts index 7a532d587..805a2213f 100644 --- a/mods/common/src/connect/schemas/index.ts +++ b/mods/common/src/connect/schemas/index.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/common/src/connect/schemas/number.ts b/mods/common/src/connect/schemas/number.ts index dca690d68..5eccbc4da 100644 --- a/mods/common/src/connect/schemas/number.ts +++ b/mods/common/src/connect/schemas/number.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/common/src/connect/schemas/peer.ts b/mods/common/src/connect/schemas/peer.ts index 5e04667ac..a87e2f3ac 100644 --- a/mods/common/src/connect/schemas/peer.ts +++ b/mods/common/src/connect/schemas/peer.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. @@ -91,6 +91,16 @@ export default { } } }, + maxContacts: { + description: + "The maximum number of contacts acceptable for this Peer", + type: "integer" + }, + expires: { + description: + "Time, in seconds, to override the expires requested by the Peer", + type: "integer" + }, enabled: { description: "Whether the Peer is enabled", type: "boolean" diff --git a/mods/common/src/connect/schemas/trunk.ts b/mods/common/src/connect/schemas/trunk.ts index 346829712..debb650d0 100644 --- a/mods/common/src/connect/schemas/trunk.ts +++ b/mods/common/src/connect/schemas/trunk.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/common/src/connect/schemas/validators.ts b/mods/common/src/connect/schemas/validators.ts index a784c700b..15f5d36af 100644 --- a/mods/common/src/connect/schemas/validators.ts +++ b/mods/common/src/connect/schemas/validators.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/common/src/connect/types.ts b/mods/common/src/connect/types.ts index ddc7029bd..179942506 100644 --- a/mods/common/src/connect/types.ts +++ b/mods/common/src/connect/types.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. @@ -70,6 +70,8 @@ export interface Agent extends BaseConnectModel { enabled: boolean domainRef?: string domain?: Domain + maxContacts: number + expires?: number credentialsRef?: string credentials?: Credentials } @@ -124,6 +126,8 @@ export interface Peer extends BaseConnectModel { accessControlList?: AccessControlList credentialsRef?: string credentials?: Credentials + maxContacts: number + expires?: number balancingAlgorithm?: LoadBalancingAlgorithm withSessionAffinity?: boolean } diff --git a/mods/common/src/connect/validations.ts b/mods/common/src/connect/validations.ts index 2cd3bc79f..033801fb7 100644 --- a/mods/common/src/connect/validations.ts +++ b/mods/common/src/connect/validations.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. @@ -18,7 +18,6 @@ */ import * as Validator from "validator" import { BadRequestError } from "../errors" -import { LoadBalancingAlgorithm } from "../types" import { phone } from "phone" export const hasReference = (ref: string) => @@ -204,25 +203,6 @@ export const isValidInboundUri = (inboundUri: string) => { return true } -export const isValidBalancingAlgorithm = ( - aor: string, - algorithm: LoadBalancingAlgorithm -) => { - if (aor.startsWith("backend:")) { - if (!algorithm || algorithm === LoadBalancingAlgorithm.UNSPECIFIED) { - return new BadRequestError( - "when the aor schema is `backend:`, the balancing algorithm is required" - ) - } - } else { - if (algorithm && algorithm !== LoadBalancingAlgorithm.UNSPECIFIED) { - return new BadRequestError( - "when the aor schema is `sip:`, the balancing algorithm is not allowed" - ) - } - } -} - export const isValidPort = (port: string) => { if (port) { if (!Validator.default.isPort(port)) { diff --git a/mods/common/src/envs.ts b/mods/common/src/envs.ts index 37c27a026..a9e8e874d 100644 --- a/mods/common/src/envs.ts +++ b/mods/common/src/envs.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/common/src/errors.ts b/mods/common/src/errors.ts index a7a2cfb1d..716506774 100644 --- a/mods/common/src/errors.ts +++ b/mods/common/src/errors.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/common/src/helper.ts b/mods/common/src/helper.ts index 471b95b68..4856bd9e9 100644 --- a/mods/common/src/helper.ts +++ b/mods/common/src/helper.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr @@ -108,10 +108,10 @@ export const readConfigFile = (path: string): Record => { } } -export const toPascaleCase = (str: string) => { +export const toPascalCase = (str: string): string => { return str - .replace(/(?:^\w|[A-Z]|\b\w)/g, (word, index) => { - return index === 0 ? word.toUpperCase() : word.toUpperCase() + .replace(/(?:^\w|[A-Z]|\b\w)/g, (word) => { + return word.toUpperCase() }) .replace(/\s+/g, "") } diff --git a/mods/common/src/index.ts b/mods/common/src/index.ts index 6bc6d3a26..54195b3c1 100644 --- a/mods/common/src/index.ts +++ b/mods/common/src/index.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr @@ -59,6 +59,7 @@ export * as Tracer from "./tracer" export * as Assertions from "./assertions" export * as CommonConnect from "./connect" export * as CommonRequester from "./requester" +export * as CommonResponse from "./response" export * as CommonTypes from "./types" export * as CommonErrors from "./errors" export * as ConnectSchemas from "./connect/schemas" diff --git a/mods/common/src/ip_utils.ts b/mods/common/src/ip_utils.ts index 3670191e5..0cf4ca944 100644 --- a/mods/common/src/ip_utils.ts +++ b/mods/common/src/ip_utils.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/common/src/protos/common.proto b/mods/common/src/protos/common.proto index a52032289..0f93010b2 100644 --- a/mods/common/src/protos/common.proto +++ b/mods/common/src/protos/common.proto @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/common/src/protos/location.proto b/mods/common/src/protos/location.proto index 53bb0533e..1a0765eb3 100644 --- a/mods/common/src/protos/location.proto +++ b/mods/common/src/protos/location.proto @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr @@ -60,6 +60,7 @@ message AddRouteRequest { // Address of record for the endpoint or trunk string aor = 1; Route route = 2; + int32 max_contacts = 3; } message FindRoutesRequest { diff --git a/mods/common/src/protos/processor.proto b/mods/common/src/protos/processor.proto index 351aa2873..3ef7930e8 100644 --- a/mods/common/src/protos/processor.proto +++ b/mods/common/src/protos/processor.proto @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/common/src/protos/requester.proto b/mods/common/src/protos/requester.proto index 84abad19e..069d05686 100644 --- a/mods/common/src/protos/requester.proto +++ b/mods/common/src/protos/requester.proto @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/common/src/protos/sipmessage.proto b/mods/common/src/protos/sipmessage.proto index 1c7d36bf1..3eb39324b 100644 --- a/mods/common/src/protos/sipmessage.proto +++ b/mods/common/src/protos/sipmessage.proto @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/common/src/protos/verifier.proto b/mods/common/src/protos/verifier.proto index a5c8bcedf..e05a19312 100644 --- a/mods/common/src/protos/verifier.proto +++ b/mods/common/src/protos/verifier.proto @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/common/src/redis.ts b/mods/common/src/redis.ts index 2636c181e..920b292e2 100644 --- a/mods/common/src/redis.ts +++ b/mods/common/src/redis.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/common/src/requester/grpc_client.ts b/mods/common/src/requester/grpc_client.ts index 5ec5c75ba..da1870c12 100644 --- a/mods/common/src/requester/grpc_client.ts +++ b/mods/common/src/requester/grpc_client.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/common/src/requester/index.ts b/mods/common/src/requester/index.ts index e3fefcb1d..4c2d51e77 100644 --- a/mods/common/src/requester/index.ts +++ b/mods/common/src/requester/index.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/common/src/response.ts b/mods/common/src/response.ts new file mode 100644 index 000000000..653f3f39f --- /dev/null +++ b/mods/common/src/response.ts @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) + * http://github.com/fonoster/routr + * + * This file is part of Routr. + * + * Licensed under the MIT License (the "License"); + * you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * https://opensource.org/licenses/MIT + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { DEFAULT_ALGORITHM, generateNonce } from "./auth" +import { ResponseType } from "./types" + +export const createUnauthorizedResponse = ( + realm: string, + params: { + qop: string + algorithm: string + } = { qop: "auth", algorithm: DEFAULT_ALGORITHM } +) => { + return { + message: { + responseType: ResponseType.UNAUTHORIZED, + reasonPhrase: "Unauthorized", + wwwAuthenticate: { + scheme: "Digest", + realm: realm, + qop: params.qop, + opaque: "", + stale: false, + nonce: generateNonce(), + algorithm: params.algorithm + } + } + } +} + +export const createUnauthorizedResponseWithoutChallenge = ( + metadata?: Record +) => { + return { + metadata, + message: { + responseType: ResponseType.UNAUTHORIZED, + reasonPhrase: "Unauthorized" + } + } +} + +export const createServerInternalErrorResponse = ( + metadata?: Record +) => { + return { + metadata, + message: { + responseType: ResponseType.SERVER_INTERNAL_ERROR, + reasonPhrase: "Server Internal Error" + } + } +} + +export const createForbideenResponse = (metadata?: Record) => { + return { + metadata, + message: { + responseType: ResponseType.FORBIDDEN, + reasonPhrase: "Forbidden" + } + } +} diff --git a/mods/common/src/service.ts b/mods/common/src/service.ts index 6bc182005..b81c270d3 100644 --- a/mods/common/src/service.ts +++ b/mods/common/src/service.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/common/src/tracer.ts b/mods/common/src/tracer.ts index ac83e12cb..b10cd8145 100644 --- a/mods/common/src/tracer.ts +++ b/mods/common/src/tracer.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/common/src/types.ts b/mods/common/src/types.ts index bd4cc9a8a..ac3ff1b57 100644 --- a/mods/common/src/types.ts +++ b/mods/common/src/types.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/common/src/verifier/grpc_client.ts b/mods/common/src/verifier/grpc_client.ts index b3ff19385..07a89c6b2 100644 --- a/mods/common/src/verifier/grpc_client.ts +++ b/mods/common/src/verifier/grpc_client.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/common/src/verifier/index.ts b/mods/common/src/verifier/index.ts index 850d9f060..19687b5ce 100644 --- a/mods/common/src/verifier/index.ts +++ b/mods/common/src/verifier/index.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/common/src/verifier/types.ts b/mods/common/src/verifier/types.ts index 005bb4af7..d0d156733 100644 --- a/mods/common/src/verifier/types.ts +++ b/mods/common/src/verifier/types.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. @@ -25,5 +25,6 @@ export interface VerifyResponse { aor: string aorLink: string username: string + maxContacts: number allowedMethods: Method[] } diff --git a/mods/common/src/verifier/verifier.ts b/mods/common/src/verifier/verifier.ts index 3e5f4be67..0b5111603 100644 --- a/mods/common/src/verifier/verifier.ts +++ b/mods/common/src/verifier/verifier.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/common/test/common.unit.test.ts b/mods/common/test/common.unit.test.ts index 7cc6e3d9a..db7b6bcf0 100644 --- a/mods/common/test/common.unit.test.ts +++ b/mods/common/test/common.unit.test.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr @@ -22,7 +22,8 @@ import sinonChai from "sinon-chai" import { getObjectProto } from "../src/service" import { addressCount, getLocalnetIp, isLocalnet } from "../src/ip_utils" import { getRedisUrlFromConfig } from "../src/redis" -import { createUnauthorizedResponse, getCredentials } from "../src/auth" +import { getCredentials } from "../src/auth" +import { createUnauthorizedResponse } from "../src/response" import { ResponseType } from "../src/types" const expect = chai.expect diff --git a/mods/common/test/mappers.unit.test.ts b/mods/common/test/mappers.unit.test.ts index 4ade4f13b..971aa4b88 100644 --- a/mods/common/test/mappers.unit.test.ts +++ b/mods/common/test/mappers.unit.test.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/connect/Dockerfile b/mods/connect/Dockerfile index 53366c0c4..f32992633 100644 --- a/mods/connect/Dockerfile +++ b/mods/connect/Dockerfile @@ -1,4 +1,4 @@ -FROM alpine:3.18 +FROM alpine:3.19 LABEL maintainer="Pedro Sanders " COPY . /scripts diff --git a/mods/connect/src/access.ts b/mods/connect/src/access.ts index 20b42fff3..3454b1642 100644 --- a/mods/connect/src/access.ts +++ b/mods/connect/src/access.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. @@ -22,6 +22,7 @@ import { MessageRequest, CommonTypes as CT, CommonConnect as CC, + CommonResponse as CR, IpUtils } from "@routr/common" import { RoutingDirection } from "./types" @@ -40,11 +41,11 @@ export const checkAccess = async (accessRequest: { case RoutingDirection.PEER_TO_PSTN: case RoutingDirection.AGENT_TO_AGENT: case RoutingDirection.AGENT_TO_PSTN: - return checkAgentOrPeerAccess(request, caller as CC.RoutableResourceUnion) + return checkAgentOrPeerAccess(request, caller) case RoutingDirection.FROM_PSTN: return checkAccessFromPSTN(apiClient, request, callee as CC.INumber) case RoutingDirection.UNKNOWN: - return Auth.createForbideenResponse() + return CR.createForbideenResponse() } } @@ -68,10 +69,10 @@ export const checkAgentOrPeerAccess = async ( ) if (calcRes !== auth.response) { - return Auth.createUnauthorizedResponse(request.message.requestUri.host) + return CR.createUnauthorizedResponse(request.message.requestUri.host) } } else { - return Auth.createUnauthorizedResponse(request.message.requestUri.host) + return CR.createUnauthorizedResponse(request.message.requestUri.host) } } @@ -90,11 +91,11 @@ export const checkAccessFromPSTN = async ( // If the Trunk or Number doesn't exist reject the call if (!callee || !trunk) { - return Auth.createForbideenResponse() + return CR.createForbideenResponse() } if (callee.trunk.ref !== trunk.ref) { - return Auth.createForbideenResponse() + return CR.createForbideenResponse() } // Verify that the IP is allowlist which means getting the access control list for the trunk @@ -105,11 +106,11 @@ export const checkAccessFromPSTN = async ( })[0] if (!allow) { - return Auth.createUnauthorizedResponseWithoutChallenge() + return CR.createUnauthorizedResponseWithoutChallenge() } } catch (e) { logger.error(e) - return Auth.createServerInternalErrorResponse() + return CR.createServerInternalErrorResponse() } } @@ -130,10 +131,10 @@ export const checkAccessFromPSTN = async ( ) if (calcRes !== auth.response) { - return Auth.createUnauthorizedResponse(request.message.requestUri.host) + return CR.createUnauthorizedResponse(request.message.requestUri.host) } } else { - return Auth.createUnauthorizedResponse(request.message.requestUri.host) + return CR.createUnauthorizedResponse(request.message.requestUri.host) } } } diff --git a/mods/connect/src/assertions.ts b/mods/connect/src/assertions.ts index a5ca72827..7fd6dfd5f 100644 --- a/mods/connect/src/assertions.ts +++ b/mods/connect/src/assertions.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/connect/src/envs.ts b/mods/connect/src/envs.ts index 7a0df9882..fe267fda5 100644 --- a/mods/connect/src/envs.ts +++ b/mods/connect/src/envs.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/connect/src/errors.ts b/mods/connect/src/errors.ts index 05a245da9..9344089b3 100644 --- a/mods/connect/src/errors.ts +++ b/mods/connect/src/errors.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/connect/src/handlers/register.ts b/mods/connect/src/handlers/register.ts index da8078bca..11c5aad0b 100644 --- a/mods/connect/src/handlers/register.ts +++ b/mods/connect/src/handlers/register.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr @@ -16,6 +16,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import * as grpc from "@grpc/grpc-js" import { Helper as H, ILocationService } from "@routr/location" import { Extensions as E, @@ -27,6 +28,7 @@ import { Auth, CommonConnect as CC, CommonTypes as CT, + CommonResponse as CR, Method, Verifier } from "@routr/common" @@ -51,14 +53,14 @@ export const handleRegister = ( const auth = { ...request.message.authorization } auth.method = request.method const fromURI = request.message.from.address.uri - const peerOrAgent = await findResource( + const peerOrAgent = (await findResource( apiClient, fromURI.host, fromURI.user - ) + )) as CC.Peer | CC.Agent if (!peerOrAgent) { - return res.send(Auth.createForbideenResponse()) + return res.send(CR.createForbideenResponse()) } const credentials = ( @@ -76,17 +78,27 @@ export const handleRegister = ( if (calcRes !== auth.response) { return res.send( - Auth.createUnauthorizedResponse(request.message.requestUri.host) + CR.createUnauthorizedResponse(request.message.requestUri.host) ) } - // TODO: Needs test - await location.addRoute({ - aor: "aor" in peerOrAgent ? peerOrAgent.aor : T.getTargetAOR(request), - route: H.createRoute(request) - }) - - res.sendRegisterOk(request) + try { + await location.addRoute({ + aor: "aor" in peerOrAgent ? peerOrAgent.aor : T.getTargetAOR(request), + route: H.createRoute(request), + maxContacts: peerOrAgent.maxContacts + }) + res.sendRegisterOk(request) + } catch (e) { + if (e.code === grpc.status.INVALID_ARGUMENT) { + const details = (e as unknown as { details: string }).details + res.sendForbidden(details) + logger.verbose(details) + return + } + logger.error(e) + res.sendInternalServerError() + } } else if (hasXConnectObjectHeader(request)) { const connectToken = E.getHeaderValue( request, @@ -99,12 +111,13 @@ export const handleRegister = ( )) as Verifier.VerifyResponse if (!payload.allowedMethods.includes(Method.REGISTER)) { - return res.send(Auth.createForbideenResponse()) + return res.send(CR.createForbideenResponse()) } await location.addRoute({ aor: payload.aor, - route: H.createRoute(request) + route: H.createRoute(request), + maxContacts: payload.maxContacts || -1 }) res.sendRegisterOk(request) @@ -112,10 +125,10 @@ export const handleRegister = ( logger.verbose("unable to validate connect token", { originalError: e.message }) - res.send(Auth.createForbideenResponse()) + res.send(CR.createForbideenResponse()) } } else { - res.send(Auth.createUnauthorizedResponse(request.message.requestUri.host)) + res.send(CR.createUnauthorizedResponse(request.message.requestUri.host)) } } } diff --git a/mods/connect/src/handlers/registry.ts b/mods/connect/src/handlers/registry.ts index a36342657..9b32d3430 100644 --- a/mods/connect/src/handlers/registry.ts +++ b/mods/connect/src/handlers/registry.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/connect/src/handlers/request.ts b/mods/connect/src/handlers/request.ts index 89f3bb63d..f7283e3a8 100644 --- a/mods/connect/src/handlers/request.ts +++ b/mods/connect/src/handlers/request.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/connect/src/index.ts b/mods/connect/src/index.ts index 40f313db1..a1639e3c0 100644 --- a/mods/connect/src/index.ts +++ b/mods/connect/src/index.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/connect/src/router.ts b/mods/connect/src/router.ts index 7eb68b3a3..6d37d3cf1 100644 --- a/mods/connect/src/router.ts +++ b/mods/connect/src/router.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. @@ -18,9 +18,9 @@ */ import { RoutingDirection } from "./types" import { - Auth, CommonConnect as CC, CommonTypes as CT, + CommonResponse as CR, HeaderModifier, Route, Method, @@ -40,11 +40,10 @@ import { hasXConnectObjectHeader } from "./utils" import { MessageRequest, Target as T, Extensions as E } from "@routr/processor" -import { ILocationService } from "@routr/location" +import { ILocationService, Backend } from "@routr/location" import { UnsuportedRoutingError } from "./errors" import { getLogger } from "@fonoster/logger" import { checkAccess } from "./access" -import { Backend } from "@routr/location" const logger = getLogger({ service: "connect", filePath: __filename }) const jwtVerifier = getVerifierImpl() @@ -70,7 +69,7 @@ export function router(location: ILocationService, apiClient: CC.APIClient) { try { if (!jwtVerifier) { - return Auth.createServerInternalErrorResponse() + return CR.createServerInternalErrorResponse() } const payload = (await jwtVerifier.verify( @@ -79,12 +78,12 @@ export function router(location: ILocationService, apiClient: CC.APIClient) { const domain = await findDomain(apiClient, payload.domain) if (!payload.allowedMethods.includes(Method.INVITE)) { - return Auth.createForbideenResponse() + return CR.createForbideenResponse() } caller = { apiVersion: CC.APIVersion.V2, - ref: payload.ref as string, + ref: payload.ref, name: request.message.from.address.displayName ?? CT.ANONYMOUS, domain: domain, domainRef: payload.domainRef, @@ -117,7 +116,7 @@ export function router(location: ILocationService, apiClient: CC.APIClient) { logger.verbose("unable to validate connect token", { originalError: e.message }) - return Auth.createForbideenResponse() + return CR.createForbideenResponse() } } else { caller = await findResource(apiClient, fromURI.host, fromURI.user) @@ -155,7 +154,11 @@ export function router(location: ILocationService, apiClient: CC.APIClient) { } } - const result = (direction: RoutingDirection, route: Route, extended: any) => + const result = ( + direction: RoutingDirection, + route: Route, + extended: Record + ) => route ? { direction, @@ -236,16 +239,15 @@ async function fromPSTN( const sessionAffinityRef = E.getHeaderValue(req, callee.sessionAffinityHeader) let backend: Backend - if (callee.aorLink.startsWith("backend:")) { - const peer = ( - await apiClient.peers.findBy({ - fieldName: "aor", - fieldValue: callee.aorLink - }) - ).items[0] + const peer = ( + await apiClient.peers.findBy({ + fieldName: "aor", + fieldValue: callee.aorLink + }) + ).items[0] + if (peer) { backend = { - ref: peer.ref, balancingAlgorithm: peer.balancingAlgorithm, withSessionAffinity: peer.withSessionAffinity } @@ -350,7 +352,6 @@ async function agentToPeer( req: MessageRequest ) { const backend: Backend = { - ref: callee.ref, balancingAlgorithm: callee.balancingAlgorithm, withSessionAffinity: callee.withSessionAffinity } diff --git a/mods/connect/src/runner.ts b/mods/connect/src/runner.ts index 1bbd942c3..d01181765 100644 --- a/mods/connect/src/runner.ts +++ b/mods/connect/src/runner.ts @@ -1,6 +1,6 @@ #!/usr/bin/env node /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/connect/src/service.ts b/mods/connect/src/service.ts index 38d8dc40c..9033ad528 100644 --- a/mods/connect/src/service.ts +++ b/mods/connect/src/service.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/connect/src/tailor.ts b/mods/connect/src/tailor.ts index 9cf8933c0..5222cb8d9 100644 --- a/mods/connect/src/tailor.ts +++ b/mods/connect/src/tailor.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/connect/src/tracer.ts b/mods/connect/src/tracer.ts index ac83e12cb..b10cd8145 100644 --- a/mods/connect/src/tracer.ts +++ b/mods/connect/src/tracer.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/connect/src/types.ts b/mods/connect/src/types.ts index 4bb4a2a31..a8e3df9c6 100644 --- a/mods/connect/src/types.ts +++ b/mods/connect/src/types.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/connect/src/utils.ts b/mods/connect/src/utils.ts index fd4d891c5..aabf4fc9d 100644 --- a/mods/connect/src/utils.ts +++ b/mods/connect/src/utils.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/connect/test/access.unit.test.ts b/mods/connect/test/access.unit.test.ts index f7b14ee17..5a181f82c 100644 --- a/mods/connect/test/access.unit.test.ts +++ b/mods/connect/test/access.unit.test.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/connect/test/connect.unit.test.ts b/mods/connect/test/connect.unit.test.ts index 696a36e4f..6a284108e 100644 --- a/mods/connect/test/connect.unit.test.ts +++ b/mods/connect/test/connect.unit.test.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/connect/test/examples.ts b/mods/connect/test/examples.ts index 3f9214033..59135a806 100644 --- a/mods/connect/test/examples.ts +++ b/mods/connect/test/examples.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/connect/test/mock_apis.ts b/mods/connect/test/mock_apis.ts index cae3a583b..d1b836df9 100644 --- a/mods/connect/test/mock_apis.ts +++ b/mods/connect/test/mock_apis.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/connect/test/utils.unit.test.ts b/mods/connect/test/utils.unit.test.ts index 69d34f60b..f29b524c1 100644 --- a/mods/connect/test/utils.unit.test.ts +++ b/mods/connect/test/utils.unit.test.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/ctl/README.md b/mods/ctl/README.md index 8be84a79f..6205bffef 100644 --- a/mods/ctl/README.md +++ b/mods/ctl/README.md @@ -809,8 +809,8 @@ DESCRIPTION EXAMPLES $ rctl peers get - Ref Name Username AOR Balancing Algorithm Session Affinity - 6f941c63-880c-419a-a72a-4a107cbaf5c5 Asterisk Conference conference backend:conference ROUND_ROBIN Yes + Ref Name Username AOR Balancing Algorithm Session Affinity + 6f941c63-880c-419a-a72a-4a107cbaf5c5 Asterisk Conference conference sip:conference@sip.local ROUND_ROBIN Yes ``` _See code: [src/commands/peers/get.ts](https://github.com/fonoster/routr/blob/v2.6.4/mods/ctl/src/commands/peers/get.ts)_ diff --git a/mods/ctl/src/base.ts b/mods/ctl/src/base.ts index 7fca3f21f..b943dea6a 100644 --- a/mods/ctl/src/base.ts +++ b/mods/ctl/src/base.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster * * This file is part of Routr. @@ -20,7 +20,7 @@ import { Command, Flags } from "@oclif/core" export abstract class BaseCommand extends Command { - static globalFlags = { + static readonly globalFlags = { insecure: Flags.boolean({ char: "i", description: "allow insecure connections to the routr server", diff --git a/mods/ctl/src/commands/acl/create.ts b/mods/ctl/src/commands/acl/create.ts index aa971fc8c..218a0a827 100644 --- a/mods/ctl/src/commands/acl/create.ts +++ b/mods/ctl/src/commands/acl/create.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster * * This file is part of Routr. @@ -30,9 +30,9 @@ import SDK from "@routr/sdk" import inquirer from "inquirer" export default class CreateCommand extends BaseCommand { - static description = "Creates a new ACL" + static readonly description = "Creates a new ACL" - static examples = [ + static readonly examples = [ `<%= config.bin %> <%= command.id %> Creating ACL US Eeast... b148b4b4-6884-4c06-bb7e-bd098f5fe793 ` diff --git a/mods/ctl/src/commands/acl/delete.ts b/mods/ctl/src/commands/acl/delete.ts index a43fd697e..8caf3a840 100644 --- a/mods/ctl/src/commands/acl/delete.ts +++ b/mods/ctl/src/commands/acl/delete.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster * * This file is part of Routr. diff --git a/mods/ctl/src/commands/acl/describe.ts b/mods/ctl/src/commands/acl/describe.ts index ca7b8e08f..d0c63c663 100644 --- a/mods/ctl/src/commands/acl/describe.ts +++ b/mods/ctl/src/commands/acl/describe.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster * * This file is part of Routr. diff --git a/mods/ctl/src/commands/acl/get.ts b/mods/ctl/src/commands/acl/get.ts index 8c24b3349..6bbcc61e0 100644 --- a/mods/ctl/src/commands/acl/get.ts +++ b/mods/ctl/src/commands/acl/get.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster * * This file is part of Routr. diff --git a/mods/ctl/src/commands/acl/update.ts b/mods/ctl/src/commands/acl/update.ts index 84405ec85..3cbcb8787 100644 --- a/mods/ctl/src/commands/acl/update.ts +++ b/mods/ctl/src/commands/acl/update.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster * * This file is part of Routr. @@ -29,9 +29,9 @@ import SDK from "@routr/sdk" import inquirer from "inquirer" export default class UpdateCommand extends BaseCommand { - static description = "Updates an existing ACL" + static readonly description = "Updates an existing ACL" - static examples = [ + static readonly examples = [ `<%= config.bin %> <%= command.id %> Updating ACL US East... 80181ca6-d4aa-4575-9375-8f72b07d5555 ` diff --git a/mods/ctl/src/commands/agents/create.ts b/mods/ctl/src/commands/agents/create.ts index 04fde6c89..cd86ebea1 100644 --- a/mods/ctl/src/commands/agents/create.ts +++ b/mods/ctl/src/commands/agents/create.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster * * This file is part of Routr. @@ -108,6 +108,11 @@ Creating Agent Jhon Doe... b148b4b4-6884-4c06-bb7e-bd098f5fe793 type: "list", choices: [{ name: "None", value: undefined }, ...credentialsList] }, + { + name: "maxContacts", + message: "Max Contacts", + type: "input" + }, { name: "privacy", message: "Privacy", diff --git a/mods/ctl/src/commands/agents/delete.ts b/mods/ctl/src/commands/agents/delete.ts index 23b2c87b3..0fdf171b3 100644 --- a/mods/ctl/src/commands/agents/delete.ts +++ b/mods/ctl/src/commands/agents/delete.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster * * This file is part of Routr. @@ -21,9 +21,9 @@ import DeleteCommand from "../../delete" import SDK from "@routr/sdk" export default class DeleteAgentCommand extends DeleteCommand { - static description = "Deletes an Agent" + static readonly description = "Deletes an Agent" - static examples = [ + static readonly examples = [ `<%= config.bin %> <%= command.id %> Deleting item 80181ca6-d4aa-4575-9375-8f72b071111... Done ` diff --git a/mods/ctl/src/commands/agents/describe.ts b/mods/ctl/src/commands/agents/describe.ts index 243228b59..e9e670de2 100644 --- a/mods/ctl/src/commands/agents/describe.ts +++ b/mods/ctl/src/commands/agents/describe.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster * * This file is part of Routr. @@ -25,8 +25,8 @@ import SDK from "@routr/sdk" import moment from "moment" export default class DescribeCommand extends BaseCommand { - static description = "shows details of an Agent" - static args = [ + static readonly description = "shows details of an Agent" + static readonly args = [ { name: "ref", required: false, @@ -49,6 +49,7 @@ export default class DescribeCommand extends BaseCommand { Name: agent.name, Username: agent.username, Domain: agent.domain?.domainUri || "None", + "Max Contacts": agent.maxContacts, Privacy: capitalize(agent.privacy), Credentials: agent.credentials ? { diff --git a/mods/ctl/src/commands/agents/get.ts b/mods/ctl/src/commands/agents/get.ts index 72d39243f..42acb9cbb 100644 --- a/mods/ctl/src/commands/agents/get.ts +++ b/mods/ctl/src/commands/agents/get.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster * * This file is part of Routr. @@ -27,17 +27,17 @@ import { CommandError } from "@oclif/core/lib/interfaces" import { CommonTypes as CT } from "@routr/common" export default class GetAgentsCommand extends BaseCommand { - static description = + static readonly description = "Shows a list of paginated Agents or a single Agent if ref is provided" - static examples = [ + static readonly examples = [ `<%= config.bin %> <%= command.id %> -Ref Name Username Domain Privacy Enabled -d31f5fb8-e367-42f7-9884-1a7999f53fe8 John Doe jdoe sip.local PRIVATE Yes +Ref Name Username Domain Max Contacts Privacy Enabled +d31f5fb8-e367-42f7-9884-1a7999f53fe8 John Doe jdoe sip.local 1 PRIVATE Yes ` ] - static flags = { + static readonly flags = { size: Flags.integer({ char: "s", description: "The number of items to return", @@ -84,6 +84,11 @@ d31f5fb8-e367-42f7-9884-1a7999f53fe8 John Doe jdoe sip.local PRIVATE Yes header: "Domain", get: (row: { domain: CC.Domain }) => row.domain?.domainUri || "None" }, + maxContacts: { + header: "Max Contacts", + get: (row: { maxContacts: number }) => + row.maxContacts === -1 ? "" : row.maxContacts + }, privacy: { header: "Privacy", get: (row: { privacy: CT.Privacy }) => capitalize(row.privacy) diff --git a/mods/ctl/src/commands/agents/update.ts b/mods/ctl/src/commands/agents/update.ts index 1de30ca36..1698fc2ec 100644 --- a/mods/ctl/src/commands/agents/update.ts +++ b/mods/ctl/src/commands/agents/update.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster * * This file is part of Routr. @@ -29,15 +29,15 @@ import SDK from "@routr/sdk" import inquirer from "inquirer" export default class UpdateCommand extends BaseCommand { - static description = "Updates an existing Agent" + static readonly description = "Updates an existing Agent" - static examples = [ + static readonly examples = [ `<%= config.bin %> <%= command.id %> Updating Agent John Doe... 80181ca6-d4aa-4575-9375-8f72b07d5555 ` ] - static args = [ + static readonly args = [ { name: "ref", required: true, @@ -107,6 +107,12 @@ Updating Agent John Doe... 80181ca6-d4aa-4575-9375-8f72b07d5555 choices: [{ name: "None", value: undefined }, ...credentialsList], default: agentFromDB.credentialsRef }, + { + name: "maxContacts", + message: "Max Contacts", + type: "input", + default: agentFromDB.maxContacts === -1 ? "" : agentFromDB.maxContacts + }, { name: "privacy", message: "Privacy", diff --git a/mods/ctl/src/commands/credentials/create.ts b/mods/ctl/src/commands/credentials/create.ts index f96d413ac..0547e27bd 100644 --- a/mods/ctl/src/commands/credentials/create.ts +++ b/mods/ctl/src/commands/credentials/create.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster * * This file is part of Routr. @@ -29,9 +29,9 @@ import inquirer from "inquirer" import { nameValidator, usernameValidator } from "../../validators" export default class CreateCommand extends BaseCommand { - static description = "Creates a new set of Credentials" + static readonly description = "Creates a new set of Credentials" - static examples = [ + static readonly examples = [ `<%= config.bin %> <%= command.id %> Creating Credentials JDoe Access... b148b4b4-6884-4c06-bb7e-bd098f5fe793 ` diff --git a/mods/ctl/src/commands/credentials/delete.ts b/mods/ctl/src/commands/credentials/delete.ts index 8346d3abe..19c79cacd 100644 --- a/mods/ctl/src/commands/credentials/delete.ts +++ b/mods/ctl/src/commands/credentials/delete.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster * * This file is part of Routr. diff --git a/mods/ctl/src/commands/credentials/describe.ts b/mods/ctl/src/commands/credentials/describe.ts index 5ef6d809f..abc4db5f4 100644 --- a/mods/ctl/src/commands/credentials/describe.ts +++ b/mods/ctl/src/commands/credentials/describe.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster * * This file is part of Routr. @@ -24,8 +24,8 @@ import SDK from "@routr/sdk" import moment from "moment" export default class DescribeCommand extends BaseCommand { - static description = "shows details for a set of Credentials" - static args = [ + static readonly description = "shows details for a set of Credentials" + static readonly args = [ { name: "ref", required: false, diff --git a/mods/ctl/src/commands/credentials/get.ts b/mods/ctl/src/commands/credentials/get.ts index aa6c40411..1f6fad8c2 100644 --- a/mods/ctl/src/commands/credentials/get.ts +++ b/mods/ctl/src/commands/credentials/get.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster * * This file is part of Routr. @@ -26,10 +26,10 @@ import { CLIError } from "@oclif/core/lib/errors" import { CommandError } from "@oclif/core/lib/interfaces" export default class GetCommand extends BaseCommand { - static description = + static readonly description = "Shows a list of paginated Credentials or a single set if ref is provided" - static examples = [ + static readonly examples = [ `<%= config.bin %> <%= command.id %> Ref Name Deny List Allow List 80181ca6-d4aa-4575-9375-8f72b07d6666 Europe ACL 0.0.0.0/0 10.0.0.25 diff --git a/mods/ctl/src/commands/credentials/update.ts b/mods/ctl/src/commands/credentials/update.ts index 0112febfc..f0d88af5e 100644 --- a/mods/ctl/src/commands/credentials/update.ts +++ b/mods/ctl/src/commands/credentials/update.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster * * This file is part of Routr. @@ -28,15 +28,15 @@ import inquirer from "inquirer" import { nameValidator, usernameValidator } from "../../validators" export default class UpdateCommand extends BaseCommand { - static description = "Updates an existing set of Credentials" + static readonly description = "Updates an existing set of Credentials" - static examples = [ + static readonly examples = [ `<%= config.bin %> <%= command.id %> Updating Credentials JDoe Credentials... 80181ca6-d4aa-4575-9375-8f72b07d5555 ` ] - static args = [ + static readonly args = [ { name: "ref", required: true, diff --git a/mods/ctl/src/commands/domains/create.ts b/mods/ctl/src/commands/domains/create.ts index 3f35e5dc1..1d3be0963 100644 --- a/mods/ctl/src/commands/domains/create.ts +++ b/mods/ctl/src/commands/domains/create.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster * * This file is part of Routr. @@ -30,9 +30,9 @@ import SDK from "@routr/sdk" import inquirer from "inquirer" export default class CreateCommand extends BaseCommand { - static description = "Creates a new set Domain" + static readonly description = "Creates a new set Domain" - static examples = [ + static readonly examples = [ `<%= config.bin %> <%= command.id %> Creating Domain Local Domain... b148b4b4-6884-4c06-bb7e-bd098f5fe793 ` diff --git a/mods/ctl/src/commands/domains/delete.ts b/mods/ctl/src/commands/domains/delete.ts index 1b1b84b48..622122051 100644 --- a/mods/ctl/src/commands/domains/delete.ts +++ b/mods/ctl/src/commands/domains/delete.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster * * This file is part of Routr. @@ -21,9 +21,9 @@ import DeleteCommand from "../../delete" import SDK from "@routr/sdk" export default class DeleteDomainCommand extends DeleteCommand { - static description = "Deletes a Domain" + static readonly description = "Deletes a Domain" - static examples = [ + static readonly examples = [ `<%= config.bin %> <%= command.id %> Deleting item 80181ca6-d4aa-4575-9375-8f72b071111... Done ` diff --git a/mods/ctl/src/commands/domains/describe.ts b/mods/ctl/src/commands/domains/describe.ts index bbc9611e1..2cf319625 100644 --- a/mods/ctl/src/commands/domains/describe.ts +++ b/mods/ctl/src/commands/domains/describe.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster * * This file is part of Routr. @@ -24,8 +24,8 @@ import SDK from "@routr/sdk" import moment from "moment" export default class DescribeCommand extends BaseCommand { - static description = "show details of a Domain" - static args = [ + static readonly description = "show details of a Domain" + static readonly args = [ { name: "ref", required: false, diff --git a/mods/ctl/src/commands/domains/get.ts b/mods/ctl/src/commands/domains/get.ts index 0dbc73adb..261f3ebf6 100644 --- a/mods/ctl/src/commands/domains/get.ts +++ b/mods/ctl/src/commands/domains/get.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster * * This file is part of Routr. @@ -26,17 +26,17 @@ import { CLIError } from "@oclif/core/lib/errors" import { CommandError } from "@oclif/core/lib/interfaces" export default class GetDomainsCommand extends BaseCommand { - static description = + static readonly description = "Shows a list of paginated Domains or a single Domain if ref is provided" - static examples = [ + static readonly examples = [ `<%= config.bin %> <%= command.id %> Ref Name URI ab2b6959-f497-4b14-903b-85a7c464b564 Local Domain sip.local ` ] - static flags = { + static readonly flags = { size: Flags.integer({ char: "s", description: "the number of items to return", diff --git a/mods/ctl/src/commands/domains/update.ts b/mods/ctl/src/commands/domains/update.ts index 98f78bd55..bc7f57942 100644 --- a/mods/ctl/src/commands/domains/update.ts +++ b/mods/ctl/src/commands/domains/update.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster * * This file is part of Routr. @@ -29,15 +29,15 @@ import SDK from "@routr/sdk" import inquirer from "inquirer" export default class UpdateCommand extends BaseCommand { - static description = "Updates an existing Domain" + static readonly description = "Updates an existing Domain" - static examples = [ + static readonly examples = [ `<%= config.bin %> <%= command.id %> Updating Domain Local... 80181ca6-d4aa-4575-9375-8f72b07d5555 ` ] - static args = [ + static readonly args = [ { name: "ref", required: true, diff --git a/mods/ctl/src/commands/numbers/create.ts b/mods/ctl/src/commands/numbers/create.ts index 3ead46740..063286e86 100644 --- a/mods/ctl/src/commands/numbers/create.ts +++ b/mods/ctl/src/commands/numbers/create.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster * * This file is part of Routr. @@ -39,9 +39,9 @@ import SDK from "@routr/sdk" import inquirer from "inquirer" export default class CreateNumberCommand extends BaseCommand { - static description = "Creates a new Number" + static readonly description = "Creates a new Number" - static examples = [ + static readonly examples = [ `<%= config.bin %> <%= command.id %> Creating Number (784) 317-8170... a134487f-a668-4509-9ddd-dcbc98175468 ` diff --git a/mods/ctl/src/commands/numbers/delete.ts b/mods/ctl/src/commands/numbers/delete.ts index 7f66cae29..08717b3fb 100644 --- a/mods/ctl/src/commands/numbers/delete.ts +++ b/mods/ctl/src/commands/numbers/delete.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster * * This file is part of Routr. @@ -21,9 +21,9 @@ import DeleteCommand from "../../delete" import SDK from "@routr/sdk" export default class DeleteNumberCommand extends DeleteCommand { - static description = "Deletes a Number" + static readonly description = "Deletes a Number" - static examples = [ + static readonly examples = [ `<%= config.bin %> <%= command.id %> Deleting item 80181ca6-d4aa-4575-9375-8f72b071111... Done ` diff --git a/mods/ctl/src/commands/numbers/describe.ts b/mods/ctl/src/commands/numbers/describe.ts index 41d18d726..d1d8fb05b 100644 --- a/mods/ctl/src/commands/numbers/describe.ts +++ b/mods/ctl/src/commands/numbers/describe.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster * * This file is part of Routr. @@ -24,8 +24,8 @@ import SDK from "@routr/sdk" import moment from "moment" export default class DescribeCommand extends BaseCommand { - static description = "shows details for a Number" - static args = [ + static readonly description = "shows details for a Number" + static readonly args = [ { name: "ref", required: false, diff --git a/mods/ctl/src/commands/numbers/get.ts b/mods/ctl/src/commands/numbers/get.ts index 15876c172..3d35d3307 100644 --- a/mods/ctl/src/commands/numbers/get.ts +++ b/mods/ctl/src/commands/numbers/get.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster * * This file is part of Routr. @@ -27,17 +27,17 @@ import { CommandError } from "@oclif/core/lib/interfaces" import { JsonObject } from "pb-util/build" export default class GetNumbersCommand extends BaseCommand { - static description = + static readonly description = "Shows a list of paginated Numbers or a single Number if ref is provided" - static examples = [ + static readonly examples = [ `<%= config.bin %> <%= command.id %> Ref Name Telephony URL AOR Link Geo a134487f-a668-4509-9ddd-dcbc98175468 (785) 317-8070 +17853178070 sip:1001@sip.local Cameron, USA (US) ` ] - static flags = { + static readonly flags = { size: Flags.integer({ char: "s", description: "the number of items to return", diff --git a/mods/ctl/src/commands/numbers/update.ts b/mods/ctl/src/commands/numbers/update.ts index 52bca3a5e..b6145b45e 100644 --- a/mods/ctl/src/commands/numbers/update.ts +++ b/mods/ctl/src/commands/numbers/update.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster * * This file is part of Routr. @@ -35,15 +35,15 @@ import SDK from "@routr/sdk" import inquirer from "inquirer" export default class UpdateCommand extends BaseCommand { - static description = "Updates an existing set of Credentials" + static readonly description = "Updates an existing set of Credentials" - static examples = [ + static readonly examples = [ `<%= config.bin %> <%= command.id %> Updating Number (785) 317-8070... 80181ca6-d4aa-4575-9375-8f72b07d5555 ` ] - static args = [ + static readonly args = [ { name: "ref", required: true, diff --git a/mods/ctl/src/commands/peers/create.ts b/mods/ctl/src/commands/peers/create.ts index 799e8e124..a80659af5 100644 --- a/mods/ctl/src/commands/peers/create.ts +++ b/mods/ctl/src/commands/peers/create.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster * * This file is part of Routr. @@ -35,9 +35,9 @@ import { } from "../../validators" export default class CreateCommand extends BaseCommand { - static description = "Creates a new Peer" + static readonly description = "Creates a new Peer" - static examples = [ + static readonly examples = [ `<%= config.bin %> <%= command.id %> Creating Peer Asterisk Conference... b148b4b4-6884-4c06-bb7e-bd098f5fe793 ` @@ -106,6 +106,11 @@ Creating Peer Asterisk Conference... b148b4b4-6884-4c06-bb7e-bd098f5fe793 type: "input", validate: contactAddrValidator }, + { + name: "maxContacts", + message: "Max Contacts", + type: "input" + }, { name: "accessControlListRef", message: "IP Access Control List", @@ -122,8 +127,7 @@ Creating Peer Asterisk Conference... b148b4b4-6884-4c06-bb7e-bd098f5fe793 name: "withSessionAffinity", message: "Enable Session Affinity?", type: "confirm", - default: false, - when: (answers) => answers.aor.startsWith("backend:") + default: false }, { name: "balancingAlgorithm", @@ -139,8 +143,7 @@ Creating Peer Asterisk Conference... b148b4b4-6884-4c06-bb7e-bd098f5fe793 } ], type: "list", - default: CT.LoadBalancingAlgorithm.ROUND_ROBIN, - when: (answers) => answers.aor.startsWith("backend:") + default: CT.LoadBalancingAlgorithm.ROUND_ROBIN }, { name: "enabled", diff --git a/mods/ctl/src/commands/peers/delete.ts b/mods/ctl/src/commands/peers/delete.ts index 9cd278111..d286f6f08 100644 --- a/mods/ctl/src/commands/peers/delete.ts +++ b/mods/ctl/src/commands/peers/delete.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster * * This file is part of Routr. @@ -21,9 +21,9 @@ import DeleteCommand from "../../delete" import SDK from "@routr/sdk" export default class DeletePeerCommand extends DeleteCommand { - static description = "Deletes a Peer" + static readonly description = "Deletes a Peer" - static examples = [ + static readonly examples = [ `<%= config.bin %> <%= command.id %> Deleting item 80181ca6-d4aa-4575-9375-8f72b071111... Done ` diff --git a/mods/ctl/src/commands/peers/describe.ts b/mods/ctl/src/commands/peers/describe.ts index 8dac902d1..400eba947 100644 --- a/mods/ctl/src/commands/peers/describe.ts +++ b/mods/ctl/src/commands/peers/describe.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster * * This file is part of Routr. @@ -24,8 +24,8 @@ import SDK from "@routr/sdk" import moment from "moment" export default class DescribeCommand extends BaseCommand { - static description = "shows details for a Peer" - static args = [ + static readonly description = "shows details for a Peer" + static readonly args = [ { name: "ref", required: false, @@ -50,6 +50,7 @@ export default class DescribeCommand extends BaseCommand { "Balancing Algorithm": peer.balancingAlgorithm, "Session Affinity?": peer.withSessionAffinity ? "Yes" : "No", "Contact Address": peer.contactAddr, + "Max Contacts": peer.maxContacts, Enabled: peer.enabled ? "Yes" : "No", "Access Control List": peer.accessControlList ? { diff --git a/mods/ctl/src/commands/peers/get.ts b/mods/ctl/src/commands/peers/get.ts index e92196c25..e56ab22d2 100644 --- a/mods/ctl/src/commands/peers/get.ts +++ b/mods/ctl/src/commands/peers/get.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster * * This file is part of Routr. @@ -26,17 +26,17 @@ import { CLIError } from "@oclif/core/lib/errors" import { CommandError } from "@oclif/core/lib/interfaces" export default class GetCommand extends BaseCommand { - static description = + static readonly description = "Shows a list of paginated Peers or a single Peer if ref is provided" - static examples = [ + static readonly examples = [ `<%= config.bin %> <%= command.id %> -Ref Name Username AOR Balancing Algorithm Session Affinity -6f941c63-880c-419a-a72a-4a107cbaf5c5 Asterisk Conference conference backend:conference ROUND_ROBIN Yes +Ref Name Username AOR Max Contacts Balancing Algorithm Session Affinity +6f941c63-880c-419a-a72a-4a107cbaf5c5 Asterisk Conference conference sip:conference@sip.local 1 ROUND_ROBIN Yes ` ] - static flags = { + static readonly flags = { size: Flags.integer({ char: "s", description: "the number of items to return", @@ -82,6 +82,11 @@ Ref Name Username AOR aor: { header: "AOR" }, + maxContacts: { + header: "Max Contacts", + get: (row: { maxContacts: number }) => + row.maxContacts === -1 ? "" : row.maxContacts + }, enabled: { header: "Enabled", get: (row: { enabled: boolean }) => (row.enabled ? "Yes" : "No") diff --git a/mods/ctl/src/commands/peers/update.ts b/mods/ctl/src/commands/peers/update.ts index 143a67b7a..f0bd309c7 100644 --- a/mods/ctl/src/commands/peers/update.ts +++ b/mods/ctl/src/commands/peers/update.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster * * This file is part of Routr. @@ -33,15 +33,15 @@ import SDK from "@routr/sdk" import inquirer from "inquirer" export default class UpdatePeerCommand extends BaseCommand { - static description = "Updates an existing Peer" + static readonly description = "Updates an existing Peer" - static examples = [ + static readonly examples = [ `<%= config.bin %> <%= command.id %> Updating Peer Asterisk Conf... 80181ca6-d4aa-4575-9375-8f72b07d5555 ` ] - static args = [ + static readonly args = [ { name: "ref", required: true, @@ -108,6 +108,12 @@ Updating Peer Asterisk Conf... 80181ca6-d4aa-4575-9375-8f72b07d5555 default: peerFromDB.contactAddr || undefined, validate: contactAddrValidator }, + { + name: "maxContacts", + message: "Max Contacts", + type: "input", + default: peerFromDB.maxContacts === -1 ? "" : peerFromDB.maxContacts + }, { name: "accessControlListRef", message: "IP Access Control List", @@ -126,8 +132,7 @@ Updating Peer Asterisk Conf... 80181ca6-d4aa-4575-9375-8f72b07d5555 name: "withSessionAffinity", message: "Enable Session Affinity?", type: "confirm", - default: peerFromDB.withSessionAffinity, - when: (answers) => answers.aor.startsWith("backend:") + default: peerFromDB.withSessionAffinity }, { name: "balancingAlgorithm", @@ -143,8 +148,7 @@ Updating Peer Asterisk Conf... 80181ca6-d4aa-4575-9375-8f72b07d5555 } ], type: "list", - default: peerFromDB.balancingAlgorithm, - when: (answers) => answers.aor.startsWith("backend:") + default: peerFromDB.balancingAlgorithm }, { name: "enabled", diff --git a/mods/ctl/src/commands/trunks/create.ts b/mods/ctl/src/commands/trunks/create.ts index d05896759..9ca5a0068 100644 --- a/mods/ctl/src/commands/trunks/create.ts +++ b/mods/ctl/src/commands/trunks/create.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster * * This file is part of Routr. @@ -38,9 +38,9 @@ import SDK from "@routr/sdk" import inquirer from "inquirer" export default class CreateTrunkCommand extends BaseCommand { - static description = "Creates a new Trunk" + static readonly description = "Creates a new Trunk" - static examples = [ + static readonly examples = [ `<%= config.bin %> <%= command.id %> Creating Trunk T01... b148b4b4-6884-4c06-bb7e-bd098f5fe793 ` diff --git a/mods/ctl/src/commands/trunks/delete.ts b/mods/ctl/src/commands/trunks/delete.ts index c2f9e2ecd..aa509d018 100644 --- a/mods/ctl/src/commands/trunks/delete.ts +++ b/mods/ctl/src/commands/trunks/delete.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster * * This file is part of Routr. diff --git a/mods/ctl/src/commands/trunks/describe.ts b/mods/ctl/src/commands/trunks/describe.ts index 243e1747d..8a8ae01e6 100644 --- a/mods/ctl/src/commands/trunks/describe.ts +++ b/mods/ctl/src/commands/trunks/describe.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster * * This file is part of Routr. diff --git a/mods/ctl/src/commands/trunks/get.ts b/mods/ctl/src/commands/trunks/get.ts index 27aa81129..acf36b6d9 100644 --- a/mods/ctl/src/commands/trunks/get.ts +++ b/mods/ctl/src/commands/trunks/get.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster * * This file is part of Routr. @@ -26,17 +26,17 @@ import { CLIError } from "@oclif/core/lib/errors" import { CommandError } from "@oclif/core/lib/interfaces" export default class GetTrunksCommand extends BaseCommand { - static description = + static readonly description = "Shows a list of paginated Trunks or a single Trunk if ref is provided" - static examples = [ + static readonly examples = [ `<%= config.bin %> <%= command.id %> Ref Name Inbound SIP URI 8cde8ea9-3c58-4dbe-b2cf-23c4413dd4cc Local sip.t01.provider.net ` ] - static flags = { + static readonly flags = { size: Flags.integer({ char: "s", description: "the number of items to return", diff --git a/mods/ctl/src/commands/trunks/update.ts b/mods/ctl/src/commands/trunks/update.ts index f2a017efc..ae641a49e 100644 --- a/mods/ctl/src/commands/trunks/update.ts +++ b/mods/ctl/src/commands/trunks/update.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster * * This file is part of Routr. @@ -37,15 +37,15 @@ import SDK from "@routr/sdk" import inquirer from "inquirer" export default class UpdateCommand extends BaseCommand { - static description = "Updates an existing Trunk" + static readonly description = "Updates an existing Trunk" - static examples = [ + static readonly examples = [ `<%= config.bin %> <%= command.id %> Updating Trunk T01... 80181ca6-d4aa-4575-9375-8f72b07d5555 ` ] - static args = [ + static readonly args = [ { name: "ref", required: true, diff --git a/mods/ctl/src/countries.ts b/mods/ctl/src/countries.ts index 37c3e2c5c..f1e2c8454 100644 --- a/mods/ctl/src/countries.ts +++ b/mods/ctl/src/countries.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster * * This file is part of Routr. diff --git a/mods/ctl/src/delete.ts b/mods/ctl/src/delete.ts index e8494afc7..7d5754a2e 100644 --- a/mods/ctl/src/delete.ts +++ b/mods/ctl/src/delete.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/fonoster * * This file is part of Fonoster @@ -22,7 +22,7 @@ import { BaseCommand } from "./base" import { CLIError } from "@oclif/core/lib/errors" export default abstract class DeleteCommand extends BaseCommand { - static args = [{ name: "ref" }] + static readonly args = [{ name: "ref" }] // eslint-disable-next-line @typescript-eslint/no-explicit-any async deleteResource(API: any, funcName: string) { diff --git a/mods/ctl/src/help.ts b/mods/ctl/src/help.ts index 2f16e0641..b90a1871b 100644 --- a/mods/ctl/src/help.ts +++ b/mods/ctl/src/help.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster * * This file is part of Routr. @@ -17,10 +17,8 @@ * limitations under the License. */ /* eslint-disable require-jsdoc */ -// import { Help } from "@oclif/plugin-help" - -import { Help } from "@oclif/core" import * as figlet from "figlet" +import { Help } from "@oclif/core" export default class MyHelpClass extends Help { protected async showRootHelp() { diff --git a/mods/ctl/src/index.ts b/mods/ctl/src/index.ts index 38404b7d0..ea8baeacd 100644 --- a/mods/ctl/src/index.ts +++ b/mods/ctl/src/index.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster * * This file is part of Routr. diff --git a/mods/ctl/src/utils.ts b/mods/ctl/src/utils.ts index a71354608..e7ac22bf6 100644 --- a/mods/ctl/src/utils.ts +++ b/mods/ctl/src/utils.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster * * This file is part of Routr. diff --git a/mods/ctl/src/validators.ts b/mods/ctl/src/validators.ts index 39db507ef..eeff999ad 100644 --- a/mods/ctl/src/validators.ts +++ b/mods/ctl/src/validators.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster * * This file is part of Routr. diff --git a/mods/ctl/test/commands/acl/get.test.ts b/mods/ctl/test/commands/acl/get.test.ts index 66f899159..0cc151a76 100644 --- a/mods/ctl/test/commands/acl/get.test.ts +++ b/mods/ctl/test/commands/acl/get.test.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster * * This file is part of Routr. diff --git a/mods/dispatcher/Dockerfile b/mods/dispatcher/Dockerfile index 6262a9c00..ee217ae50 100644 --- a/mods/dispatcher/Dockerfile +++ b/mods/dispatcher/Dockerfile @@ -1,4 +1,4 @@ -FROM alpine:3.18 +FROM alpine:3.19 LABEL maintainer="Pedro Sanders " COPY . /scripts diff --git a/mods/dispatcher/src/config/get_config.ts b/mods/dispatcher/src/config/get_config.ts index bb852fcd8..9247fda8d 100644 --- a/mods/dispatcher/src/config/get_config.ts +++ b/mods/dispatcher/src/config/get_config.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/dispatcher/src/config/schema.ts b/mods/dispatcher/src/config/schema.ts index b776a8041..806e3295f 100644 --- a/mods/dispatcher/src/config/schema.ts +++ b/mods/dispatcher/src/config/schema.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/dispatcher/src/connections.ts b/mods/dispatcher/src/connections.ts index 594209677..dd403cd7b 100644 --- a/mods/dispatcher/src/connections.ts +++ b/mods/dispatcher/src/connections.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/dispatcher/src/envs.ts b/mods/dispatcher/src/envs.ts index 8b14d4e3e..198293780 100644 --- a/mods/dispatcher/src/envs.ts +++ b/mods/dispatcher/src/envs.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/dispatcher/src/errors.ts b/mods/dispatcher/src/errors.ts index 061b214e1..fde613483 100644 --- a/mods/dispatcher/src/errors.ts +++ b/mods/dispatcher/src/errors.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/dispatcher/src/find_processor.ts b/mods/dispatcher/src/find_processor.ts index b3b73003b..8e48ee3e9 100644 --- a/mods/dispatcher/src/find_processor.ts +++ b/mods/dispatcher/src/find_processor.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/dispatcher/src/index.ts b/mods/dispatcher/src/index.ts index f112b2259..3b1e280cd 100644 --- a/mods/dispatcher/src/index.ts +++ b/mods/dispatcher/src/index.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/dispatcher/src/processor.ts b/mods/dispatcher/src/processor.ts index e2e62df14..a02b7dbdf 100644 --- a/mods/dispatcher/src/processor.ts +++ b/mods/dispatcher/src/processor.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/dispatcher/src/run_middlewares.ts b/mods/dispatcher/src/run_middlewares.ts index 8a8fb7c51..0121bbbff 100644 --- a/mods/dispatcher/src/run_middlewares.ts +++ b/mods/dispatcher/src/run_middlewares.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/dispatcher/src/run_processor.ts b/mods/dispatcher/src/run_processor.ts index 840e2fceb..b9a310eed 100644 --- a/mods/dispatcher/src/run_processor.ts +++ b/mods/dispatcher/src/run_processor.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/dispatcher/src/runner.ts b/mods/dispatcher/src/runner.ts index d4173b09e..5e2125867 100644 --- a/mods/dispatcher/src/runner.ts +++ b/mods/dispatcher/src/runner.ts @@ -1,6 +1,6 @@ #!/usr/bin/env node /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/dispatcher/src/service.ts b/mods/dispatcher/src/service.ts index 151eddec1..f4318adc6 100644 --- a/mods/dispatcher/src/service.ts +++ b/mods/dispatcher/src/service.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/dispatcher/src/tracer.ts b/mods/dispatcher/src/tracer.ts index ac83e12cb..b10cd8145 100644 --- a/mods/dispatcher/src/tracer.ts +++ b/mods/dispatcher/src/tracer.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/dispatcher/src/types.ts b/mods/dispatcher/src/types.ts index 2de4f8b62..e4c94c867 100644 --- a/mods/dispatcher/src/types.ts +++ b/mods/dispatcher/src/types.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/dispatcher/src/util.ts b/mods/dispatcher/src/util.ts index ab20cd99e..b1473b593 100644 --- a/mods/dispatcher/src/util.ts +++ b/mods/dispatcher/src/util.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/dispatcher/test/dispatcher.unit.test.ts b/mods/dispatcher/test/dispatcher.unit.test.ts index 35cb897a7..d8ae496aa 100644 --- a/mods/dispatcher/test/dispatcher.unit.test.ts +++ b/mods/dispatcher/test/dispatcher.unit.test.ts @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/echo/Dockerfile b/mods/echo/Dockerfile index 3134748a9..257f78976 100644 --- a/mods/echo/Dockerfile +++ b/mods/echo/Dockerfile @@ -1,4 +1,4 @@ -FROM alpine:3.18 +FROM alpine:3.19 LABEL maintainer="Pedro Sanders " COPY . /scripts diff --git a/mods/echo/src/envs.ts b/mods/echo/src/envs.ts index 65977b4a8..f026a314a 100644 --- a/mods/echo/src/envs.ts +++ b/mods/echo/src/envs.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/echo/src/runner.ts b/mods/echo/src/runner.ts index 1fe8e0b9b..94e348510 100644 --- a/mods/echo/src/runner.ts +++ b/mods/echo/src/runner.ts @@ -1,6 +1,6 @@ #!/usr/bin/env node /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/echo/src/tracer.ts b/mods/echo/src/tracer.ts index ac83e12cb..b10cd8145 100644 --- a/mods/echo/src/tracer.ts +++ b/mods/echo/src/tracer.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/echo/test/echo.unit.test.ts b/mods/echo/test/echo.unit.test.ts index b0f1e2129..60b55fe3b 100644 --- a/mods/echo/test/echo.unit.test.ts +++ b/mods/echo/test/echo.unit.test.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/edgeport/Dockerfile b/mods/edgeport/Dockerfile index e70495e54..3e0aa0b2c 100644 --- a/mods/edgeport/Dockerfile +++ b/mods/edgeport/Dockerfile @@ -1,7 +1,7 @@ ## ## Build and pack the service ## -FROM alpine:3.18 as builder +FROM alpine:3.19 as builder LABEL maintainer="Pedro Sanders " ENV JAVA_HOME=/usr/lib/jvm/java-11-openjdk @@ -15,7 +15,7 @@ RUN apk add --no-cache --update openjdk11-jdk \ ## ## Runner ## -FROM alpine:3.18 as runner +FROM alpine:3.19 as runner ARG PKCS12_PASSWORD=changeme ARG PATH_TO_CERTS=/etc/routr/certs diff --git a/mods/edgeport/edgeport.sh b/mods/edgeport/edgeport.sh index 4a0f522c9..bffd45295 100755 --- a/mods/edgeport/edgeport.sh +++ b/mods/edgeport/edgeport.sh @@ -8,7 +8,6 @@ export HOME="$(cd "$(dirname "$0")"; pwd)" # TODO: Look into performance impact of not having runtime compilation context export JAVA_OPTS="-Dlog4j.configurationFile=${LOG4J2} \ -Dpolyglot.engine.WarnInterpreterOnly=false \ - -XX:CMSInitiatingOccupancyFraction=80 \ -Dsun.rmi.dgc.client.gcInterval=3600000 \ -Djava.net.preferIPv4Stack=true" diff --git a/mods/edgeport/graaljstest/config.ts b/mods/edgeport/graaljstest/config.ts index baf0f7395..299dd5a27 100644 --- a/mods/edgeport/graaljstest/config.ts +++ b/mods/edgeport/graaljstest/config.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/edgeport/graaljstest/config.unit.test.ts b/mods/edgeport/graaljstest/config.unit.test.ts index df6281a73..af1975268 100644 --- a/mods/edgeport/graaljstest/config.unit.test.ts +++ b/mods/edgeport/graaljstest/config.unit.test.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/edgeport/graaljstest/edgeport.unit.test.ts b/mods/edgeport/graaljstest/edgeport.unit.test.ts index 3fe1d9961..329347adb 100644 --- a/mods/edgeport/graaljstest/edgeport.unit.test.ts +++ b/mods/edgeport/graaljstest/edgeport.unit.test.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/edgeport/src/assertions.ts b/mods/edgeport/src/assertions.ts index 52cd8d112..ae797c9ed 100644 --- a/mods/edgeport/src/assertions.ts +++ b/mods/edgeport/src/assertions.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/edgeport/src/config/fs.ts b/mods/edgeport/src/config/fs.ts index aeebabadf..69d178224 100644 --- a/mods/edgeport/src/config/fs.ts +++ b/mods/edgeport/src/config/fs.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/edgeport/src/config/get_config.ts b/mods/edgeport/src/config/get_config.ts index 5ef941a14..6b25f90d5 100644 --- a/mods/edgeport/src/config/get_config.ts +++ b/mods/edgeport/src/config/get_config.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/edgeport/src/config/schema.ts b/mods/edgeport/src/config/schema.ts index 85da8eb72..5490cf10a 100644 --- a/mods/edgeport/src/config/schema.ts +++ b/mods/edgeport/src/config/schema.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/edgeport/src/create_listening_points.ts b/mods/edgeport/src/create_listening_points.ts index 93aaca359..22911eebe 100644 --- a/mods/edgeport/src/create_listening_points.ts +++ b/mods/edgeport/src/create_listening_points.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/edgeport/src/create_sip_provider.ts b/mods/edgeport/src/create_sip_provider.ts index 10b799427..e456a1a91 100644 --- a/mods/edgeport/src/create_sip_provider.ts +++ b/mods/edgeport/src/create_sip_provider.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/edgeport/src/create_sip_stack.ts b/mods/edgeport/src/create_sip_stack.ts index 6ee3d3f57..4f4c9369f 100644 --- a/mods/edgeport/src/create_sip_stack.ts +++ b/mods/edgeport/src/create_sip_stack.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/edgeport/src/edgeport.ts b/mods/edgeport/src/edgeport.ts index b56dff81a..7b2dbf337 100644 --- a/mods/edgeport/src/edgeport.ts +++ b/mods/edgeport/src/edgeport.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/edgeport/src/envs.ts b/mods/edgeport/src/envs.ts index ef9497f3a..5ba160aa9 100644 --- a/mods/edgeport/src/envs.ts +++ b/mods/edgeport/src/envs.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/edgeport/src/main/java/io/routr/GRPCSipListener.java b/mods/edgeport/src/main/java/io/routr/GRPCSipListener.java index 6146a1d0b..8c79d2633 100644 --- a/mods/edgeport/src/main/java/io/routr/GRPCSipListener.java +++ b/mods/edgeport/src/main/java/io/routr/GRPCSipListener.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/edgeport/src/main/java/io/routr/HangupCauses.java b/mods/edgeport/src/main/java/io/routr/HangupCauses.java index f28fb2e52..d6f31563c 100644 --- a/mods/edgeport/src/main/java/io/routr/HangupCauses.java +++ b/mods/edgeport/src/main/java/io/routr/HangupCauses.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/edgeport/src/main/java/io/routr/HealthCheck.java b/mods/edgeport/src/main/java/io/routr/HealthCheck.java index 5afb5fccd..a256b6deb 100644 --- a/mods/edgeport/src/main/java/io/routr/HealthCheck.java +++ b/mods/edgeport/src/main/java/io/routr/HealthCheck.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/edgeport/src/main/java/io/routr/Launcher.java b/mods/edgeport/src/main/java/io/routr/Launcher.java index a61b2f7f3..e4a15d7b3 100644 --- a/mods/edgeport/src/main/java/io/routr/Launcher.java +++ b/mods/edgeport/src/main/java/io/routr/Launcher.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr @@ -54,23 +54,6 @@ public static void main(String... args) { } public void launch() throws ScriptException { - String engine = System.getenv("JS_ENGINE"); - - if (engine != null && engine.equals("graal.js")) { - launchWithGraalJS(); - } else if (engine != null && engine.equals("nashorn")) { - launchWithNashorn(); - } else { - launchWithGraalJS(); - } - } - - public void launchWithNashorn() throws ScriptException { - ScriptEngine engine = new ScriptEngineManager().getEngineByName("nashorn"); - engine.eval(LAUNCH_SCRIPT); - } - - public void launchWithGraalJS() { Context polyglot = Context .newBuilder() .allowExperimentalOptions(true) diff --git a/mods/edgeport/src/main/java/io/routr/MapProxyObject.java b/mods/edgeport/src/main/java/io/routr/MapProxyObject.java index b770d1312..92f773a8e 100644 --- a/mods/edgeport/src/main/java/io/routr/MapProxyObject.java +++ b/mods/edgeport/src/main/java/io/routr/MapProxyObject.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/edgeport/src/main/java/io/routr/events/ConsolePublisher.java b/mods/edgeport/src/main/java/io/routr/events/ConsolePublisher.java index be4162939..ebd20b87f 100644 --- a/mods/edgeport/src/main/java/io/routr/events/ConsolePublisher.java +++ b/mods/edgeport/src/main/java/io/routr/events/ConsolePublisher.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/edgeport/src/main/java/io/routr/events/EventTypes.java b/mods/edgeport/src/main/java/io/routr/events/EventTypes.java index 08fd85e9a..be3a7c3fe 100644 --- a/mods/edgeport/src/main/java/io/routr/events/EventTypes.java +++ b/mods/edgeport/src/main/java/io/routr/events/EventTypes.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/edgeport/src/main/java/io/routr/events/EventsPublisher.java b/mods/edgeport/src/main/java/io/routr/events/EventsPublisher.java index cb1e64793..f25f0d579 100644 --- a/mods/edgeport/src/main/java/io/routr/events/EventsPublisher.java +++ b/mods/edgeport/src/main/java/io/routr/events/EventsPublisher.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/edgeport/src/main/java/io/routr/events/NATSPublisher.java b/mods/edgeport/src/main/java/io/routr/events/NATSPublisher.java index 526245ac4..1d4cf9340 100644 --- a/mods/edgeport/src/main/java/io/routr/events/NATSPublisher.java +++ b/mods/edgeport/src/main/java/io/routr/events/NATSPublisher.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/edgeport/src/main/java/io/routr/headers/AddressConverter.java b/mods/edgeport/src/main/java/io/routr/headers/AddressConverter.java index 6ce6d411e..4e52d3931 100644 --- a/mods/edgeport/src/main/java/io/routr/headers/AddressConverter.java +++ b/mods/edgeport/src/main/java/io/routr/headers/AddressConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/edgeport/src/main/java/io/routr/headers/AuthorizationConverter.java b/mods/edgeport/src/main/java/io/routr/headers/AuthorizationConverter.java index 3eecacce0..968d8b8aa 100644 --- a/mods/edgeport/src/main/java/io/routr/headers/AuthorizationConverter.java +++ b/mods/edgeport/src/main/java/io/routr/headers/AuthorizationConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/edgeport/src/main/java/io/routr/headers/CallIDConverter.java b/mods/edgeport/src/main/java/io/routr/headers/CallIDConverter.java index 94312f094..f3dfef13e 100644 --- a/mods/edgeport/src/main/java/io/routr/headers/CallIDConverter.java +++ b/mods/edgeport/src/main/java/io/routr/headers/CallIDConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/edgeport/src/main/java/io/routr/headers/ContactConverter.java b/mods/edgeport/src/main/java/io/routr/headers/ContactConverter.java index a8c849944..af6e0831f 100644 --- a/mods/edgeport/src/main/java/io/routr/headers/ContactConverter.java +++ b/mods/edgeport/src/main/java/io/routr/headers/ContactConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/edgeport/src/main/java/io/routr/headers/ContentLengthConverter.java b/mods/edgeport/src/main/java/io/routr/headers/ContentLengthConverter.java index 72d6cec61..90461a837 100644 --- a/mods/edgeport/src/main/java/io/routr/headers/ContentLengthConverter.java +++ b/mods/edgeport/src/main/java/io/routr/headers/ContentLengthConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/edgeport/src/main/java/io/routr/headers/Converter.java b/mods/edgeport/src/main/java/io/routr/headers/Converter.java index e61dd9c64..ace9fd30c 100644 --- a/mods/edgeport/src/main/java/io/routr/headers/Converter.java +++ b/mods/edgeport/src/main/java/io/routr/headers/Converter.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/edgeport/src/main/java/io/routr/headers/ExpiresConverter.java b/mods/edgeport/src/main/java/io/routr/headers/ExpiresConverter.java index d8185df76..b25600c4a 100644 --- a/mods/edgeport/src/main/java/io/routr/headers/ExpiresConverter.java +++ b/mods/edgeport/src/main/java/io/routr/headers/ExpiresConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/edgeport/src/main/java/io/routr/headers/ExtensionConverter.java b/mods/edgeport/src/main/java/io/routr/headers/ExtensionConverter.java index e8578e49e..69bcc5836 100644 --- a/mods/edgeport/src/main/java/io/routr/headers/ExtensionConverter.java +++ b/mods/edgeport/src/main/java/io/routr/headers/ExtensionConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/edgeport/src/main/java/io/routr/headers/FromConverter.java b/mods/edgeport/src/main/java/io/routr/headers/FromConverter.java index 93d4473bc..036bf6784 100644 --- a/mods/edgeport/src/main/java/io/routr/headers/FromConverter.java +++ b/mods/edgeport/src/main/java/io/routr/headers/FromConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/edgeport/src/main/java/io/routr/headers/MaxForwardsConverter.java b/mods/edgeport/src/main/java/io/routr/headers/MaxForwardsConverter.java index dc18895e8..1a43a07a5 100644 --- a/mods/edgeport/src/main/java/io/routr/headers/MaxForwardsConverter.java +++ b/mods/edgeport/src/main/java/io/routr/headers/MaxForwardsConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/edgeport/src/main/java/io/routr/headers/MessageConverter.java b/mods/edgeport/src/main/java/io/routr/headers/MessageConverter.java index 9f916c8cc..80c5cc209 100644 --- a/mods/edgeport/src/main/java/io/routr/headers/MessageConverter.java +++ b/mods/edgeport/src/main/java/io/routr/headers/MessageConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/edgeport/src/main/java/io/routr/headers/ProtoMapping.java b/mods/edgeport/src/main/java/io/routr/headers/ProtoMapping.java index fb7dc7421..8b3884535 100644 --- a/mods/edgeport/src/main/java/io/routr/headers/ProtoMapping.java +++ b/mods/edgeport/src/main/java/io/routr/headers/ProtoMapping.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/edgeport/src/main/java/io/routr/headers/RecordRouteConverter.java b/mods/edgeport/src/main/java/io/routr/headers/RecordRouteConverter.java index 502a86205..2ba03714a 100644 --- a/mods/edgeport/src/main/java/io/routr/headers/RecordRouteConverter.java +++ b/mods/edgeport/src/main/java/io/routr/headers/RecordRouteConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/edgeport/src/main/java/io/routr/headers/ResponseCode.java b/mods/edgeport/src/main/java/io/routr/headers/ResponseCode.java index 21f020401..585ff8e76 100644 --- a/mods/edgeport/src/main/java/io/routr/headers/ResponseCode.java +++ b/mods/edgeport/src/main/java/io/routr/headers/ResponseCode.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/edgeport/src/main/java/io/routr/headers/RouteConverter.java b/mods/edgeport/src/main/java/io/routr/headers/RouteConverter.java index 2e57cd687..d0dd9b348 100644 --- a/mods/edgeport/src/main/java/io/routr/headers/RouteConverter.java +++ b/mods/edgeport/src/main/java/io/routr/headers/RouteConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/edgeport/src/main/java/io/routr/headers/SipURIConverter.java b/mods/edgeport/src/main/java/io/routr/headers/SipURIConverter.java index fdc0e17d0..eff75db73 100644 --- a/mods/edgeport/src/main/java/io/routr/headers/SipURIConverter.java +++ b/mods/edgeport/src/main/java/io/routr/headers/SipURIConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/edgeport/src/main/java/io/routr/headers/ToConverter.java b/mods/edgeport/src/main/java/io/routr/headers/ToConverter.java index 7682748ea..4b18d07a1 100644 --- a/mods/edgeport/src/main/java/io/routr/headers/ToConverter.java +++ b/mods/edgeport/src/main/java/io/routr/headers/ToConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/edgeport/src/main/java/io/routr/headers/ViaConverter.java b/mods/edgeport/src/main/java/io/routr/headers/ViaConverter.java index 2bd4cf7b5..126d0ac35 100644 --- a/mods/edgeport/src/main/java/io/routr/headers/ViaConverter.java +++ b/mods/edgeport/src/main/java/io/routr/headers/ViaConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/edgeport/src/main/java/io/routr/headers/WWWAuthenticateConverter.java b/mods/edgeport/src/main/java/io/routr/headers/WWWAuthenticateConverter.java index b7926f678..a99aa0e47 100644 --- a/mods/edgeport/src/main/java/io/routr/headers/WWWAuthenticateConverter.java +++ b/mods/edgeport/src/main/java/io/routr/headers/WWWAuthenticateConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/edgeport/src/main/java/io/routr/utils/AccountManagerImpl.java b/mods/edgeport/src/main/java/io/routr/utils/AccountManagerImpl.java index 9e699c6b9..8a711b8b7 100644 --- a/mods/edgeport/src/main/java/io/routr/utils/AccountManagerImpl.java +++ b/mods/edgeport/src/main/java/io/routr/utils/AccountManagerImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/edgeport/src/main/java/io/routr/utils/UserCredentialsImpl.java b/mods/edgeport/src/main/java/io/routr/utils/UserCredentialsImpl.java index 54bb5d3b8..c6d1cde78 100644 --- a/mods/edgeport/src/main/java/io/routr/utils/UserCredentialsImpl.java +++ b/mods/edgeport/src/main/java/io/routr/utils/UserCredentialsImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/edgeport/src/runner.ts b/mods/edgeport/src/runner.ts index ef0a1ed60..2d38f211b 100644 --- a/mods/edgeport/src/runner.ts +++ b/mods/edgeport/src/runner.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/edgeport/src/server_properties.ts b/mods/edgeport/src/server_properties.ts index 2c5959851..657c1135e 100644 --- a/mods/edgeport/src/server_properties.ts +++ b/mods/edgeport/src/server_properties.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/edgeport/src/test/java/io/routr/ConverterTests.java b/mods/edgeport/src/test/java/io/routr/ConverterTests.java index cfeaa542d..295caf109 100644 --- a/mods/edgeport/src/test/java/io/routr/ConverterTests.java +++ b/mods/edgeport/src/test/java/io/routr/ConverterTests.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/edgeport/src/test/java/io/routr/ResponseCodeTests.java b/mods/edgeport/src/test/java/io/routr/ResponseCodeTests.java index dd049058f..6b08269cb 100644 --- a/mods/edgeport/src/test/java/io/routr/ResponseCodeTests.java +++ b/mods/edgeport/src/test/java/io/routr/ResponseCodeTests.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/edgeport/src/test/java/io/routr/UtilsTests.java b/mods/edgeport/src/test/java/io/routr/UtilsTests.java index 1bbf101f1..fe09fb001 100644 --- a/mods/edgeport/src/test/java/io/routr/UtilsTests.java +++ b/mods/edgeport/src/test/java/io/routr/UtilsTests.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/edgeport/src/tracer.ts b/mods/edgeport/src/tracer.ts index ac83e12cb..b10cd8145 100644 --- a/mods/edgeport/src/tracer.ts +++ b/mods/edgeport/src/tracer.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/edgeport/src/types.ts b/mods/edgeport/src/types.ts index 719a57847..d52d90d7c 100644 --- a/mods/edgeport/src/types.ts +++ b/mods/edgeport/src/types.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/location/Dockerfile b/mods/location/Dockerfile index 7cc928e0f..6b2f5d142 100644 --- a/mods/location/Dockerfile +++ b/mods/location/Dockerfile @@ -1,4 +1,4 @@ -FROM alpine:3.18 +FROM alpine:3.19 LABEL maintainer="Pedro Sanders " COPY . /scripts diff --git a/mods/location/src/client.ts b/mods/location/src/client.ts index ab9de8317..4e80e0afb 100644 --- a/mods/location/src/client.ts +++ b/mods/location/src/client.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr @@ -32,6 +32,8 @@ const container = (self: Location, request: RequestType, name: string) => { self.location[name](request, (err: { code: number }, response: unknown) => { if (err?.code === grpc.status.UNAVAILABLE) { return reject(new CE.ServiceUnavailableError(self.config.addr)) + } else if (err?.code) { + return reject(err) } resolve(response) }) @@ -67,9 +69,10 @@ export default class Location implements ILocationService { * @param {AddRouteRequest} request - Add route request * @param {string} request.aor - AOR of the route * @param {Route} request.route - Route to add + * @param {number} request.maxContacts - Max number of contacts to accept * @return {Promise} */ - public addRoute(request: AddRouteRequest): Promise { + public async addRoute(request: AddRouteRequest): Promise { return container( this, request, @@ -84,7 +87,7 @@ export default class Location implements ILocationService { * @param {string} request.aor - AOR of the route * @param {Map} request.labels - Optional Route labels (reserved for future use) * @param {object} request.backend - Optional Route backend (reserved for future use) - * @return {Promise} + * @return {Promise} */ public async findRoutes(request: FindRoutesRequest): Promise { return ( @@ -101,7 +104,7 @@ export default class Location implements ILocationService { * @param {string} request.aor - AOR of the route * @return {Promise} */ - public removeRoutes(request: RemoveRoutesRequest): Promise { + public async removeRoutes(request: RemoveRoutesRequest): Promise { return container( this, request, diff --git a/mods/location/src/config/get_config.ts b/mods/location/src/config/get_config.ts index 10cc27094..7ad47d39a 100644 --- a/mods/location/src/config/get_config.ts +++ b/mods/location/src/config/get_config.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/location/src/config/schema.ts b/mods/location/src/config/schema.ts index 3a9731cd3..5a2f0d5bd 100644 --- a/mods/location/src/config/schema.ts +++ b/mods/location/src/config/schema.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/location/src/envs.ts b/mods/location/src/envs.ts index 8b14d4e3e..198293780 100644 --- a/mods/location/src/envs.ts +++ b/mods/location/src/envs.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/location/src/errors.ts b/mods/location/src/errors.ts index d6393294e..92414e029 100644 --- a/mods/location/src/errors.ts +++ b/mods/location/src/errors.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/location/src/helper.ts b/mods/location/src/helper.ts index 893504a61..1c546c121 100644 --- a/mods/location/src/helper.ts +++ b/mods/location/src/helper.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr @@ -16,10 +16,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { MessageRequest, Route, Transport } from "@routr/common" -import { CommonTypes as CT } from "@routr/common" -import { Extensions as E, Target as T } from "@routr/processor" /* eslint-disable require-jsdoc */ +import { + MessageRequest, + Route, + Transport, + CommonTypes as CT +} from "@routr/common" +import { Extensions as E, Target as T } from "@routr/processor" // TODO: Before finalizing this, consider using the old approach of saving the rport // and received values (like here: diff --git a/mods/location/src/index.ts b/mods/location/src/index.ts index 3b768e7f3..63fd72674 100644 --- a/mods/location/src/index.ts +++ b/mods/location/src/index.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/location/src/location.ts b/mods/location/src/location.ts index 6da849af5..8fb4dd090 100644 --- a/mods/location/src/location.ts +++ b/mods/location/src/location.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr @@ -16,16 +16,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/* eslint-disable require-jsdoc */ import { UnsupportedSchema } from "./errors" +import { Route, CommonTypes as CT, CommonErrors as CE } from "@routr/common" import { AddRouteRequest, - Backend, FindRoutesRequest, ILocationService, ILocatorStore, RemoveRoutesRequest } from "./types" -import { Route, CommonTypes as CT } from "@routr/common" import { filterOnlyMatchingLabels } from "./utils" enum AOR_SCHEME { @@ -51,50 +51,84 @@ export default class Location implements ILocationService { } /** @inheritdoc */ - public addRoute(request: AddRouteRequest): Promise { + public async addRoute(request: AddRouteRequest): Promise { if ( !request.aor.startsWith(AOR_SCHEME.SIP) && !request.aor.startsWith(AOR_SCHEME.BACKEND) ) { throw new UnsupportedSchema(request.aor) } + + const existingRoutes = await this.store.get(request.aor) + const routeAlreadyExists = existingRoutes.some( + (route) => + route.user === request.route.user && + route.host === request.route.host && + route.port === request.route.port && + route.transport === request.route.transport + ) + + if ( + !routeAlreadyExists && + request.maxContacts !== -1 && + existingRoutes.length >= request.maxContacts + ) { + throw new CE.BadRequestError( + `exceeds maximum of ${request.maxContacts} allowed contacts` + ) + } return this.store.put(request.aor, request.route) } /** @inheritdoc */ public async findRoutes(request: FindRoutesRequest): Promise { - let routes = await this.store.get(`${request.aor}:${request.callId}`) + const formatLabels = (labelsMap: Map) => { + return Array.from(labelsMap) + .sort(([keyA], [keyB]) => keyA.localeCompare(keyB)) + .map(([key, value]) => `${key}=${value}`) + .join(";") + } + + const labelString = request.labels ? formatLabels(request.labels) : null + const storeKeyWithLabels = labelString + ? `${request.aor}:${request.callId}:${labelString}` + : `${request.aor}:${request.callId}` + + let routes = await this.store.get(storeKeyWithLabels) - if (routes.length > 0) { + if (routes && routes.length > 0) { return routes } - routes = request.labels - ? (await this.store.get(request.aor)).filter( + if (labelString) { + const storeKey = `${request.aor}:${request.callId}:${labelString}` + routes = await this.store.get(storeKey) + + if (!routes || routes.length === 0) { + routes = (await this.store.get(request.aor)).filter( filterOnlyMatchingLabels(request.labels) ) - : (await this.store.get(request.aor)) ?? [] + } + } else { + routes = (await this.store.get(request.aor)) ?? [] + } + + const { backend } = request - if (request.aor.startsWith(AOR_SCHEME.SIP)) { - // Set call to the last route + if (!backend) { this.store.put(`${request.aor}:${request.callId}`, routes[0]) return routes - } else if (request.aor.startsWith(AOR_SCHEME.BACKEND)) { - const { backend } = request + } - // If it has not affinity session then get next - const r = - // Falls back to round-robin if no session affinity ref is provided - backend.withSessionAffinity && request.sessionAffinityRef - ? [await this.nextWithAffinity(routes, request.sessionAffinityRef)] - : [this.next(routes, backend)] + // If it has no affinity session then get next + const r = + backend?.withSessionAffinity && request.sessionAffinityRef + ? [await this.nextWithAffinity(routes, request.sessionAffinityRef)] + : [this.next(routes, request)] - // Next time we will get the route with callId - this.store.put(`${request.aor}:${request.callId}`, r[0]) + this.store.put(storeKeyWithLabels, r[0]) - return r - } - throw new UnsupportedSchema(request.aor) + return r } /** @inheritdoc */ @@ -102,44 +136,42 @@ export default class Location implements ILocationService { return this.store.delete(request.aor) } - // eslint-disable-next-line require-jsdoc - private next(routes: Array, backend: Backend): Route { + private next(routes: Array, request: FindRoutesRequest): Route { + const { backend } = request + const ref = backend?.ref || request.aor if ( - backend.balancingAlgorithm === CT.LoadBalancingAlgorithm.LEAST_SESSIONS + backend?.balancingAlgorithm === CT.LoadBalancingAlgorithm.LEAST_SESSIONS ) { return routes.sort((r1, r2) => r1.sessionCount - r2.sessionCount)[0] } // Continues using round-robin - const nextPosition = - this.rrCount.get(`${AOR_SCHEME.BACKEND}${backend.ref}`) ?? 0 - + const nextPosition = this.rrCount.get(ref) ?? 0 const result = routes[nextPosition] if (nextPosition >= routes.length - 1) { // Restarting round-robin counter - this.rrCount.set(`${AOR_SCHEME.BACKEND}${backend.ref}`, 0) + this.rrCount.set(ref, 0) } else { - this.rrCount.set(`${AOR_SCHEME.BACKEND}${backend.ref}`, nextPosition + 1) + this.rrCount.set(ref, nextPosition + 1) } return result } // Backend with session affinity does not support round-robin - // eslint-disable-next-line require-jsdoc private async nextWithAffinity( routes: Array, - sessionAffinityHeader: string + sessionAffinityRef: string ): Promise { - const route = await this.store.get(sessionAffinityHeader) + const route = await this.store.get(sessionAffinityRef) if (route.length > 0) { return route[0] } const r = routes.sort((r1, r2) => r1.sessionCount - r2.sessionCount)[0] - this.store.put(sessionAffinityHeader, r) + this.store.put(sessionAffinityRef, r) return r } diff --git a/mods/location/src/memory_store.ts b/mods/location/src/memory_store.ts index 337cfc8e3..fc63b27d3 100644 --- a/mods/location/src/memory_store.ts +++ b/mods/location/src/memory_store.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/location/src/redis_store.ts b/mods/location/src/redis_store.ts index 8e688775b..209c38f25 100644 --- a/mods/location/src/redis_store.ts +++ b/mods/location/src/redis_store.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/location/src/runner.ts b/mods/location/src/runner.ts index 07ae7d57e..573242ef0 100644 --- a/mods/location/src/runner.ts +++ b/mods/location/src/runner.ts @@ -1,6 +1,6 @@ #!/usr/bin/env node /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/location/src/service.ts b/mods/location/src/service.ts index fcba44904..878fc1500 100644 --- a/mods/location/src/service.ts +++ b/mods/location/src/service.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/location/src/tracer.ts b/mods/location/src/tracer.ts index ac83e12cb..b10cd8145 100644 --- a/mods/location/src/tracer.ts +++ b/mods/location/src/tracer.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/location/src/types.ts b/mods/location/src/types.ts index a18f7cd71..288ce3c51 100644 --- a/mods/location/src/types.ts +++ b/mods/location/src/types.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr @@ -33,6 +33,7 @@ export interface ILocatorStore { export interface AddRouteRequest { aor: string route: Route + maxContacts: number } export interface FindRoutesRequest { @@ -53,7 +54,8 @@ export interface RemoveRoutesRequest { } export interface Backend { - ref: string + // Keep this for backward compatibility + ref?: string balancingAlgorithm: CT.LoadBalancingAlgorithm withSessionAffinity: boolean } diff --git a/mods/location/src/utils.ts b/mods/location/src/utils.ts index 56b0e3b90..9cd311378 100644 --- a/mods/location/src/utils.ts +++ b/mods/location/src/utils.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr @@ -29,7 +29,7 @@ export const expiredFilter = (r: Route) => r.expires - (Date.now() - r.registeredOn) / 1000 > 0 export const duplicateFilter = (r1: Route, r2: Route) => - !(r1.host === r2.host && r1.port === r2.port) + !(r1.host === r2.host && r1.port === r2.port && r1.transport === r2.transport) export const mergeKeyValue = (map: Map) => Array.from(map).map((l) => l[0] + l[1]) @@ -53,9 +53,9 @@ export const getServiceInfo = ( // eslint-disable-next-line @typescript-eslint/no-explicit-any service: (LOCATION_OBJECT_PROTO as any).Location.service, handlers: { - addRoute: (call: CT.GrpcCall, callback) => { + addRoute: async (call: CT.GrpcCall, callback) => { try { - locator.addRoute(call.request as AddRouteRequest) + await locator.addRoute(call.request as AddRouteRequest) callback(null, {}) } catch (e) { callback(e, null) @@ -66,11 +66,12 @@ export const getServiceInfo = ( const routes = await locator.findRoutes( call.request as FindRoutesRequest ) - if (routes.length === 0) + + if (routes.length === 0) { throw new NotRoutesFoundForAOR(call.request.aor) - callback(null, { - routes: routes - }) + } + + callback(null, { routes }) } catch (e) { callback(e, null) } diff --git a/mods/location/test/location.unit.test.ts b/mods/location/test/location.unit.test.ts index 4c61af579..66874be85 100644 --- a/mods/location/test/location.unit.test.ts +++ b/mods/location/test/location.unit.test.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr @@ -41,8 +41,16 @@ describe("@routr/location", () => { ["region", "us-east01"] ]) - locator.addRoute({ aor: "sip:1001@sip.local", route: Routes.simpleRoute01 }) - locator.addRoute({ aor: "sip:1001@sip.local", route: Routes.simpleRoute02 }) + await locator.addRoute({ + aor: "sip:1001@sip.local", + route: Routes.simpleRoute01, + maxContacts: -1 + }) + await locator.addRoute({ + aor: "sip:1001@sip.local", + route: Routes.simpleRoute02, + maxContacts: -1 + }) const findRoutesRequest1 = { callId: "3848276298220188511", @@ -59,49 +67,51 @@ describe("@routr/location", () => { labels: labels2 } - expect((await locator.findRoutes(findRoutesRequest1)).length).to.be.equal(2) - expect((await locator.findRoutes(findRoutesRequest1))[0]) - .to.have.property("user") - .to.be.equal("1001") - - expect((await locator.findRoutes(findRoutesRequest2)).length).to.be.equal(1) - expect((await locator.findRoutes(findRoutesRequest2))[0]) - .to.have.property("user") - .to.be.equal("1001") + const result1 = await locator.findRoutes(findRoutesRequest1) + const result2 = await locator.findRoutes(findRoutesRequest2) + const result3 = await locator.findRoutes(findRoutesRequest3) - expect((await locator.findRoutes(findRoutesRequest3)).length).to.be.equal(0) + expect(result1.length).to.be.equal(2) + expect(result1[0]).to.have.property("user").to.be.equal("1001") + expect(result2.length).to.be.equal(1) + expect(result2[0]).to.have.property("user").to.be.equal("1001") + expect(result3.length).to.be.equal(0) }) it("find next backend using least-sessions", async () => { const locator = new Locator(new MemoryStore()) - locator.addRoute({ - aor: "backend:voice_ls", - route: Routes.voiceBackendRoute01 + await locator.addRoute({ + aor: "sip:voice_ls@sip.local", + route: Routes.voiceBackendRoute01, + maxContacts: -1 }) - locator.addRoute({ - aor: "backend:voice_ls", - route: Routes.voiceBackendRoute02 + await locator.addRoute({ + aor: "sip:voice_ls@sip.local", + route: Routes.voiceBackendRoute02, + maxContacts: -1 }) - locator.addRoute({ - aor: "backend:voice_ls", - route: Routes.voiceBackendRoute03 + await locator.addRoute({ + aor: "sip:voice_ls@sip.local", + route: Routes.voiceBackendRoute03, + maxContacts: -1 }) - locator.addRoute({ - aor: "backend:voice_ls", - route: Routes.voiceBackendRoute04 + await locator.addRoute({ + aor: "sip:voice_ls@sip.local", + route: Routes.voiceBackendRoute04, + maxContacts: -1 }) - locator.addRoute({ - aor: "backend:voice_ls", - route: Routes.voiceBackendRoute05 + await locator.addRoute({ + aor: "sip:voice_ls@sip.local", + route: Routes.voiceBackendRoute05, + maxContacts: -1 }) const findRoutesRequest1: FindRoutesRequest = { callId: "3848276298220188511", - aor: "backend:voice_ls", + aor: "sip:voice_ls@sip.local", backend: { withSessionAffinity: true, - balancingAlgorithm: CT.LoadBalancingAlgorithm.LEAST_SESSIONS, - ref: "voice_ls" + balancingAlgorithm: CT.LoadBalancingAlgorithm.LEAST_SESSIONS } } @@ -112,88 +122,86 @@ describe("@routr/location", () => { it("find next backend using round-robin", async () => { const locator = new Locator(new MemoryStore()) - locator.addRoute({ - aor: "backend:voice_rr", - route: Routes.voiceBackendRoute05 + await locator.addRoute({ + aor: "sip:voice_rr@sip.local", + route: Routes.voiceBackendRoute05, + maxContacts: -1 }) - locator.addRoute({ - aor: "backend:voice_rr", - route: Routes.voiceBackendRoute04 + await locator.addRoute({ + aor: "sip:voice_rr@sip.local", + route: Routes.voiceBackendRoute04, + maxContacts: -1 }) - locator.addRoute({ - aor: "backend:voice_rr", - route: Routes.voiceBackendRoute03 + await locator.addRoute({ + aor: "sip:voice_rr@sip.local", + route: Routes.voiceBackendRoute03, + maxContacts: -1 }) - locator.addRoute({ - aor: "backend:voice_rr", - route: Routes.voiceBackendRoute02 + await locator.addRoute({ + aor: "sip:voice_rr@sip.local", + route: Routes.voiceBackendRoute02, + maxContacts: -1 }) - locator.addRoute({ - aor: "backend:voice_rr", - route: Routes.voiceBackendRoute01 + await locator.addRoute({ + aor: "sip:voice_rr@sip.local", + route: Routes.voiceBackendRoute01, + maxContacts: -1 }) const findRoutesRequest1 = { callId: "01", - aor: "backend:voice_rr", + aor: "sip:voice_rr@sip.local", backend: { withSessionAffinity: false, - balancingAlgorithm: CT.LoadBalancingAlgorithm.ROUND_ROBIN, - ref: "voice_rr" + balancingAlgorithm: CT.LoadBalancingAlgorithm.ROUND_ROBIN } } const findRoutesRequest2 = { callId: "02", - aor: "backend:voice_rr", + aor: "sip:voice_rr@sip.local", backend: { withSessionAffinity: false, - balancingAlgorithm: CT.LoadBalancingAlgorithm.ROUND_ROBIN, - ref: "voice_rr" + balancingAlgorithm: CT.LoadBalancingAlgorithm.ROUND_ROBIN } } const findRoutesRequest3 = { callId: "03", - aor: "backend:voice_rr", + aor: "sip:voice_rr@sip.local", backend: { withSessionAffinity: false, - balancingAlgorithm: CT.LoadBalancingAlgorithm.ROUND_ROBIN, - ref: "voice_rr" + balancingAlgorithm: CT.LoadBalancingAlgorithm.ROUND_ROBIN } } const findRoutesRequest4 = { callId: "04", - aor: "backend:voice_rr", + aor: "sip:voice_rr@sip.local", backend: { withSessionAffinity: false, - balancingAlgorithm: CT.LoadBalancingAlgorithm.ROUND_ROBIN, - ref: "voice_rr" + balancingAlgorithm: CT.LoadBalancingAlgorithm.ROUND_ROBIN } } const findRoutesRequest5 = { callId: "05", - aor: "backend:voice_rr", + aor: "sip:voice_rr@sip.local", backend: { withSessionAffinity: false, - balancingAlgorithm: CT.LoadBalancingAlgorithm.ROUND_ROBIN, - ref: "voice_rr" + balancingAlgorithm: CT.LoadBalancingAlgorithm.ROUND_ROBIN } } const findRoutesRequest6 = { callId: "06", - aor: "backend:voice_rr", + aor: "sip:voice_rr@sip.local", backend: { withSessionAffinity: false, - balancingAlgorithm: CT.LoadBalancingAlgorithm.ROUND_ROBIN, - ref: "voice_rr" + balancingAlgorithm: CT.LoadBalancingAlgorithm.ROUND_ROBIN } } const findRoutesRequest7 = { callId: "07", - aor: "backend:voice_rr", + aor: "sip:voice_rr@sip.local", backend: { withSessionAffinity: false, - balancingAlgorithm: CT.LoadBalancingAlgorithm.ROUND_ROBIN, - ref: "voice_rr" + balancingAlgorithm: CT.LoadBalancingAlgorithm.ROUND_ROBIN } } @@ -227,38 +235,39 @@ describe("@routr/location", () => { it("find next backend with session affinity enabled", async () => { const locator = new Locator(new MemoryStore()) - locator.addRoute({ - aor: "backend:conference", - route: Routes.conferenceWithExpiredRoute + await locator.addRoute({ + aor: "sip:conference@sip.local", + route: Routes.conferenceWithExpiredRoute, + maxContacts: -1 }) - locator.addRoute({ - aor: "backend:conference", - route: Routes.conferenceBackendRoute02 + await locator.addRoute({ + aor: "sip:conference@sip.local", + route: Routes.conferenceBackendRoute02, + maxContacts: -1 }) - locator.addRoute({ - aor: "backend:conference", - route: Routes.conferenceBackendRoute01 + await locator.addRoute({ + aor: "sip:conference@sip.local", + route: Routes.conferenceBackendRoute01, + maxContacts: -1 }) const findRoutesRequest1 = { callId: "3848276298220188511", - aor: "backend:conference", + aor: "sip:conference@sip.local", sessionAffinityRef: "any-session-affinity-ref", backend: { withSessionAffinity: true, - balancingAlgorithm: CT.LoadBalancingAlgorithm.LEAST_SESSIONS, - ref: "conference" + balancingAlgorithm: CT.LoadBalancingAlgorithm.LEAST_SESSIONS } } const findRoutesRequest2 = { callId: "any-call-id", - aor: "backend:conference", + aor: "sip:conference@sip.local", sessionAffinityRef: "any-session-affinity-ref", backend: { withSessionAffinity: true, - balancingAlgorithm: CT.LoadBalancingAlgorithm.LEAST_SESSIONS, - ref: "conference" + balancingAlgorithm: CT.LoadBalancingAlgorithm.LEAST_SESSIONS } } @@ -270,6 +279,109 @@ describe("@routr/location", () => { .to.be.equal("conference01") }) + it("checks if maxContacts has been reached (passing a different route)", async () => { + const locator = new Locator(new MemoryStore()) + await locator.addRoute({ + aor: "sip:voice@sip.local", + route: Routes.voiceBackendRoute01, + maxContacts: 1 + }) + + try { + await locator.addRoute({ + aor: "sip:voice@sip.local", + route: Routes.voiceBackendRoute02, + maxContacts: 1 + }) + throw new Error("Test failed - no error thrown") + } catch (error) { + expect(error.message).to.equal("exceeds maximum of 1 allowed contacts") + } + }) + + it("checks if maxContacts has been reached (passing the same route)", async () => { + const locator = new Locator(new MemoryStore()) + await locator.addRoute({ + aor: "sip:voice@sip.local", + route: Routes.voiceBackendRoute01, + maxContacts: 1 + }) + + // It should not throw an error since it is the same route + await locator.addRoute({ + aor: "sip:voice@sip.local", + route: Routes.voiceBackendRoute01, + maxContacts: 1 + }) + + try { + await locator.addRoute({ + aor: "sip:voice@sip.local", + route: Routes.voiceBackendRoute02, + maxContacts: 1 + }) + throw new Error("Test failed - no error thrown") + } catch (error) { + expect(error.message).to.equal("exceeds maximum of 1 allowed contacts") + } + }) + + it("checks if maxContacts has been reached (combining routes)", async () => { + const locator = new Locator(new MemoryStore()) + await locator.addRoute({ + aor: "sip:voice@sip.local", + route: Routes.voiceBackendRoute01, + maxContacts: 2 + }) + + await locator.addRoute({ + aor: "sip:voice@sip.local", + route: Routes.voiceBackendRoute01, + maxContacts: 2 + }) + + // It should not throw an error since two of the routes are the same + await locator.addRoute({ + aor: "sip:voice@sip.local", + route: Routes.voiceBackendRoute02, + maxContacts: 2 + }) + + try { + await locator.addRoute({ + aor: "sip:voice@sip.local", + route: Routes.voiceBackendRoute03, + maxContacts: 1 + }) + throw new Error("Test failed - no error thrown") + } catch (error) { + expect(error.message).to.equal("exceeds maximum of 1 allowed contacts") + } + }) + + it("find next backend using deprecated 'backend:' schema", async () => { + const locator = new Locator(new MemoryStore()) + await locator.addRoute({ + aor: "backend:voice_ls", + route: Routes.voiceBackendRoute01, + maxContacts: 1 + }) + + const findRoutesRequest1 = { + callId: "3848276298220188511", + aor: "backend:voice_ls", + backend: { + withSessionAffinity: true, + balancingAlgorithm: CT.LoadBalancingAlgorithm.LEAST_SESSIONS, + ref: "voice_ls" + } + } + + expect((await locator.findRoutes(findRoutesRequest1))[0]) + .to.be.have.property("user") + .to.be.equal("voice01") + }) + it("gets configuration from file", (done) => { const result = getConfig(__dirname + "/../../../config/location.yaml") if (result._tag === "Right") { diff --git a/mods/location/test/memory_store.unit.test.ts b/mods/location/test/memory_store.unit.test.ts index adb9a7634..fc91913d0 100644 --- a/mods/location/test/memory_store.unit.test.ts +++ b/mods/location/test/memory_store.unit.test.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr @@ -31,34 +31,34 @@ describe("@routr/location/memory_store", () => { it("puts value in a collection", async () => { const store = new MemoryStore() - store.put("backend:voice", Routes.voiceBackendRoute01) - store.put("backend:voice", Routes.voiceBackendRoute02) - store.put("backend:voice", Routes.voiceBackendRoute02) - store.put("backend:conference", Routes.conferenceBackendRoute01) - store.put("backend:conference", Routes.conferenceBackendRoute01) + store.put("sip:voice@sip.local", Routes.voiceBackendRoute01) + store.put("sip:voice@sip.local", Routes.voiceBackendRoute02) + store.put("sip:voice@sip.local", Routes.voiceBackendRoute02) + store.put("sip:conference@sip.local", Routes.conferenceBackendRoute01) + store.put("sip:conference@sip.local", Routes.conferenceBackendRoute01) expect(store.size()).to.be.equal(2) - expect((await store.get("backend:voice")).length).to.be.equal(2) - expect((await store.get("backend:conference")).length).to.be.equal(1) + expect((await store.get("sip:voice@sip.local")).length).to.be.equal(2) + expect((await store.get("sip:conference@sip.local")).length).to.be.equal(1) }) it("test removing all routes for an aor", async () => { const store = new MemoryStore() - store.put("backend:voice", Routes.voiceBackendRoute01) - store.put("backend:voice", Routes.voiceBackendRoute02) - store.put("backend:voice", Routes.voiceBackendRoute02) - await store.delete("backend:voice") - expect(await store.get("backend:voice")).to.be.empty + store.put("sip:voice@sip.local", Routes.voiceBackendRoute01) + store.put("sip:voice@sip.local", Routes.voiceBackendRoute02) + store.put("sip:voice@sip.local", Routes.voiceBackendRoute02) + await store.delete("sip:voice@sip.local") + expect(await store.get("sip:voice@sip.local")).to.be.empty }) it("sets an expire route and clean the collection", async () => { const store = new MemoryStore() - store.put("backend:voice", Routes.voiceBackendRoute01) - store.put("backend:voice", Routes.voiceBackendRoute02) - store.put("backend:voice", Routes.voiceBackendRoute02) - store.put("backend:conference", Routes.conferenceBackendRoute01) - store.put("backend:conference", Routes.conferenceWithExpiredRoute) + store.put("sip:voice@sip.local", Routes.voiceBackendRoute01) + store.put("sip:voice@sip.local", Routes.voiceBackendRoute02) + store.put("sip:voice@sip.local", Routes.voiceBackendRoute02) + store.put("sip:conference@sip.local", Routes.conferenceBackendRoute01) + store.put("sip:conference@sip.local", Routes.conferenceWithExpiredRoute) store.cleanup() expect(store.size()).to.be.equal(2) - expect((await store.get("backend:conference")).length).to.be.equal(1) + expect((await store.get("sip:conference@sip.local")).length).to.be.equal(1) }) }) diff --git a/mods/location/test/redis_store.int.test.ts b/mods/location/test/redis_store.int.test.ts index dc85aa589..9c4aa8376 100644 --- a/mods/location/test/redis_store.int.test.ts +++ b/mods/location/test/redis_store.int.test.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr @@ -31,36 +31,36 @@ describe("@routr/location/redis_store", () => { it("puts value in a collection", async () => { const store = new RedisStore() - store.put("backend:voice", Routes.voiceBackendRoute01) - store.put("backend:voice", Routes.voiceBackendRoute02) - store.put("backend:voice", Routes.voiceBackendRoute02) - store.put("backend:conference", Routes.conferenceBackendRoute01) - store.put("backend:conference", Routes.conferenceBackendRoute01) - expect((await store.get("backend:voice")).length).to.be.equal(2) - expect((await store.get("backend:conference")).length).to.be.equal(1) - expect((await store.get("backend:voice"))[0]) + store.put("sip:voice@sip.local", Routes.voiceBackendRoute01) + store.put("sip:voice@sip.local", Routes.voiceBackendRoute02) + store.put("sip:voice@sip.local", Routes.voiceBackendRoute02) + store.put("sip:conference@sip.local", Routes.conferenceBackendRoute01) + store.put("sip:conference@sip.local", Routes.conferenceBackendRoute01) + expect((await store.get("sip:voice@sip.local")).length).to.be.equal(2) + expect((await store.get("sip:conference@sip.local")).length).to.be.equal(1) + expect((await store.get("sip:voice@sip.local"))[0]) .to.be.have.property("user") .to.be.equal("voice02") }) it("test removing all routes for an aor", async () => { const store = new RedisStore() - await store.delete("backend:voice") - store.put("backend:voice", Routes.voiceBackendRoute01) - store.put("backend:voice", Routes.voiceBackendRoute02) - store.put("backend:voice", Routes.voiceBackendRoute02) - await store.delete("backend:voice") - expect(await store.get("backend:voice")).to.be.empty + await store.delete("sip:voice@sip.local") + store.put("sip:voice@sip.local", Routes.voiceBackendRoute01) + store.put("sip:voice@sip.local", Routes.voiceBackendRoute02) + store.put("sip:voice@sip.local", Routes.voiceBackendRoute02) + await store.delete("sip:voice@sip.local") + expect(await store.get("sip:voice@sip.local")).to.be.empty }) it("sets an expire route and clean the collection", async () => { const store = new RedisStore() - await store.delete("backend:voice") - await store.delete("backend:conference") - store.put("backend:voice", Routes.voiceBackendRoute01) - store.put("backend:voice", Routes.voiceBackendRoute02) - store.put("backend:voice", Routes.voiceBackendRoute02) - store.put("backend:conference", Routes.conferenceBackendRoute01) - expect((await store.get("backend:conference")).length).to.be.equal(1) + await store.delete("sip:voice@sip.local") + await store.delete("sip:conference@sip.local") + store.put("sip:voice@sip.local", Routes.voiceBackendRoute01) + store.put("sip:voice@sip.local", Routes.voiceBackendRoute02) + store.put("sip:voice@sip.local", Routes.voiceBackendRoute02) + store.put("sip:conference@sip.local", Routes.conferenceBackendRoute01) + expect((await store.get("sip:conference@sip.local")).length).to.be.equal(1) }) }) diff --git a/mods/location/test/route_examples.ts b/mods/location/test/route_examples.ts index a3ed07eb5..6ef803125 100644 --- a/mods/location/test/route_examples.ts +++ b/mods/location/test/route_examples.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/location/test/utils.unit.test.ts b/mods/location/test/utils.unit.test.ts index c0a77d437..2b31de0ae 100644 --- a/mods/location/test/utils.unit.test.ts +++ b/mods/location/test/utils.unit.test.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/one/src/configs.ts b/mods/one/src/configs.ts index abef4ab57..43d3b3dc7 100644 --- a/mods/one/src/configs.ts +++ b/mods/one/src/configs.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/one/src/envs.ts b/mods/one/src/envs.ts index 13fa161e5..98f10d021 100644 --- a/mods/one/src/envs.ts +++ b/mods/one/src/envs.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/one/src/runner.ts b/mods/one/src/runner.ts index 1ceb53020..222a63a70 100644 --- a/mods/one/src/runner.ts +++ b/mods/one/src/runner.ts @@ -1,6 +1,6 @@ #!/usr/bin/env node /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. @@ -61,6 +61,10 @@ edgeportProcess.stdout.on("data", (data) => { process.stdout.write(`${data}`) }) +edgeportProcess.stderr.on("data", (data) => { + process.stderr.write(`${data}`) +}) + edgeportProcess.on("error", (err) => { logger.error(`failed to spawn edgeport process: ${err}`) process.exit(1) diff --git a/mods/one/src/tracer.ts b/mods/one/src/tracer.ts index ac83e12cb..b10cd8145 100644 --- a/mods/one/src/tracer.ts +++ b/mods/one/src/tracer.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/one/test/one.unit.test.ts b/mods/one/test/one.unit.test.ts index 65b12cc35..a89d0fc8f 100644 --- a/mods/one/test/one.unit.test.ts +++ b/mods/one/test/one.unit.test.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/pgdata/Dockerfile b/mods/pgdata/Dockerfile index 7dcb603a4..cea3fd051 100644 --- a/mods/pgdata/Dockerfile +++ b/mods/pgdata/Dockerfile @@ -1,7 +1,7 @@ ## ## Runner ## -FROM alpine:3.18 as runner +FROM alpine:3.19 as runner LABEL maintainer="Pedro Sanders " ARG CA_CERT_SUBJECT="/CN=Self Signed CA" diff --git a/mods/pgdata/schema.prisma b/mods/pgdata/schema.prisma index d4b42e4fe..a94c7acc8 100644 --- a/mods/pgdata/schema.prisma +++ b/mods/pgdata/schema.prisma @@ -25,6 +25,8 @@ model Agent { name String @db.VarChar(60) username String @unique @db.VarChar(60) privacy Privacy @default(NONE) + maxContacts Int @map("max_contacts") @default(-1) + expires Int enabled Boolean @default(true) createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(3) updatedAt DateTime @updatedAt @map("updated_at") @db.Timestamptz(3) @@ -50,6 +52,8 @@ model Peer { contactAddr String? @map("contact_addr") @db.VarChar(20) balancingAlgorithm LoadBalancingAlgorithm? @map("balancing_algorithm") withSessionAffinity Boolean @default(false) @map("with_session_affinity") + maxContacts Int @map("max_contacts") @default(-1) + expires Int enabled Boolean @default(true) createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(3) updatedAt DateTime @updatedAt @map("updated_at") @db.Timestamptz(3) diff --git a/mods/pgdata/src/api/create.ts b/mods/pgdata/src/api/create.ts index 20ba4a0d9..69d78c993 100644 --- a/mods/pgdata/src/api/create.ts +++ b/mods/pgdata/src/api/create.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/pgdata/src/api/delete.ts b/mods/pgdata/src/api/delete.ts index c2ff4c6e1..c457c1452 100644 --- a/mods/pgdata/src/api/delete.ts +++ b/mods/pgdata/src/api/delete.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr @@ -22,7 +22,6 @@ import { PrismaClientInitializationError } from "@prisma/client/runtime/library" import { CommonTypes as CT, CommonErrors as CE } from "@routr/common" import { PrismaOperation } from "../types" -// TODO: Fix the error handling. We should return the error export function del(operation: PrismaOperation) { return async (call: CT.GrpcCall, callback: CT.GrpcCallback) => { if (!call.request.ref) { diff --git a/mods/pgdata/src/api/find.ts b/mods/pgdata/src/api/find.ts index 14ea517b5..bd5dfa4c9 100644 --- a/mods/pgdata/src/api/find.ts +++ b/mods/pgdata/src/api/find.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/pgdata/src/api/get.ts b/mods/pgdata/src/api/get.ts index 988e51bd3..c37cd649f 100644 --- a/mods/pgdata/src/api/get.ts +++ b/mods/pgdata/src/api/get.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/pgdata/src/api/index.ts b/mods/pgdata/src/api/index.ts index 58abe04ca..e7bbf249c 100644 --- a/mods/pgdata/src/api/index.ts +++ b/mods/pgdata/src/api/index.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/pgdata/src/api/list.ts b/mods/pgdata/src/api/list.ts index 5a4ca31a6..5b10ff7b8 100644 --- a/mods/pgdata/src/api/list.ts +++ b/mods/pgdata/src/api/list.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/pgdata/src/api/update.ts b/mods/pgdata/src/api/update.ts index 6729e859c..25205e0c1 100644 --- a/mods/pgdata/src/api/update.ts +++ b/mods/pgdata/src/api/update.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/pgdata/src/envs.ts b/mods/pgdata/src/envs.ts index 5394ae16a..872b1332b 100644 --- a/mods/pgdata/src/envs.ts +++ b/mods/pgdata/src/envs.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/pgdata/src/index.ts b/mods/pgdata/src/index.ts index d02883bc4..2c097233c 100644 --- a/mods/pgdata/src/index.ts +++ b/mods/pgdata/src/index.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/pgdata/src/mappers/acl.ts b/mods/pgdata/src/mappers/acl.ts index 1e1ef89f1..20a988664 100644 --- a/mods/pgdata/src/mappers/acl.ts +++ b/mods/pgdata/src/mappers/acl.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/pgdata/src/mappers/agent.ts b/mods/pgdata/src/mappers/agent.ts index e255c2d46..024978625 100644 --- a/mods/pgdata/src/mappers/agent.ts +++ b/mods/pgdata/src/mappers/agent.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. @@ -87,6 +87,8 @@ export class AgentManager extends EntityManager { updatedAt: this.agent.updatedAt ? new Date(this.agent.updatedAt * 1000) : undefined, + maxContacts: this.agent.maxContacts, + expires: this.agent.expires, extended: this.agent.extended || {} } } @@ -104,6 +106,8 @@ export class AgentManager extends EntityManager { credentialsRef: agent.credentialsRef, domain: DomainManager.mapToDto(agent.domain), credentials: CredentialsManager.mapToDto(agent.credentials), + maxContacts: agent.maxContacts, + expires: agent.expires, extended: (agent.extended || {}) as JsonObject, createdAt: agent.createdAt.getTime() / 1000, updatedAt: agent.updatedAt.getTime() / 1000 diff --git a/mods/pgdata/src/mappers/credentials.ts b/mods/pgdata/src/mappers/credentials.ts index 6daf9d17e..336d623f7 100644 --- a/mods/pgdata/src/mappers/credentials.ts +++ b/mods/pgdata/src/mappers/credentials.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/pgdata/src/mappers/domain.ts b/mods/pgdata/src/mappers/domain.ts index 4c49971fa..eed0ee3fc 100644 --- a/mods/pgdata/src/mappers/domain.ts +++ b/mods/pgdata/src/mappers/domain.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/pgdata/src/mappers/manager.ts b/mods/pgdata/src/mappers/manager.ts index 1cf647673..479e64731 100644 --- a/mods/pgdata/src/mappers/manager.ts +++ b/mods/pgdata/src/mappers/manager.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. @@ -16,12 +16,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/* eslint-disable require-jsdoc */ import { JsonObject } from "pb-util/build" -/* eslint-disable require-jsdoc */ export abstract class EntityManager { - static includeFields: () => JsonObject + static readonly includeFields: () => JsonObject abstract validOrThrowCreate(): void abstract validOrThrowUpdate(): void - // abstract mapToPrisma(): T } diff --git a/mods/pgdata/src/mappers/number.ts b/mods/pgdata/src/mappers/number.ts index 74396c01b..9cce42bff 100644 --- a/mods/pgdata/src/mappers/number.ts +++ b/mods/pgdata/src/mappers/number.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/pgdata/src/mappers/peer.ts b/mods/pgdata/src/mappers/peer.ts index a49339bc0..2f04b7a98 100644 --- a/mods/pgdata/src/mappers/peer.ts +++ b/mods/pgdata/src/mappers/peer.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. @@ -52,10 +52,6 @@ export class PeerManager extends EntityManager { CC.hasAOROrThrow(this.peer.aor) CC.isValidAOROrThrow(this.peer.aor) CC.isValidContactAddressOrThrow(this.peer.contactAddr) - CC.isValidBalancingAlgorithmOrThrow( - this.peer.aor, - this.peer.balancingAlgorithm - ) } validOrThrowUpdate() { @@ -64,10 +60,6 @@ export class PeerManager extends EntityManager { CC.isValidUsernameOrThrow(this.peer.username) CC.isValidAOROrThrow(this.peer.aor) CC.isValidContactAddressOrThrow(this.peer.contactAddr) - CC.isValidBalancingAlgorithmOrThrow( - this.peer.aor, - this.peer.balancingAlgorithm - ) } mapToPrisma(): PeerPrismaModel { @@ -95,6 +87,8 @@ export class PeerManager extends EntityManager { updatedAt: this.peer.updatedAt ? new Date(this.peer.updatedAt * 1000) : undefined, + maxContacts: this.peer.maxContacts, + expires: this.peer.expires, extended: this.peer.extended || {} } } @@ -118,6 +112,8 @@ export class PeerManager extends EntityManager { accessControlList: ACLManager.mapToDto(peer.accessControlList), createdAt: peer.createdAt.getTime() / 1000, updatedAt: peer.updatedAt.getTime() / 1000, + maxContacts: peer.maxContacts, + expires: peer.expires, extended: peer.extended as JsonObject } : undefined diff --git a/mods/pgdata/src/mappers/trunk.ts b/mods/pgdata/src/mappers/trunk.ts index f36a1c9cf..a64fdcdca 100644 --- a/mods/pgdata/src/mappers/trunk.ts +++ b/mods/pgdata/src/mappers/trunk.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/pgdata/src/mappers/utils.ts b/mods/pgdata/src/mappers/utils.ts index 04e964a63..3d39ff1da 100644 --- a/mods/pgdata/src/mappers/utils.ts +++ b/mods/pgdata/src/mappers/utils.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/pgdata/src/runner.ts b/mods/pgdata/src/runner.ts index d33832742..6c2e0f031 100644 --- a/mods/pgdata/src/runner.ts +++ b/mods/pgdata/src/runner.ts @@ -1,6 +1,6 @@ #!/usr/bin/env node /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/pgdata/src/service.ts b/mods/pgdata/src/service.ts index b61f9d036..9137d37af 100644 --- a/mods/pgdata/src/service.ts +++ b/mods/pgdata/src/service.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/pgdata/src/tracer.ts b/mods/pgdata/src/tracer.ts index 9b7d7c976..178e7df23 100644 --- a/mods/pgdata/src/tracer.ts +++ b/mods/pgdata/src/tracer.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/pgdata/src/types.ts b/mods/pgdata/src/types.ts index be51ede76..9c88bbff5 100644 --- a/mods/pgdata/src/types.ts +++ b/mods/pgdata/src/types.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/pgdata/test/acl.mapper.unit.test.ts b/mods/pgdata/test/acl.mapper.unit.test.ts index 02c07237c..40e3c2184 100644 --- a/mods/pgdata/test/acl.mapper.unit.test.ts +++ b/mods/pgdata/test/acl.mapper.unit.test.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/pgdata/test/agent.mapper.unit.test.ts b/mods/pgdata/test/agent.mapper.unit.test.ts index e9ee87e2b..61516974b 100644 --- a/mods/pgdata/test/agent.mapper.unit.test.ts +++ b/mods/pgdata/test/agent.mapper.unit.test.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr @@ -46,6 +46,8 @@ describe("@routr/pgdata/mappers/agent", () => { extended: { test: "test" }, + maxContacts: 1, + expires: 3600, createdAt: new Date().getTime() / 1000, updatedAt: new Date().getTime() / 1000 } @@ -85,6 +87,8 @@ describe("@routr/pgdata/mappers/agent", () => { }, createdAt: new Date(), updatedAt: new Date(), + maxContacts: 1, + expires: 3600, domain: { apiVersion: "v2" as APIVersion, ref: "domain-01", @@ -145,6 +149,7 @@ describe("@routr/pgdata/mappers/agent", () => { enabled: true, domainRef: "domain-01", credentialsRef: "credentials-01", + maxContacts: -1, extended: { test: "test" }, @@ -172,6 +177,7 @@ describe("@routr/pgdata/mappers/agent", () => { enabled: true, domainRef: "domain-01", credentialsRef: "credentials-01", + maxContacts: -1, extended: { test: "test" }, @@ -203,6 +209,7 @@ describe("@routr/pgdata/mappers/agent", () => { enabled: true, domainRef: "domain-01", credentialsRef: "credentials-01", + maxContacts: -1, extended: { test: "test" }, @@ -228,6 +235,7 @@ describe("@routr/pgdata/mappers/agent", () => { enabled: true, domainRef: "domain-01", credentialsRef: "credentials-01", + maxContacts: -1, extended: { test: "test" }, @@ -253,6 +261,7 @@ describe("@routr/pgdata/mappers/agent", () => { enabled: true, domainRef: "domain-01", credentialsRef: "credentials-01", + maxContacts: -1, extended: { test: "test" }, diff --git a/mods/pgdata/test/credentials.mapper.unit.test.ts b/mods/pgdata/test/credentials.mapper.unit.test.ts index c2072c3f1..720df7deb 100644 --- a/mods/pgdata/test/credentials.mapper.unit.test.ts +++ b/mods/pgdata/test/credentials.mapper.unit.test.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/pgdata/test/domain.mapper.unit.test.ts b/mods/pgdata/test/domain.mapper.unit.test.ts index fd831c12a..553375de8 100644 --- a/mods/pgdata/test/domain.mapper.unit.test.ts +++ b/mods/pgdata/test/domain.mapper.unit.test.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/pgdata/test/number.mapper.unit.test.ts b/mods/pgdata/test/number.mapper.unit.test.ts index d38b1d667..e380f0a44 100644 --- a/mods/pgdata/test/number.mapper.unit.test.ts +++ b/mods/pgdata/test/number.mapper.unit.test.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr @@ -39,7 +39,7 @@ describe("@routr/pgdata/mappers/number", () => { trunkRef: "trunk-01", name: "(785)317-8070", telUrl: "tel:+17853178070", - aorLink: "backend:aor-01", + aorLink: "sip:aor-01@sip.local", city: "Durham", country: "United States", countryIsoCode: "US", @@ -189,7 +189,7 @@ describe("@routr/pgdata/mappers/number", () => { trunkRef: "trunk-01", name: "", telUrl: "tel:+17853178070", - aorLink: "backend:aor-01", + aorLink: "sip:aor-01@sip.local", city: "Durham", country: "United States", countryIsoCode: "US", @@ -224,7 +224,7 @@ describe("@routr/pgdata/mappers/number", () => { trunkRef: "trunk-01", name: "a".repeat(65), telUrl: "tel:+17853178070", - aorLink: "backend:aor-01", + aorLink: "sip:aor-01@sip.local", city: "Durham", country: "United States", countryIsoCode: "US", @@ -263,7 +263,7 @@ describe("@routr/pgdata/mappers/number", () => { trunkRef: "trunk-01", name: "(785)317-8070", telUrl: "tel:+17853178070", - aorLink: "backend:aor-01", + aorLink: "sip:aor-01@sip.local", city: "Durham", country: "United States", countryIsoCode: "US", @@ -296,7 +296,7 @@ describe("@routr/pgdata/mappers/number", () => { trunkRef: "trunk-01", name: "(785)317-8070", telUrl: "", - aorLink: "backend:aor-01", + aorLink: "sip:aor-01@sip.local", city: "Durham", country: "United States", countryIsoCode: "US", @@ -328,7 +328,7 @@ describe("@routr/pgdata/mappers/number", () => { trunkRef: "trunk-01", name: "(785)317-8070", telUrl: "tel:+17853178070", - aorLink: "backend:aor-01", + aorLink: "sip:aor-01@sip.local", city: "Durham", country: "United States", countryIsoCode: "US", diff --git a/mods/pgdata/test/peer.mapper.unit.test.ts b/mods/pgdata/test/peer.mapper.unit.test.ts index 587dcc261..4e12ad4bf 100644 --- a/mods/pgdata/test/peer.mapper.unit.test.ts +++ b/mods/pgdata/test/peer.mapper.unit.test.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr @@ -48,6 +48,8 @@ describe("@routr/pgdata/mappers/peer", () => { enabled: true, createdAt: new Date().getTime() / 1000, updatedAt: new Date().getTime() / 1000, + maxContacts: 1, + expires: 3600, extended: { test: "test" } @@ -75,7 +77,7 @@ describe("@routr/pgdata/mappers/peer", () => { credentialsRef: "credentials-01", name: "Asterisk Media Server", username: "asterisk", - aor: "backend:voice", + aor: "sip:voice@sip.local", contactAddr: "192.168.1.3", balancingAlgorithm: "ROUND_ROBIN" as LoadBalancingAlgorithm, withSessionAffinity: false, @@ -92,6 +94,8 @@ describe("@routr/pgdata/mappers/peer", () => { test: "test" } }, + maxContacts: 1, + expires: 3600, accessControlListRef: "acl-01", accessControlList: { apiVersion: "v2" as APIVersion, @@ -134,6 +138,7 @@ describe("@routr/pgdata/mappers/peer", () => { aor: "sip:1001@sip.local", contactAddr: "192.168.1.12", enabled: true, + maxContacts: -1, createdAt: new Date().getTime() / 1000, updatedAt: new Date().getTime() / 1000, extended: { @@ -164,6 +169,7 @@ describe("@routr/pgdata/mappers/peer", () => { enabled: true, createdAt: new Date().getTime() / 1000, updatedAt: new Date().getTime() / 1000, + maxContacts: -1, extended: { test: "test" } @@ -193,6 +199,7 @@ describe("@routr/pgdata/mappers/peer", () => { username: "asterisk", aor: "sip:1001@sip.local", contactAddr: "192.168.1.12", + maxContacts: -1, enabled: true, createdAt: new Date().getTime() / 1000, updatedAt: new Date().getTime() / 1000, @@ -219,6 +226,7 @@ describe("@routr/pgdata/mappers/peer", () => { username: "", aor: "sip:1001@sip.local", contactAddr: "192.168.1.12", + maxContacts: -1, enabled: true, createdAt: new Date().getTime() / 1000, updatedAt: new Date().getTime() / 1000, @@ -245,6 +253,7 @@ describe("@routr/pgdata/mappers/peer", () => { username: "asterisk space", aor: "sip:1001@sip.local", contactAddr: "192.168.1.12", + maxContacts: -1, enabled: true, createdAt: new Date().getTime() / 1000, updatedAt: new Date().getTime() / 1000, @@ -273,6 +282,7 @@ describe("@routr/pgdata/mappers/peer", () => { username: "asterisk", aor: "", contactAddr: "192.168.1.12", + maxContacts: -1, enabled: true, createdAt: new Date().getTime() / 1000, updatedAt: new Date().getTime() / 1000, @@ -299,6 +309,7 @@ describe("@routr/pgdata/mappers/peer", () => { username: "asterisk", aor: "backendx:aor-01", contactAddr: "192.168.1.12:5060", + maxContacts: -1, enabled: true, createdAt: new Date().getTime() / 1000, updatedAt: new Date().getTime() / 1000, @@ -319,71 +330,5 @@ describe("@routr/pgdata/mappers/peer", () => { "the aor schema must start with `backend:` or `sip:`" ) }) - - it("when aor schema is backend: but defined no balancing algorithm", () => { - // Arrange - const peer = { - apiVersion: "v2", - ref: "peer-01", - credentialsRef: "credentials-01", - accessControlListRef: "acl-01", - name: "Asterisk Media Server", - username: "asterisk", - aor: "backend:aor-01", - contactAddr: "192.168.1.12:5060", - enabled: true, - createdAt: new Date().getTime() / 1000, - updatedAt: new Date().getTime() / 1000, - extended: { - test: "test" - } - } - - // Act - const createResult = () => new PeerManager(peer).validOrThrowCreate() - const createUpdate = () => new PeerManager(peer).validOrThrowUpdate() - - // Assert - expect(createResult).to.throw( - "when the aor schema is `backend:`, the balancing algorithm is required" - ) - expect(createUpdate).to.throw( - "when the aor schema is `backend:`, the balancing algorithm is required" - ) - }) - - it("when aor schema is sip: balancing algorithm is not allowed", () => { - // Arrange - const peer = { - apiVersion: "v2", - ref: "peer-01", - credentialsRef: "credentials-01", - accessControlListRef: "acl-01", - name: "Asterisk Media Server", - username: "asterisk", - aor: "sip:1001@sip.local", - balancingAlgorithm: CT.LoadBalancingAlgorithm.ROUND_ROBIN, - withSessionAffinity: false, - contactAddr: "192.168.1.12:5060", - enabled: true, - createdAt: new Date().getTime() / 1000, - updatedAt: new Date().getTime() / 1000, - extended: { - test: "test" - } - } - - // Act - const createResult = () => new PeerManager(peer).validOrThrowCreate() - const createUpdate = () => new PeerManager(peer).validOrThrowUpdate() - - // Assert - expect(createResult).to.throw( - "when the aor schema is `sip:`, the balancing algorithm is not allowed" - ) - expect(createUpdate).to.throw( - "when the aor schema is `sip:`, the balancing algorithm is not allowed" - ) - }) }) }) diff --git a/mods/pgdata/test/trunk.mapper.unit.test.ts b/mods/pgdata/test/trunk.mapper.unit.test.ts index 5b45d402b..29e0b1bc0 100644 --- a/mods/pgdata/test/trunk.mapper.unit.test.ts +++ b/mods/pgdata/test/trunk.mapper.unit.test.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/processor/src/alterations.ts b/mods/processor/src/alterations.ts index 44da87c0b..69e34bcdc 100644 --- a/mods/processor/src/alterations.ts +++ b/mods/processor/src/alterations.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/processor/src/extensions.ts b/mods/processor/src/extensions.ts index 6e318caa2..c6d64b7bb 100644 --- a/mods/processor/src/extensions.ts +++ b/mods/processor/src/extensions.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/processor/src/helper.ts b/mods/processor/src/helper.ts index d1b47b3ed..bf4f1ae0b 100644 --- a/mods/processor/src/helper.ts +++ b/mods/processor/src/helper.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/processor/src/index.ts b/mods/processor/src/index.ts index ecd8fa094..f19c68345 100644 --- a/mods/processor/src/index.ts +++ b/mods/processor/src/index.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/processor/src/processor.ts b/mods/processor/src/processor.ts index 2641cbdde..b1751b244 100644 --- a/mods/processor/src/processor.ts +++ b/mods/processor/src/processor.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/processor/src/response.ts b/mods/processor/src/response.ts index dd08f1836..92ade29e8 100644 --- a/mods/processor/src/response.ts +++ b/mods/processor/src/response.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr @@ -142,6 +142,21 @@ export default class Response { ) } + /** + * Sends a forbidden response. + * + * @param {string} message - Optional message to be sent. + */ + sendForbidden(message?: string) { + this.callback( + null, + buildResponse({ + code: CT.ResponseType.FORBIDDEN, + reasonPhrase: message || "Forbidden" + }) + ) + } + /** * Sends a response with a SIP Message. * diff --git a/mods/processor/src/target.ts b/mods/processor/src/target.ts index 79bcdc536..aed621232 100644 --- a/mods/processor/src/target.ts +++ b/mods/processor/src/target.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/processor/src/tracer.ts b/mods/processor/src/tracer.ts index ac83e12cb..b10cd8145 100644 --- a/mods/processor/src/tracer.ts +++ b/mods/processor/src/tracer.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/processor/src/types.ts b/mods/processor/src/types.ts index ce1622c45..93daeb980 100644 --- a/mods/processor/src/types.ts +++ b/mods/processor/src/types.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/processor/test/alterations.unit.test.ts b/mods/processor/test/alterations.unit.test.ts index 856c16cd2..335a435bd 100644 --- a/mods/processor/test/alterations.unit.test.ts +++ b/mods/processor/test/alterations.unit.test.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/processor/test/examples.ts b/mods/processor/test/examples.ts index 271413e38..4f12684ab 100644 --- a/mods/processor/test/examples.ts +++ b/mods/processor/test/examples.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/processor/test/extensions.unit.test.ts b/mods/processor/test/extensions.unit.test.ts index afb20437c..2770ca292 100644 --- a/mods/processor/test/extensions.unit.test.ts +++ b/mods/processor/test/extensions.unit.test.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/processor/test/helper.unit.test.ts b/mods/processor/test/helper.unit.test.ts index e4b8ec9d4..7f0e1377d 100644 --- a/mods/processor/test/helper.unit.test.ts +++ b/mods/processor/test/helper.unit.test.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/processor/test/processor.unit.test.ts b/mods/processor/test/processor.unit.test.ts index 75a14495d..e7c6874f5 100644 --- a/mods/processor/test/processor.unit.test.ts +++ b/mods/processor/test/processor.unit.test.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/processor/test/target.unit.test.ts b/mods/processor/test/target.unit.test.ts index 3c3a870e4..fd0d5f015 100644 --- a/mods/processor/test/target.unit.test.ts +++ b/mods/processor/test/target.unit.test.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/registry/Dockerfile b/mods/registry/Dockerfile index 7bab54e1e..e10df5a48 100644 --- a/mods/registry/Dockerfile +++ b/mods/registry/Dockerfile @@ -1,4 +1,4 @@ -FROM alpine:3.18 +FROM alpine:3.19 LABEL maintainer="Pedro Sanders " COPY . /scripts diff --git a/mods/registry/src/config/get_config.ts b/mods/registry/src/config/get_config.ts index 5cc8854d6..b38eaba3d 100644 --- a/mods/registry/src/config/get_config.ts +++ b/mods/registry/src/config/get_config.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/registry/src/config/schema.ts b/mods/registry/src/config/schema.ts index 9ac9d6ed2..05e0fcd82 100644 --- a/mods/registry/src/config/schema.ts +++ b/mods/registry/src/config/schema.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/registry/src/envs.ts b/mods/registry/src/envs.ts index 9a34a8f78..9ae28cb38 100644 --- a/mods/registry/src/envs.ts +++ b/mods/registry/src/envs.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/registry/src/errors.ts b/mods/registry/src/errors.ts index ed5c210e5..c720ea5be 100644 --- a/mods/registry/src/errors.ts +++ b/mods/registry/src/errors.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/registry/src/memory_store.ts b/mods/registry/src/memory_store.ts index 4fafd6d5f..108fca5b0 100644 --- a/mods/registry/src/memory_store.ts +++ b/mods/registry/src/memory_store.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/registry/src/redis_store.ts b/mods/registry/src/redis_store.ts index 6bb183a4f..71afec6fb 100644 --- a/mods/registry/src/redis_store.ts +++ b/mods/registry/src/redis_store.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/registry/src/request.ts b/mods/registry/src/request.ts index a782b65fc..e2c55204f 100644 --- a/mods/registry/src/request.ts +++ b/mods/registry/src/request.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/registry/src/runner.ts b/mods/registry/src/runner.ts index 2a132f9d2..b6e7fb3de 100644 --- a/mods/registry/src/runner.ts +++ b/mods/registry/src/runner.ts @@ -1,6 +1,6 @@ #!/usr/bin/env node /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/registry/src/sender.ts b/mods/registry/src/sender.ts index 7e998af6d..3c4b002cc 100644 --- a/mods/registry/src/sender.ts +++ b/mods/registry/src/sender.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/registry/src/service.ts b/mods/registry/src/service.ts index 13ced8911..039a3569f 100644 --- a/mods/registry/src/service.ts +++ b/mods/registry/src/service.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr @@ -85,7 +85,7 @@ export default function registryService(config: RegistryConfig) { const results = await Promise.allSettled(registryInvocations) results?.forEach(async (result) => { - logger.verbose("processing registration result", { result }) + logger.silly("processing registration result", { result }) if (result.status === "rejected") { logger.error("request rejected", result.reason) diff --git a/mods/registry/src/tracer.ts b/mods/registry/src/tracer.ts index 9b7d7c976..178e7df23 100644 --- a/mods/registry/src/tracer.ts +++ b/mods/registry/src/tracer.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/registry/src/types.ts b/mods/registry/src/types.ts index 055aeee4a..d0bcabf0b 100644 --- a/mods/registry/src/types.ts +++ b/mods/registry/src/types.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/registry/src/utils.ts b/mods/registry/src/utils.ts index b2c219b88..79caf7af4 100644 --- a/mods/registry/src/utils.ts +++ b/mods/registry/src/utils.ts @@ -1,6 +1,5 @@ -/* eslint-disable require-jsdoc */ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. @@ -17,6 +16,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/* eslint-disable require-jsdoc */ import { CommonConnect as CC } from "@routr/common" import MemoryStore from "./memory_store" import RedisStore from "./redis_store" diff --git a/mods/registry/test/memory_store.unit.test.ts b/mods/registry/test/memory_store.unit.test.ts index e5d7e5b43..b52fdf26d 100644 --- a/mods/registry/test/memory_store.unit.test.ts +++ b/mods/registry/test/memory_store.unit.test.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/registry/test/redis_store.int.test.ts b/mods/registry/test/redis_store.int.test.ts index ef22407e2..22f0432f8 100644 --- a/mods/registry/test/redis_store.int.test.ts +++ b/mods/registry/test/redis_store.int.test.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/registry/test/registry.unit.test.ts b/mods/registry/test/registry.unit.test.ts index 223b8ffe6..7474f32ae 100644 --- a/mods/registry/test/registry.unit.test.ts +++ b/mods/registry/test/registry.unit.test.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/requester/Dockerfile b/mods/requester/Dockerfile index 8ee7599a6..8def607f4 100644 --- a/mods/requester/Dockerfile +++ b/mods/requester/Dockerfile @@ -1,7 +1,7 @@ ## ## Build and pack the service ## -FROM alpine:3.18 as builder +FROM alpine:3.19 as builder LABEL maintainer="Pedro Sanders " ENV JAVA_HOME=/usr/lib/jvm/java-11-openjdk @@ -15,7 +15,7 @@ RUN apk add --no-cache --update openjdk11-jdk \ ## ## Runner ## -FROM alpine:3.18 as runner +FROM alpine:3.19 as runner RUN mkdir -p /opt/routr && apk add --no-cache tini WORKDIR /opt/routr diff --git a/mods/requester/requester.sh b/mods/requester/requester.sh index 5fc62794f..4c6fad14c 100755 --- a/mods/requester/requester.sh +++ b/mods/requester/requester.sh @@ -5,7 +5,6 @@ export HOME="$(cd "$(dirname "$0")"; pwd)" [ -z "$JAVA_HOME" ] && { echo "Could not find a runtime environment. Please setup environment variable JAVA_HOME"; exit 1; } export JAVA_OPTS="-Dlog4j.configurationFile=${LOG4J2} \ - -XX:CMSInitiatingOccupancyFraction=80 \ -Dsun.rmi.dgc.client.gcInterval=3600000 \ -Djava.net.preferIPv4Stack=true" diff --git a/mods/requester/src/main/java/io/routr/requester/AddressUtil.java b/mods/requester/src/main/java/io/routr/requester/AddressUtil.java index 7a9bcf8d4..a9bab0029 100644 --- a/mods/requester/src/main/java/io/routr/requester/AddressUtil.java +++ b/mods/requester/src/main/java/io/routr/requester/AddressUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/requester/src/main/java/io/routr/requester/Launcher.java b/mods/requester/src/main/java/io/routr/requester/Launcher.java index c07656e34..dd17f1e12 100644 --- a/mods/requester/src/main/java/io/routr/requester/Launcher.java +++ b/mods/requester/src/main/java/io/routr/requester/Launcher.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/requester/src/main/java/io/routr/requester/RequestSender.java b/mods/requester/src/main/java/io/routr/requester/RequestSender.java index 9b859448d..4c8e35d70 100644 --- a/mods/requester/src/main/java/io/routr/requester/RequestSender.java +++ b/mods/requester/src/main/java/io/routr/requester/RequestSender.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/requester/src/main/java/io/routr/requester/Requester.java b/mods/requester/src/main/java/io/routr/requester/Requester.java index 270c65dad..8ec2bdd2e 100644 --- a/mods/requester/src/main/java/io/routr/requester/Requester.java +++ b/mods/requester/src/main/java/io/routr/requester/Requester.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/requester/src/main/java/io/routr/requester/RequesterService.java b/mods/requester/src/main/java/io/routr/requester/RequesterService.java index 10c9cc837..ebc3dcb4e 100644 --- a/mods/requester/src/main/java/io/routr/requester/RequesterService.java +++ b/mods/requester/src/main/java/io/routr/requester/RequesterService.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/requester/src/main/java/io/routr/requester/ResponseCallable.java b/mods/requester/src/main/java/io/routr/requester/ResponseCallable.java index f6a3f9bac..ea1567888 100644 --- a/mods/requester/src/main/java/io/routr/requester/ResponseCallable.java +++ b/mods/requester/src/main/java/io/routr/requester/ResponseCallable.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/requester/src/main/java/io/routr/requester/SIPProviderBuilder.java b/mods/requester/src/main/java/io/routr/requester/SIPProviderBuilder.java index 114f1c8fe..5fb311ecf 100644 --- a/mods/requester/src/main/java/io/routr/requester/SIPProviderBuilder.java +++ b/mods/requester/src/main/java/io/routr/requester/SIPProviderBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/requester/src/main/java/io/routr/requester/SIPStackProperties.java b/mods/requester/src/main/java/io/routr/requester/SIPStackProperties.java index aaeba6abe..b61a93a6f 100644 --- a/mods/requester/src/main/java/io/routr/requester/SIPStackProperties.java +++ b/mods/requester/src/main/java/io/routr/requester/SIPStackProperties.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/requester/src/main/java/io/routr/requester/Utils.java b/mods/requester/src/main/java/io/routr/requester/Utils.java index d9525156a..64eee01d8 100644 --- a/mods/requester/src/main/java/io/routr/requester/Utils.java +++ b/mods/requester/src/main/java/io/routr/requester/Utils.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/requester/src/runner.ts b/mods/requester/src/runner.ts index 1ecb446a5..ff8e5a131 100644 --- a/mods/requester/src/runner.ts +++ b/mods/requester/src/runner.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/requester/src/test/java/io/routr/requester/AddressUtilTests.java b/mods/requester/src/test/java/io/routr/requester/AddressUtilTests.java index 4df7994fa..e60b244fd 100644 --- a/mods/requester/src/test/java/io/routr/requester/AddressUtilTests.java +++ b/mods/requester/src/test/java/io/routr/requester/AddressUtilTests.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/requester/src/test/java/io/routr/requester/SIPProviderBuilderTests.java b/mods/requester/src/test/java/io/routr/requester/SIPProviderBuilderTests.java index 946c9000a..6b6ed5601 100644 --- a/mods/requester/src/test/java/io/routr/requester/SIPProviderBuilderTests.java +++ b/mods/requester/src/test/java/io/routr/requester/SIPProviderBuilderTests.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/requester/src/test/java/io/routr/requester/SIPStackPropertiesTests.java b/mods/requester/src/test/java/io/routr/requester/SIPStackPropertiesTests.java index 6e421983b..59035595c 100644 --- a/mods/requester/src/test/java/io/routr/requester/SIPStackPropertiesTests.java +++ b/mods/requester/src/test/java/io/routr/requester/SIPStackPropertiesTests.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/requester/src/test/java/io/routr/requester/UtilsTests.java b/mods/requester/src/test/java/io/routr/requester/UtilsTests.java index d2ce63e12..c068aaab6 100644 --- a/mods/requester/src/test/java/io/routr/requester/UtilsTests.java +++ b/mods/requester/src/test/java/io/routr/requester/UtilsTests.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/requester/src/tracer.ts b/mods/requester/src/tracer.ts index ac83e12cb..b10cd8145 100644 --- a/mods/requester/src/tracer.ts +++ b/mods/requester/src/tracer.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/rtprelay/Dockerfile b/mods/rtprelay/Dockerfile index 06d6c06ea..12d1c9722 100644 --- a/mods/rtprelay/Dockerfile +++ b/mods/rtprelay/Dockerfile @@ -1,4 +1,4 @@ -FROM alpine:3.18 +FROM alpine:3.19 LABEL maintainer="Pedro Sanders " COPY . /scripts diff --git a/mods/rtprelay/src/client.ts b/mods/rtprelay/src/client.ts index 8de38e6b4..a60bd3c52 100644 --- a/mods/rtprelay/src/client.ts +++ b/mods/rtprelay/src/client.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/rtprelay/src/envs.ts b/mods/rtprelay/src/envs.ts index ef95641fc..4edfe9e47 100644 --- a/mods/rtprelay/src/envs.ts +++ b/mods/rtprelay/src/envs.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/rtprelay/src/index.ts b/mods/rtprelay/src/index.ts index db23d3bb4..329ec8146 100644 --- a/mods/rtprelay/src/index.ts +++ b/mods/rtprelay/src/index.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/rtprelay/src/runner.ts b/mods/rtprelay/src/runner.ts index b1fd12ee2..ba8206f4d 100644 --- a/mods/rtprelay/src/runner.ts +++ b/mods/rtprelay/src/runner.ts @@ -1,6 +1,6 @@ #!/usr/bin/env node /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/rtprelay/src/service.ts b/mods/rtprelay/src/service.ts index 7c04c878e..3ade84b95 100644 --- a/mods/rtprelay/src/service.ts +++ b/mods/rtprelay/src/service.ts @@ -1,6 +1,6 @@ #!/usr/bin/env node /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr @@ -74,7 +74,7 @@ export default function rtprelay( if (H.isInviteOrAckWithSDP(req)) { return await sendRequest(offer) } else if (H.isRinging(req) && direction === Direction.WEB_TO_PHONE) { - // Fixme: This was added to prevent the ringing message from being sent to the + // FIXME: This was added to prevent the ringing message from being sent to the // caller while the call is being established. This is a temporary fix req.message.body = "" return res.send(req) diff --git a/mods/rtprelay/src/tracer.ts b/mods/rtprelay/src/tracer.ts index ac83e12cb..b10cd8145 100644 --- a/mods/rtprelay/src/tracer.ts +++ b/mods/rtprelay/src/tracer.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/rtprelay/src/types.ts b/mods/rtprelay/src/types.ts index fdd093349..7eacb15c8 100644 --- a/mods/rtprelay/src/types.ts +++ b/mods/rtprelay/src/types.ts @@ -1,7 +1,7 @@ import { MessageRequest } from "@routr/common" /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/rtprelay/src/utils.ts b/mods/rtprelay/src/utils.ts index 9e2810a96..de749978e 100644 --- a/mods/rtprelay/src/utils.ts +++ b/mods/rtprelay/src/utils.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/rtprelay/test/examples.ts b/mods/rtprelay/test/examples.ts index 0aa29e051..6a72461ba 100644 --- a/mods/rtprelay/test/examples.ts +++ b/mods/rtprelay/test/examples.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/rtprelay/test/rtpengine.unit.test.ts b/mods/rtprelay/test/rtpengine.unit.test.ts index a546b3a4b..5f27b1f5b 100644 --- a/mods/rtprelay/test/rtpengine.unit.test.ts +++ b/mods/rtprelay/test/rtpengine.unit.test.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/sdk/README.md b/mods/sdk/README.md index a27d61ee6..38434f385 100644 --- a/mods/sdk/README.md +++ b/mods/sdk/README.md @@ -966,7 +966,7 @@ const peers = new SDK.Peers() const request = { name: "Asterisk Conference Server", username: "conference", - aor: "backend:conference", + aor: "sip:conference@sip.local", contactAddr: "10.0.0.1:5060", accessControlListRef: "4671371b-ff5d-48b1-aabe-d3c5ca5317a3", credentialsRef: "4671371b-ff5d-48b1-aabe-d3c5ca5317a3", @@ -1012,7 +1012,7 @@ Creates a new Peer on Routr. const request = { name: "Asterisk Conference Server", username: "conference", - aor: "backend:conference", + aor: "sip:conference@sip.local", contactAddr: "10.0.0.1:5060", accessControlListRef: "4671371b-ff5d-48b1-aabe-d3c5ca5317a3", credentialsRef: "4671371b-ff5d-48b1-aabe-d3c5ca5317a3", diff --git a/mods/sdk/src/acl/acl.ts b/mods/sdk/src/acl/acl.ts index f2685d676..6e025365c 100644 --- a/mods/sdk/src/acl/acl.ts +++ b/mods/sdk/src/acl/acl.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/sdk/src/acl/index.ts b/mods/sdk/src/acl/index.ts index 0efa8bcc6..b670f4a54 100644 --- a/mods/sdk/src/acl/index.ts +++ b/mods/sdk/src/acl/index.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/sdk/src/acl/types.ts b/mods/sdk/src/acl/types.ts index 0acdd33f8..8b30aac26 100644 --- a/mods/sdk/src/acl/types.ts +++ b/mods/sdk/src/acl/types.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/sdk/src/agents/agents.ts b/mods/sdk/src/agents/agents.ts index b00c31a67..ed78196c3 100644 --- a/mods/sdk/src/agents/agents.ts +++ b/mods/sdk/src/agents/agents.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/sdk/src/agents/index.ts b/mods/sdk/src/agents/index.ts index d43708174..67caf3ebf 100644 --- a/mods/sdk/src/agents/index.ts +++ b/mods/sdk/src/agents/index.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/sdk/src/agents/types.ts b/mods/sdk/src/agents/types.ts index 8d5141e88..e7a255485 100644 --- a/mods/sdk/src/agents/types.ts +++ b/mods/sdk/src/agents/types.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/sdk/src/client.ts b/mods/sdk/src/client.ts index 68ebadd12..1484d2313 100644 --- a/mods/sdk/src/client.ts +++ b/mods/sdk/src/client.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/sdk/src/credentials/credentials.ts b/mods/sdk/src/credentials/credentials.ts index fa6b7989b..9f48680cb 100644 --- a/mods/sdk/src/credentials/credentials.ts +++ b/mods/sdk/src/credentials/credentials.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/sdk/src/credentials/index.ts b/mods/sdk/src/credentials/index.ts index 6e9e7a4f2..8a3857666 100644 --- a/mods/sdk/src/credentials/index.ts +++ b/mods/sdk/src/credentials/index.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/sdk/src/credentials/types.ts b/mods/sdk/src/credentials/types.ts index a2c6c70e3..2c6e14e29 100644 --- a/mods/sdk/src/credentials/types.ts +++ b/mods/sdk/src/credentials/types.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/sdk/src/domains/domains.ts b/mods/sdk/src/domains/domains.ts index 560265426..fbb628d21 100644 --- a/mods/sdk/src/domains/domains.ts +++ b/mods/sdk/src/domains/domains.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/sdk/src/domains/index.ts b/mods/sdk/src/domains/index.ts index d561a9c46..49ec74bdb 100644 --- a/mods/sdk/src/domains/index.ts +++ b/mods/sdk/src/domains/index.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/sdk/src/domains/types.ts b/mods/sdk/src/domains/types.ts index 9cc36e1b6..4dc98d2b0 100644 --- a/mods/sdk/src/domains/types.ts +++ b/mods/sdk/src/domains/types.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/sdk/src/index.ts b/mods/sdk/src/index.ts index 9ea12b554..9584a621a 100644 --- a/mods/sdk/src/index.ts +++ b/mods/sdk/src/index.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/sdk/src/numbers/index.ts b/mods/sdk/src/numbers/index.ts index d14f7491a..71cf5dfa1 100644 --- a/mods/sdk/src/numbers/index.ts +++ b/mods/sdk/src/numbers/index.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/sdk/src/numbers/numbers.ts b/mods/sdk/src/numbers/numbers.ts index 854aac1e1..ba2b0bf19 100644 --- a/mods/sdk/src/numbers/numbers.ts +++ b/mods/sdk/src/numbers/numbers.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/sdk/src/numbers/types.ts b/mods/sdk/src/numbers/types.ts index 3d74873f6..54e0a0e1c 100644 --- a/mods/sdk/src/numbers/types.ts +++ b/mods/sdk/src/numbers/types.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/sdk/src/peers/index.ts b/mods/sdk/src/peers/index.ts index 85609f952..801040899 100644 --- a/mods/sdk/src/peers/index.ts +++ b/mods/sdk/src/peers/index.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/sdk/src/peers/peers.ts b/mods/sdk/src/peers/peers.ts index 721753f47..aa4f88461 100644 --- a/mods/sdk/src/peers/peers.ts +++ b/mods/sdk/src/peers/peers.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. @@ -41,7 +41,7 @@ import { * const request = { * name: "Asterisk Conference Server", * username: "conference", - * aor: "backend:conference", + * aor: "sip:conference@sip.local", * contactAddr: "10.0.0.1:5060", * accessControlListRef: "4671371b-ff5d-48b1-aabe-d3c5ca5317a3", * credentialsRef: "4671371b-ff5d-48b1-aabe-d3c5ca5317a3", @@ -88,7 +88,7 @@ export class Peers extends APIClient { * const request = { * name: "Asterisk Conference Server", * username: "conference", - * aor: "backend:conference", + * aor: "sip:conference@sip.local", * contactAddr: "10.0.0.1:5060", * accessControlListRef: "4671371b-ff5d-48b1-aabe-d3c5ca5317a3", * credentialsRef: "4671371b-ff5d-48b1-aabe-d3c5ca5317a3", diff --git a/mods/sdk/src/peers/types.ts b/mods/sdk/src/peers/types.ts index 5fb624fb9..bfa135263 100644 --- a/mods/sdk/src/peers/types.ts +++ b/mods/sdk/src/peers/types.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/sdk/src/trunks/index.ts b/mods/sdk/src/trunks/index.ts index bc2937e74..257ef4877 100644 --- a/mods/sdk/src/trunks/index.ts +++ b/mods/sdk/src/trunks/index.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/sdk/src/trunks/trunks.ts b/mods/sdk/src/trunks/trunks.ts index 1b540b226..f5e6b5abb 100644 --- a/mods/sdk/src/trunks/trunks.ts +++ b/mods/sdk/src/trunks/trunks.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/sdk/src/trunks/types.ts b/mods/sdk/src/trunks/types.ts index 3885ba201..e3b770748 100644 --- a/mods/sdk/src/trunks/types.ts +++ b/mods/sdk/src/trunks/types.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/sdk/src/types.ts b/mods/sdk/src/types.ts index 900a58188..70e06edea 100644 --- a/mods/sdk/src/types.ts +++ b/mods/sdk/src/types.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/sdk/test/acl.unit.test.ts b/mods/sdk/test/acl.unit.test.ts index 1491fb34f..cffdb0bb3 100644 --- a/mods/sdk/test/acl.unit.test.ts +++ b/mods/sdk/test/acl.unit.test.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/simpleauth/Dockerfile b/mods/simpleauth/Dockerfile index ef3bd5cc6..8d48305f4 100644 --- a/mods/simpleauth/Dockerfile +++ b/mods/simpleauth/Dockerfile @@ -1,4 +1,4 @@ -FROM alpine:3.18 +FROM alpine:3.19 LABEL maintainer="Pedro Sanders " COPY . /scripts diff --git a/mods/simpleauth/src/envs.ts b/mods/simpleauth/src/envs.ts index cbe680d46..37a1f0bce 100644 --- a/mods/simpleauth/src/envs.ts +++ b/mods/simpleauth/src/envs.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/simpleauth/src/runner.ts b/mods/simpleauth/src/runner.ts index ff39134cf..859ca8bb1 100644 --- a/mods/simpleauth/src/runner.ts +++ b/mods/simpleauth/src/runner.ts @@ -1,6 +1,6 @@ #!/usr/bin/env node /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/simpleauth/src/service.ts b/mods/simpleauth/src/service.ts index c1a90d082..03429ee00 100644 --- a/mods/simpleauth/src/service.ts +++ b/mods/simpleauth/src/service.ts @@ -1,6 +1,6 @@ #!/usr/bin/env node /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr @@ -19,7 +19,12 @@ */ import opentelemetry from "@opentelemetry/api" import Processor, { Response } from "@routr/processor" -import { MessageRequest, Auth, CommonTypes as CT } from "@routr/common" +import { + MessageRequest, + Auth, + CommonTypes as CT, + CommonResponse as CR +} from "@routr/common" import { User } from "./types" import { getLogger } from "@fonoster/logger" @@ -86,7 +91,7 @@ export default function simpleAuthMiddleware(config: { ) span.end() return res.send( - Auth.createUnauthorizedResponse(req.message.requestUri.host) + CR.createUnauthorizedResponse(req.message.requestUri.host) ) } } else { @@ -95,7 +100,7 @@ export default function simpleAuthMiddleware(config: { ) span.end() return res.send( - Auth.createUnauthorizedResponse(req.message.requestUri.host) + CR.createUnauthorizedResponse(req.message.requestUri.host) ) } // Forward request to next middleware diff --git a/mods/simpleauth/src/tracer.ts b/mods/simpleauth/src/tracer.ts index ac83e12cb..b10cd8145 100644 --- a/mods/simpleauth/src/tracer.ts +++ b/mods/simpleauth/src/tracer.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/simpleauth/src/types.ts b/mods/simpleauth/src/types.ts index 8fe4f1c2a..a05984773 100644 --- a/mods/simpleauth/src/types.ts +++ b/mods/simpleauth/src/types.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/simpleauth/test/simpleauth.unit.test.ts b/mods/simpleauth/test/simpleauth.unit.test.ts index a71264e06..b68ea0dbf 100644 --- a/mods/simpleauth/test/simpleauth.unit.test.ts +++ b/mods/simpleauth/test/simpleauth.unit.test.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/simpledata/Dockerfile b/mods/simpledata/Dockerfile index 2d6195d4c..8cdc6d3d6 100644 --- a/mods/simpledata/Dockerfile +++ b/mods/simpledata/Dockerfile @@ -1,4 +1,4 @@ -FROM alpine:3.18 +FROM alpine:3.19 LABEL maintainer="Pedro Sanders " COPY . /scripts diff --git a/mods/simpledata/src/api.ts b/mods/simpledata/src/api.ts index 26f0ef657..17815fc25 100644 --- a/mods/simpledata/src/api.ts +++ b/mods/simpledata/src/api.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/simpledata/src/envs.ts b/mods/simpledata/src/envs.ts index cc0af40b5..4d0354133 100644 --- a/mods/simpledata/src/envs.ts +++ b/mods/simpledata/src/envs.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/simpledata/src/loaders/acl.ts b/mods/simpledata/src/loaders/acl.ts index 3d11214f3..3d2c43649 100644 --- a/mods/simpledata/src/loaders/acl.ts +++ b/mods/simpledata/src/loaders/acl.ts @@ -1,6 +1,4 @@ -/* eslint-disable require-jsdoc */ -/* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) +/* * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. @@ -17,6 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/* eslint-disable require-jsdoc */ import { CommonConnect as CC } from "@routr/common" export function aclLoader(config: CC.UserConfig): CC.AccessControlList { diff --git a/mods/simpledata/src/loaders/agents.ts b/mods/simpledata/src/loaders/agents.ts index eb2f8dcc7..0183479dd 100644 --- a/mods/simpledata/src/loaders/agents.ts +++ b/mods/simpledata/src/loaders/agents.ts @@ -1,6 +1,5 @@ -/* eslint-disable require-jsdoc */ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. @@ -17,6 +16,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/* eslint-disable require-jsdoc */ import { CommonConnect as CC } from "@routr/common" import { findByRef } from "./find" @@ -34,5 +34,8 @@ export function agentsLoader( list ) as CC.Credentials + // maxContacts -1 means no limit + agent.maxContacts = agent.maxContacts || -1 + return agent } diff --git a/mods/simpledata/src/loaders/credentials.ts b/mods/simpledata/src/loaders/credentials.ts index 090d8f6d8..f7ed1e80c 100644 --- a/mods/simpledata/src/loaders/credentials.ts +++ b/mods/simpledata/src/loaders/credentials.ts @@ -1,6 +1,5 @@ -/* eslint-disable require-jsdoc */ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. @@ -17,6 +16,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/* eslint-disable require-jsdoc */ import { CommonConnect as CC } from "@routr/common" export function credentialsLoader(config: CC.UserConfig): CC.Credentials { diff --git a/mods/simpledata/src/loaders/domains.ts b/mods/simpledata/src/loaders/domains.ts index 9ec98e4a3..9bc829eea 100644 --- a/mods/simpledata/src/loaders/domains.ts +++ b/mods/simpledata/src/loaders/domains.ts @@ -1,6 +1,5 @@ -/* eslint-disable require-jsdoc */ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. @@ -17,6 +16,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/* eslint-disable require-jsdoc */ import { CommonConnect as CC } from "@routr/common" import { findByRef } from "./find" diff --git a/mods/simpledata/src/loaders/find.ts b/mods/simpledata/src/loaders/find.ts index d2587b626..827fcc1b0 100644 --- a/mods/simpledata/src/loaders/find.ts +++ b/mods/simpledata/src/loaders/find.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/simpledata/src/loaders/index.ts b/mods/simpledata/src/loaders/index.ts index b542ec7f1..43fb595d4 100644 --- a/mods/simpledata/src/loaders/index.ts +++ b/mods/simpledata/src/loaders/index.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/simpledata/src/loaders/loader.ts b/mods/simpledata/src/loaders/loader.ts index 6092e6aab..3137adb54 100644 --- a/mods/simpledata/src/loaders/loader.ts +++ b/mods/simpledata/src/loaders/loader.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. diff --git a/mods/simpledata/src/loaders/numbers.ts b/mods/simpledata/src/loaders/numbers.ts index 1ae86c2d9..eb5c6d9ec 100644 --- a/mods/simpledata/src/loaders/numbers.ts +++ b/mods/simpledata/src/loaders/numbers.ts @@ -1,6 +1,5 @@ -/* eslint-disable require-jsdoc */ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. @@ -17,6 +16,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/* eslint-disable require-jsdoc */ import { CommonConnect as CC } from "@routr/common" import { findByRef } from "./find" diff --git a/mods/simpledata/src/loaders/peers.ts b/mods/simpledata/src/loaders/peers.ts index 75ef41629..ff43bc143 100644 --- a/mods/simpledata/src/loaders/peers.ts +++ b/mods/simpledata/src/loaders/peers.ts @@ -1,6 +1,5 @@ -/* eslint-disable require-jsdoc */ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. @@ -17,9 +16,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/* eslint-disable require-jsdoc */ import { CommonConnect as CC } from "@routr/common" +import { getLogger } from "@fonoster/logger" import { findByRef } from "./find" +const logger = getLogger({ service: "simpledata", filePath: __filename }) + export function peersLoader( config: CC.UserConfig, list: CC.UserConfig[] @@ -28,10 +31,20 @@ export function peersLoader( throw new Error("invalid resource type `Peer`") const peer = CC.mapToPeer(config) + + if (peer.aor.startsWith("backend:")) { + logger.warn( + "'backend:' prefix to be removed in upcoming updates. please use 'sip:' for compatibility." + ) + } + peer.credentials = findByRef( config.spec.credentialsRef, list ) as CC.Credentials + // maxContacts -1 means no limit + peer.maxContacts = peer.maxContacts || -1 + return peer } diff --git a/mods/simpledata/src/loaders/trunks.ts b/mods/simpledata/src/loaders/trunks.ts index 611ab44cc..541ce5518 100644 --- a/mods/simpledata/src/loaders/trunks.ts +++ b/mods/simpledata/src/loaders/trunks.ts @@ -1,6 +1,5 @@ -/* eslint-disable require-jsdoc */ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr. @@ -17,6 +16,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/* eslint-disable require-jsdoc */ import { CommonConnect as CC } from "@routr/common" import { findByRef } from "./find" diff --git a/mods/simpledata/src/runner.ts b/mods/simpledata/src/runner.ts index 302efdaf8..94ad6b484 100644 --- a/mods/simpledata/src/runner.ts +++ b/mods/simpledata/src/runner.ts @@ -1,6 +1,6 @@ #!/usr/bin/env node /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/simpledata/src/service.ts b/mods/simpledata/src/service.ts index a1825526f..8e151a9f5 100644 --- a/mods/simpledata/src/service.ts +++ b/mods/simpledata/src/service.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/simpledata/src/tracer.ts b/mods/simpledata/src/tracer.ts index 9b7d7c976..178e7df23 100644 --- a/mods/simpledata/src/tracer.ts +++ b/mods/simpledata/src/tracer.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/simpledata/src/types.ts b/mods/simpledata/src/types.ts index 3bf334634..83b5265d1 100644 --- a/mods/simpledata/src/types.ts +++ b/mods/simpledata/src/types.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/simpledata/src/utils.ts b/mods/simpledata/src/utils.ts index 7cd08282f..5a6500152 100644 --- a/mods/simpledata/src/utils.ts +++ b/mods/simpledata/src/utils.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/simpledata/test/api.unit.test.ts b/mods/simpledata/test/api.unit.test.ts index c2a942339..26e1a6d11 100644 --- a/mods/simpledata/test/api.unit.test.ts +++ b/mods/simpledata/test/api.unit.test.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/simpledata/test/examples.ts b/mods/simpledata/test/examples.ts index 1c79c3d7d..784a4157b 100644 --- a/mods/simpledata/test/examples.ts +++ b/mods/simpledata/test/examples.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/mods/simpledata/test/resources.unit.test.ts b/mods/simpledata/test/resources.unit.test.ts index d1c776049..83b5aaf45 100644 --- a/mods/simpledata/test/resources.unit.test.ts +++ b/mods/simpledata/test/resources.unit.test.ts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/routr * * This file is part of Routr diff --git a/package-lock.json b/package-lock.json index 33fc9922e..e87cd74e4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9805,9 +9805,9 @@ "integrity": "sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw==" }, "node_modules/follow-redirects": { - "version": "1.15.4", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.4.tgz", - "integrity": "sha512-Cr4D/5wlrb0z9dgERpUL3LrmPKVDsETIJhaCMeDfuFYcqa5bldGV6wBsAN6X/vxlXQtFBMrXdXxdL8CbDTGniw==", + "version": "1.15.5", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.5.tgz", + "integrity": "sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw==", "dev": true, "funding": [ { @@ -11908,6 +11908,9 @@ } }, "node_modules/jsdoc-parse": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/jsdoc-parse/-/jsdoc-parse-6.2.1.tgz", + "integrity": "sha512-9viGRUUtWOk/G4V0+nQ6rfLucz5plxh5I74WbNSNm9h9NWugCDVX4jbG8hZP9QqKGpdTPDE+qJXzaYNos3wqTA==", "version": "6.2.1", "resolved": "https://registry.npmjs.org/jsdoc-parse/-/jsdoc-parse-6.2.1.tgz", "integrity": "sha512-9viGRUUtWOk/G4V0+nQ6rfLucz5plxh5I74WbNSNm9h9NWugCDVX4jbG8hZP9QqKGpdTPDE+qJXzaYNos3wqTA==", diff --git a/webpack.config.js b/webpack.config.js index 0219d5642..4c8719d26 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com) + * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster * * This file is part of Routr.