fix regbot to send REGISTER headers with from user value

This commit is contained in:
Quan HL
2023-06-30 11:38:32 +07:00
parent 48e8cf418f
commit 6829a63dfa
+7 -6
View File
@@ -40,21 +40,21 @@ class Regbot {
this.port = opts.port; this.port = opts.port;
this.use_public_ip_in_contact = opts.use_public_ip_in_contact || process.env.JAMBONES_REGBOT_CONTACT_USE_IP; 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; const fromDomain = opts.from_domain || this.sip_realm;
this.from = `sip:${fromUser}@${fromDomain}`; this.from = `sip:${this.fromUser}@${fromDomain}`;
this.aor = `${this.username}@${this.sip_realm}`; this.aor = `${this.fromUser}@${this.sip_realm}`;
this.status = 'none'; this.status = 'none';
} }
start(srf) { 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); assert(!this.timer);
this.register(srf); this.register(srf);
} }
stop() { stop() {
this.logger.info(`stopping regbot ${this.username}@${this.sip_realm}`); this.logger.info(`stopping regbot ${this.fromUser}@${this.sip_realm}`);
clearTimeout(this.timer); clearTimeout(this.timer);
} }
@@ -62,6 +62,7 @@ class Regbot {
return { return {
voip_carrier_sid: this.voip_carrier_sid, voip_carrier_sid: this.voip_carrier_sid,
username: this.username, username: this.username,
fromUser: this.fromUser,
sip_realm: this.sip_realm, sip_realm: this.sip_realm,
ipv4: this.ipv4, ipv4: this.ipv4,
port: this.port, port: this.port,
@@ -74,7 +75,7 @@ class Regbot {
const { updateVoipCarriersRegisterStatus } = srf.locals.dbHelpers; const { updateVoipCarriersRegisterStatus } = srf.locals.dbHelpers;
try { try {
const contactAddress = this.use_public_ip_in_contact ? 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}`); this.logger.debug(`sending REGISTER for ${this.aor}`);
const req = await srf.request(`sip:${this.aor}`, { const req = await srf.request(`sip:${this.aor}`, {
method: 'REGISTER', method: 'REGISTER',