Skip to content

Commit

Permalink
Added flag to enable converting ingress numbers to e164 format
Browse files Browse the repository at this point in the history
  • Loading branch information
psanders committed Mar 14, 2021
1 parent a21884e commit 2636daf
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .helm/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ spec:
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
- name: EX_CONVERT_TEL_TO_E164
value: {{ .Values.routr.ex_convertTelToE164 | quote }}
- name: EX_UNIQUE_GATEWAY_PER_HOST_PORT
value: {{ .Values.routr.ex_uniqueGatewayPerHostPort | quote }}
- name: EX_RTP_ENGINE_ENABLED
Expand Down
5 changes: 3 additions & 2 deletions .helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ routr:
patchRequestURI: false
registrarIntf: External
ex_uniqueGatewayPerHostPort: false
ex_convertTelToE164: false
ex_rtpEngine:
enabled: false
accessControlList:
deny: []
allow: []
Expand All @@ -66,8 +69,6 @@ routr:
trustStore: ""
keyStorePassword: ""
trustStorePassword: ""
ex_rtpEngine:
enabled: false
securityContext:
keyStore: ""
trustStore: ""
Expand Down
3 changes: 3 additions & 0 deletions etc/schemas/config_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
"ex_uniqueGatewayPerHostPort": {
"type": "boolean"
},
"ex_convertTelToE164": {
"type": "boolean"
},
"registrarIntf": {
"enum": ["Internal", "External", "internal", "external"]
},
Expand Down
1 change: 1 addition & 0 deletions mod/core/config/config_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module.exports = upSince => {
},
spec: {
ex_uniqueGatewayPerHostPort: false,
ex_convertTelToE164: false,
bindAddr: InetAddress.getLocalHost().getHostAddress(),
localnets: [],
transport: [
Expand Down
2 changes: 2 additions & 0 deletions mod/core/config/config_from_env.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,12 @@ envsMap.set('EX_RTP_ENGINE_ENABLED', 'spec.ex_rtpEngine.enabled')
envsMap.set('EX_RTP_ENGINE_PROTO', 'spec.ex_rtpEngine.proto')
envsMap.set('EX_RTP_ENGINE_HOST', 'spec.ex_rtpEngine.host')
envsMap.set('EX_RTP_ENGINE_PORT', 'spec.ex_rtpEngine.port')
envsMap.set('EX_CONVERT_TEL_TO_E164', 'spec.ex_convertTelToE164')
envsMap.set(
'EX_UNIQUE_GATEWAY_PER_HOST_PORT',
'spec.ex_uniqueGatewayPerHostPort'
)

envsMap.set('LOG4J', '')
envsMap.set('CONFIG_FILE', '')
envsMap.set('SALT', '')
Expand Down
7 changes: 5 additions & 2 deletions mod/location/locator.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const StoreAPI = require('@routr/data_api/store_api')
const postal = require('postal')
const { Status } = require('@routr/core/status')
const phone = require('phone')
const config = require('@routr/core/config_util')()

const LogManager = Java.type('org.apache.logging.log4j.LogManager')
const LOG = LogManager.getLogger()
Expand Down Expand Up @@ -78,11 +79,13 @@ class Locator {
} else {
try {
const tel = LocatorUtils.aorAsObj(addressOfRecord).getUser()
const telE164 = phone(tel)[0]
const telE164 = config.spec.ex_convertTelToE164
? phone('+' + tel, '', true)[0]
: tel
const response = this.findEndpointByTelUrl(`tel:${telE164}`)
if (response.status === Status.OK) return response
} catch (e) {
// Ignore
LOG.warning(`Tel '${tel}' not a valid e164`)
}
}

Expand Down

0 comments on commit 2636daf

Please sign in to comment.