mirror of
https://github.com/jambonz/sbc-sip-sidecar.git
synced 2025-12-19 04:27:46 +00:00
fix register to support dns domain and transport
This commit is contained in:
@@ -30,7 +30,7 @@ class Regbot {
|
||||
constructor(logger, opts) {
|
||||
this.logger = logger;
|
||||
|
||||
['ipv4', 'port', 'username', 'password', 'sip_realm'].forEach((prop) => this[prop] = opts[prop]);
|
||||
['ipv4', 'port', 'username', 'password', 'sip_realm', 'protocol'].forEach((prop) => this[prop] = opts[prop]);
|
||||
|
||||
this.voip_carrier_sid = opts.voip_carrier_sid;
|
||||
this.username = opts.username;
|
||||
@@ -77,9 +77,13 @@ class Regbot {
|
||||
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 proxy = `sip:${this.ipv4}${isIPv4 ? `:${this.port}` : ''};transport=${transport}`;
|
||||
const req = await srf.request(`sip:${this.aor}`, {
|
||||
method: 'REGISTER',
|
||||
proxy: `sip:${this.ipv4}:${this.port}`,
|
||||
proxy,
|
||||
headers: {
|
||||
'From': this.from,
|
||||
'Contact': `<sip:${contactAddress}>;expires=${DEFAULT_EXPIRES}`,
|
||||
@@ -273,6 +277,7 @@ const updateCarrierRegbots = async(logger, srf) => {
|
||||
voip_carrier_sid: gw.carrier.voip_carrier_sid,
|
||||
ipv4: gw.ipv4,
|
||||
port: gw.port,
|
||||
protocol: gw.protocol,
|
||||
username: gw.carrier.register_username,
|
||||
password: gw.carrier.register_password,
|
||||
sip_realm: gw.carrier.register_sip_realm,
|
||||
|
||||
Reference in New Issue
Block a user