From 063fc8ebba541c0d683fc7ce7fad5f0ec8c8369f Mon Sep 17 00:00:00 2001 From: Pedro Sanders Date: Sat, 22 Jun 2024 17:51:17 -0400 Subject: [PATCH] fix: allow IP addresses as the inboundUri at the CTL --- mods/common/src/connect/validations.ts | 13 +++++++++---- mods/pgdata/test/trunk.mapper.unit.test.ts | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/mods/common/src/connect/validations.ts b/mods/common/src/connect/validations.ts index c4dfd412a..dcca3be0c 100644 --- a/mods/common/src/connect/validations.ts +++ b/mods/common/src/connect/validations.ts @@ -177,13 +177,14 @@ export const hasValidACLRules = (acl: { deny: string[] allow: string[] }): true | BadRequestError => { - const deny = isValidACLRule(acl?.deny) as true | BadRequestError + const deny = isValidACLRule(acl?.deny) if (deny instanceof BadRequestError) { return deny } - const allow = isValidACLRule(acl?.allow) as true | BadRequestError + const allow = isValidACLRule(acl?.allow) + if (allow instanceof BadRequestError) { return allow } @@ -195,9 +196,13 @@ export const hasInboundUri = (inboundUri: string) => inboundUri ? true : new BadRequestError("the inboundUri is required") export const isValidInboundUri = (inboundUri: string) => { - if (inboundUri && !Validator.default.isFQDN(inboundUri)) { + if ( + inboundUri && + !Validator.default.isFQDN(inboundUri) && + !Validator.default.isIP(inboundUri) + ) { return new BadRequestError( - "the inbound URI must be a valid FQDN (e.g. sip.example.com)" + "the inbound URI must be a valid FQDN or IP address (e.g., sip.example.com or 47.132.130.31)" ) } return true diff --git a/mods/pgdata/test/trunk.mapper.unit.test.ts b/mods/pgdata/test/trunk.mapper.unit.test.ts index 29e0b1bc0..8c6532ee3 100644 --- a/mods/pgdata/test/trunk.mapper.unit.test.ts +++ b/mods/pgdata/test/trunk.mapper.unit.test.ts @@ -277,7 +277,7 @@ describe("@routr/pgdata/mappers/trunk", () => { // Assert expect(createResult).to.throw( - "the inbound URI must be a valid FQDN (e.g. sip.example.com)" + "the inbound URI must be a valid FQDN or IP address (e.g., sip.example.com or 47.132.130.31)" ) }) })