mirror of
https://github.com/jambonz/sbc-inbound.git
synced 2025-12-19 04:37:43 +00:00
bugfix: setting public ip and handling options ping
This commit is contained in:
2
app.js
2
app.js
@@ -48,7 +48,7 @@ if (process.env.DRACHTIO_HOST) {
|
||||
const last = hp.split(',').pop();
|
||||
const arr = /^(.*)\/(.*):(\d+)$/.exec(last);
|
||||
logger.info(`connected to drachtio listening on ${hp}: adding ${arr[2]} to sbc_addresses table`);
|
||||
addSbcAddress(arr[1]);
|
||||
addSbcAddress(arr[2]);
|
||||
});
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -21,17 +21,18 @@ module.exports = (srf, logger) => {
|
||||
const status = req.get('X-FS-Status');
|
||||
const calls = req.has('X-FS-Calls') ? parseInt(req.get('X-FS-Calls')) : 0;
|
||||
if (status === 'open') {
|
||||
if (!contacts.has(uri)) {
|
||||
const adding = !contacts.has(uri);
|
||||
debug(`Feature server at ${uri} has ${calls} calls`);
|
||||
contacts.set(uri, {pingTime: new Date(), calls: calls});
|
||||
if (adding) {
|
||||
logger.info(`adding feature server at ${uri}`);
|
||||
stats.gauge('sbc.featureservers.count', contacts.size + 1);
|
||||
stats.gauge('sbc.featureservers.count', contacts.size);
|
||||
const featureServerIps = [...contacts.keys()].map((uri) => {
|
||||
const arr = /^(.*):\d+$/.exec(uri);
|
||||
return arr[1];
|
||||
});
|
||||
createSet(setName, new Set(featureServerIps));
|
||||
}
|
||||
debug(`Feature server at ${uri} has ${calls} calls`);
|
||||
contacts.set(uri, {pingTime: new Date(), calls: calls});
|
||||
}
|
||||
else {
|
||||
if (contacts.has(uri)) {
|
||||
@@ -48,15 +49,6 @@ module.exports = (srf, logger) => {
|
||||
}
|
||||
});
|
||||
|
||||
if (process.env.JAMBONES_FEATURE_SERVERS) {
|
||||
dynamic = false;
|
||||
process.env.JAMBONES_FEATURE_SERVERS
|
||||
.split(',')
|
||||
.map((hp) => hp.trim())
|
||||
.forEach((uri) => contacts.set(uri, {active: 0, calls: 0}));
|
||||
debug(`using static list of feature servers: ${[ ...contacts]}`);
|
||||
}
|
||||
|
||||
if (dynamic) {
|
||||
const CHECK_INTERVAL = 35;
|
||||
setInterval(() => {
|
||||
|
||||
Reference in New Issue
Block a user