Merge pull request #36 from jambonz/fix/register_auth

fix regbot to send REGISTER headers with from user value
This commit is contained in:
Dave Horton
2023-07-03 15:26:28 +01:00
committed by GitHub

View File

@@ -40,21 +40,21 @@ class Regbot {
this.port = opts.port;
this.use_public_ip_in_contact = opts.use_public_ip_in_contact || process.env.JAMBONES_REGBOT_CONTACT_USE_IP;
const fromUser = opts.from_user || this.username;
this.fromUser = opts.from_user || this.username;
const fromDomain = opts.from_domain || this.sip_realm;
this.from = `sip:${fromUser}@${fromDomain}`;
this.aor = `${this.username}@${this.sip_realm}`;
this.from = `sip:${this.fromUser}@${fromDomain}`;
this.aor = `${this.fromUser}@${this.sip_realm}`;
this.status = 'none';
}
start(srf) {
this.logger.info(`starting regbot ${this.username}@${this.sip_realm}`);
this.logger.info(`starting regbot ${this.fromUser}@${this.sip_realm}`);
assert(!this.timer);
this.register(srf);
}
stop() {
this.logger.info(`stopping regbot ${this.username}@${this.sip_realm}`);
this.logger.info(`stopping regbot ${this.fromUser}@${this.sip_realm}`);
clearTimeout(this.timer);
}
@@ -62,6 +62,7 @@ class Regbot {
return {
voip_carrier_sid: this.voip_carrier_sid,
username: this.username,
fromUser: this.fromUser,
sip_realm: this.sip_realm,
ipv4: this.ipv4,
port: this.port,
@@ -74,7 +75,7 @@ class Regbot {
const { updateVoipCarriersRegisterStatus } = srf.locals.dbHelpers;
try {
const contactAddress = this.use_public_ip_in_contact ?
`${this.username}@${srf.locals.sbcPublicIpAddress}` : this.aor;
`${this.fromUser}@${srf.locals.sbcPublicIpAddress}` : this.aor;
this.logger.debug(`sending REGISTER for ${this.aor}`);
const req = await srf.request(`sip:${this.aor}`, {
method: 'REGISTER',