Skip to content

Commit

Permalink
fix: allow IP addresses as the inboundUri at the CTL
Browse files Browse the repository at this point in the history
  • Loading branch information
psanders committed Jun 22, 2024
1 parent c69eb8a commit 063fc8e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 9 additions & 4 deletions mods/common/src/connect/validations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion mods/pgdata/test/trunk.mapper.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
)
})
})
Expand Down

0 comments on commit 063fc8e

Please sign in to comment.