when registering over tls contact header should have appropriate sip … (#62)

* rebase

* update gh workflow
This commit is contained in:
Dave Horton
2024-06-19 12:24:08 +01:00
committed by GitHub
parent 6f7f553408
commit 0ff39724e4
4 changed files with 27 additions and 13 deletions

View File

@@ -83,20 +83,22 @@ class Regbot {
async register(srf) {
const { updateVoipCarriersRegisterStatus } = srf.locals.dbHelpers;
try {
const contactAddress = this.use_public_ip_in_contact ?
`${this.fromUser}@${srf.locals.sbcPublicIpAddress}` : this.aor;
this.logger.debug(`sending REGISTER for ${this.aor}`);
const isIPv4 = /[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}/.test(this.ipv4);
const transport = this.protocol.includes('/') ? this.protocol.substring(0, this.protocol.indexOf('/')) :
this.protocol;
const useSipsScheme = transport === 'tls' && this.use_sips_scheme;
let scheme = 'sip';
if (transport === 'tls' && this.use_sips_scheme) scheme = 'sips';
const publicAddress = srf.locals.sbcPublicIpAddress[transport] || srf.locals.sbcPublicIpAddress.udp;
const contactAddress = this.use_public_ip_in_contact ?
`${this.fromUser}@${publicAddress}` : this.aor;
this.logger.debug(`sending REGISTER for ${this.aor}`);
const isIPv4 = /[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}/.test(this.ipv4);
const proxy = `sip:${this.ipv4}${isIPv4 ? `:${this.port}` : ''};transport=${transport}`;
const req = await srf.request(`sip${useSipsScheme ? 's' : ''}:${this.aor}`, {
const req = await srf.request(`${scheme}:${this.aor}`, {
method: 'REGISTER',
proxy,
headers: {
'From': this.from,
'Contact': `<sip:${contactAddress}>;expires=${DEFAULT_EXPIRES}`,
'Contact': `<${scheme}:${contactAddress}>;expires=${DEFAULT_EXPIRES}`,
'Expires': DEFAULT_EXPIRES
},
auth: {