mirror of
https://github.com/jambonz/sbc-sip-sidecar.git
synced 2025-12-19 04:27:46 +00:00
when registering over tls contact header should have appropriate sip … (#62)
* rebase * update gh workflow
This commit is contained in:
@@ -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: {
|
||||
|
||||
Reference in New Issue
Block a user