mirror of
https://github.com/jambonz/sbc-sip-sidecar.git
synced 2026-01-24 22:27:52 +00:00
feat: update voip carriers register status
This commit is contained in:
6
app.js
6
app.js
@@ -25,7 +25,8 @@ const {
|
||||
lookupSipGatewaysByCarrier,
|
||||
lookupAccountBySipRealm,
|
||||
lookupAccountCapacitiesBySid,
|
||||
addSbcAddress
|
||||
addSbcAddress,
|
||||
updateVoipCarriersRegisterStatus
|
||||
} = require('@jambonz/db-helpers')({
|
||||
host: process.env.JAMBONES_MYSQL_HOST,
|
||||
user: process.env.JAMBONES_MYSQL_USER,
|
||||
@@ -69,7 +70,8 @@ srf.locals = {
|
||||
lookupAllVoipCarriers,
|
||||
lookupSipGatewaysByCarrier,
|
||||
lookupAccountBySipRealm,
|
||||
lookupAccountCapacitiesBySid
|
||||
lookupAccountCapacitiesBySid,
|
||||
updateVoipCarriersRegisterStatus
|
||||
},
|
||||
realtimeDbHelpers: {
|
||||
addKey,
|
||||
|
||||
@@ -54,6 +54,7 @@ class Regbot {
|
||||
}
|
||||
|
||||
async register(srf) {
|
||||
const { updateVoipCarriersRegisterStatus } = srf.locals.dbHelpers;
|
||||
try {
|
||||
const contactAddress = this.use_public_ip_in_contact ?
|
||||
`${this.username}@${srf.locals.sbcPublicIpAddress}` : this.aor;
|
||||
@@ -90,11 +91,20 @@ class Regbot {
|
||||
debug(`setting timer for next register to ${expires} seconds`);
|
||||
this.timer = setTimeout(this.register.bind(this, srf), (expires - 5) * 1000);
|
||||
}
|
||||
updateVoipCarriersRegisterStatus({
|
||||
status: res.status === 200 ? 'ok' : 'fail',
|
||||
reason: `${res.status} ${res.reason}`
|
||||
});
|
||||
});
|
||||
} catch (err) {
|
||||
this.logger.error({ err }, `Regbot Error registering to ${this.ipv4}:${this.port}`);
|
||||
this.timer = setTimeout(this.register.bind(this, srf), 60 * 1000);
|
||||
updateVoipCarriersRegisterStatus({
|
||||
status: 'fail',
|
||||
reason: err
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user