add support for registration trunks which result in a set of ephemera… (#112)

* add support for registration trunks which result in a set of ephemeral sip gateways to be stored in redis

* wip

* refactor createEphemeralGateways into realtime dbhelpers

* minor

* update eslint
This commit is contained in:
Dave Horton
2025-10-21 07:32:06 -04:00
committed by GitHub
parent d08496840e
commit e94ae431d8
15 changed files with 697 additions and 783 deletions

View File

@@ -1 +0,0 @@
test/*

View File

@@ -1,126 +0,0 @@
{
"env": {
"node": true,
"es6": true
},
"parserOptions": {
"ecmaFeatures": {
"jsx": false,
"modules": false
},
"ecmaVersion": 2020
},
"plugins": ["promise"],
"rules": {
"promise/always-return": "error",
"promise/no-return-wrap": "error",
"promise/param-names": "error",
"promise/catch-or-return": "error",
"promise/no-native": "off",
"promise/no-nesting": "warn",
"promise/no-promise-in-callback": "warn",
"promise/no-callback-in-promise": "warn",
"promise/no-return-in-finally": "warn",
// Possible Errors
// http://eslint.org/docs/rules/#possible-errors
"comma-dangle": [2, "only-multiline"],
"no-control-regex": 2,
"no-debugger": 2,
"no-dupe-args": 2,
"no-dupe-keys": 2,
"no-duplicate-case": 2,
"no-empty-character-class": 2,
"no-ex-assign": 2,
"no-extra-boolean-cast" : 2,
"no-extra-parens": [2, "functions"],
"no-extra-semi": 2,
"no-func-assign": 2,
"no-invalid-regexp": 2,
"no-irregular-whitespace": 2,
"no-negated-in-lhs": 2,
"no-obj-calls": 2,
"no-proto": 2,
"no-unexpected-multiline": 2,
"no-unreachable": 2,
"use-isnan": 2,
"valid-typeof": 2,
// Best Practices
// http://eslint.org/docs/rules/#best-practices
"no-fallthrough": 2,
"no-octal": 2,
"no-redeclare": 2,
"no-self-assign": 2,
"no-unused-labels": 2,
// Strict Mode
// http://eslint.org/docs/rules/#strict-mode
"strict": [2, "never"],
// Variables
// http://eslint.org/docs/rules/#variables
"no-delete-var": 2,
"no-undef": 2,
"no-unused-vars": [2, {"args": "none"}],
// Node.js and CommonJS
// http://eslint.org/docs/rules/#nodejs-and-commonjs
"no-mixed-requires": 2,
"no-new-require": 2,
"no-path-concat": 2,
"no-restricted-modules": [2, "sys", "_linklist"],
// Stylistic Issues
// http://eslint.org/docs/rules/#stylistic-issues
"comma-spacing": 2,
"eol-last": 2,
"indent": [2, 2, {"SwitchCase": 1}],
"keyword-spacing": 2,
"max-len": [2, 120, 2],
"new-parens": 2,
"no-mixed-spaces-and-tabs": 2,
"no-multiple-empty-lines": [2, {"max": 2}],
"no-trailing-spaces": [2, {"skipBlankLines": false }],
"quotes": [2, "single", "avoid-escape"],
"semi": 2,
"space-before-blocks": [2, "always"],
"space-before-function-paren": [2, "never"],
"space-in-parens": [2, "never"],
"space-infix-ops": 2,
"space-unary-ops": 2,
// ECMAScript 6
// http://eslint.org/docs/rules/#ecmascript-6
"arrow-parens": [2, "always"],
"arrow-spacing": [2, {"before": true, "after": true}],
"constructor-super": 2,
"no-class-assign": 2,
"no-confusing-arrow": 2,
"no-const-assign": 2,
"no-dupe-class-members": 2,
"no-new-symbol": 2,
"no-this-before-super": 2,
"prefer-const": 2
},
"globals": {
"DTRACE_HTTP_CLIENT_REQUEST" : false,
"LTTNG_HTTP_CLIENT_REQUEST" : false,
"COUNTER_HTTP_CLIENT_REQUEST" : false,
"DTRACE_HTTP_CLIENT_RESPONSE" : false,
"LTTNG_HTTP_CLIENT_RESPONSE" : false,
"COUNTER_HTTP_CLIENT_RESPONSE" : false,
"DTRACE_HTTP_SERVER_REQUEST" : false,
"LTTNG_HTTP_SERVER_REQUEST" : false,
"COUNTER_HTTP_SERVER_REQUEST" : false,
"DTRACE_HTTP_SERVER_RESPONSE" : false,
"LTTNG_HTTP_SERVER_RESPONSE" : false,
"COUNTER_HTTP_SERVER_RESPONSE" : false,
"DTRACE_NET_STREAM_END" : false,
"LTTNG_NET_STREAM_END" : false,
"COUNTER_NET_SERVER_CONNECTION_CLOSE" : false,
"DTRACE_NET_SERVER_CONNECTION" : false,
"LTTNG_NET_SERVER_CONNECTION" : false,
"COUNTER_NET_SERVER_CONNECTION" : false
}
}

2
.gitignore vendored
View File

@@ -2,6 +2,8 @@
logs
*.log
CLAUDE.md
# Runtime data
pids
*.pid

6
app.js
View File

@@ -85,7 +85,8 @@ const {
addToSet,
removeFromSet,
isMemberOfSet,
retrieveSet
retrieveSet,
createEphemeralGateway,
} = require('@jambonz/realtimedb-helpers')({}, logger);
const interval = SBC_PUBLIC_ADDRESS_KEEP_ALIVE_IN_MILISECOND || 900000; // Default 15 minutes
@@ -116,7 +117,8 @@ srf.locals = {
addKey,
addKeyNx,
retrieveKey,
retrieveSet
retrieveSet,
createEphemeralGateway,
},
writeAlerts,
AlertType

137
eslint.config.js Normal file
View File

@@ -0,0 +1,137 @@
const promisePlugin = require('eslint-plugin-promise');
module.exports = [
{
ignores: ['test/*']
},
{
files: ['**/*.js'],
languageOptions: {
ecmaVersion: 2020,
sourceType: 'commonjs',
globals: {
// Node.js globals
console: 'readonly',
process: 'readonly',
Buffer: 'readonly',
__dirname: 'readonly',
__filename: 'readonly',
module: 'readonly',
require: 'readonly',
exports: 'readonly',
setTimeout: 'readonly',
clearTimeout: 'readonly',
setInterval: 'readonly',
clearInterval: 'readonly',
setImmediate: 'readonly',
clearImmediate: 'readonly',
// DTrace/LTTNG globals
DTRACE_HTTP_CLIENT_REQUEST: false,
LTTNG_HTTP_CLIENT_REQUEST: false,
COUNTER_HTTP_CLIENT_REQUEST: false,
DTRACE_HTTP_CLIENT_RESPONSE: false,
LTTNG_HTTP_CLIENT_RESPONSE: false,
COUNTER_HTTP_CLIENT_RESPONSE: false,
DTRACE_HTTP_SERVER_REQUEST: false,
LTTNG_HTTP_SERVER_REQUEST: false,
COUNTER_HTTP_SERVER_REQUEST: false,
DTRACE_HTTP_SERVER_RESPONSE: false,
LTTNG_HTTP_SERVER_RESPONSE: false,
COUNTER_HTTP_SERVER_RESPONSE: false,
DTRACE_NET_STREAM_END: false,
LTTNG_NET_STREAM_END: false,
COUNTER_NET_SERVER_CONNECTION_CLOSE: false,
DTRACE_NET_SERVER_CONNECTION: false,
LTTNG_NET_SERVER_CONNECTION: false,
COUNTER_NET_SERVER_CONNECTION: false
}
},
plugins: {
promise: promisePlugin
},
rules: {
// Promise plugin rules
'promise/always-return': 'error',
'promise/no-return-wrap': 'error',
'promise/param-names': 'error',
'promise/catch-or-return': 'error',
'promise/no-native': 'off',
'promise/no-nesting': 'warn',
'promise/no-promise-in-callback': 'warn',
'promise/no-callback-in-promise': 'warn',
'promise/no-return-in-finally': 'warn',
// Possible Errors
'comma-dangle': [2, 'only-multiline'],
'no-control-regex': 2,
'no-debugger': 2,
'no-dupe-args': 2,
'no-dupe-keys': 2,
'no-duplicate-case': 2,
'no-empty-character-class': 2,
'no-ex-assign': 2,
'no-extra-boolean-cast': 2,
'no-extra-parens': [2, 'functions'],
'no-extra-semi': 2,
'no-func-assign': 2,
'no-invalid-regexp': 2,
'no-irregular-whitespace': 2,
'no-obj-calls': 2,
'no-proto': 2,
'no-unexpected-multiline': 2,
'no-unreachable': 2,
'use-isnan': 2,
'valid-typeof': 2,
// Best Practices
'no-fallthrough': 2,
'no-octal': 2,
'no-redeclare': 2,
'no-self-assign': 2,
'no-unused-labels': 2,
// Strict Mode
'strict': [2, 'never'],
// Variables
'no-delete-var': 2,
'no-undef': 2,
'no-unused-vars': [2, {args: 'none'}],
// Node.js and CommonJS
'no-mixed-requires': 2,
'no-new-require': 2,
'no-path-concat': 2,
// Stylistic Issues
'comma-spacing': 2,
'eol-last': 2,
'indent': [2, 2, {SwitchCase: 1}],
'keyword-spacing': 2,
'max-len': [2, 120, 2],
'new-parens': 2,
'no-mixed-spaces-and-tabs': 2,
'no-multiple-empty-lines': [2, {max: 2}],
'no-trailing-spaces': [2, {skipBlankLines: false}],
'quotes': [2, 'single', 'avoid-escape'],
'semi': 2,
'space-before-blocks': [2, 'always'],
'space-before-function-paren': [2, 'never'],
'space-in-parens': [2, 'never'],
'space-infix-ops': 2,
'space-unary-ops': 2,
// ECMAScript 6
'arrow-parens': [2, 'always'],
'arrow-spacing': [2, {before: true, after: true}],
'constructor-super': 2,
'no-class-assign': 2,
'no-confusing-arrow': 2,
'no-const-assign': 2,
'no-dupe-class-members': 2,
'no-new-symbol': 2,
'no-this-before-super': 2,
'prefer-const': 2
}
}
];

View File

@@ -1,3 +1,4 @@
const dns = require('dns').promises;
const {
JAMBONES_REGBOT_DEFAULT_EXPIRES_INTERVAL,
JAMBONES_REGBOT_MIN_EXPIRES_INTERVAL,
@@ -17,24 +18,20 @@ class Regbot {
this.logger = logger;
[
'voip_carrier_sid',
'ipv4',
'port',
'username',
'password',
'sip_realm',
'protocol',
'account_sip_realm'
'account_sip_realm',
'outbound_sip_proxy',
'trunk_type'
].forEach((prop) => this[prop] = opts[prop]);
this.voip_carrier_sid = opts.voip_carrier_sid;
this.username = opts.username;
this.password = opts.password;
this.sip_realm = opts.sip_realm || opts.ipv4;
this.ipv4 = opts.ipv4;
this.port = opts.port;
this.use_public_ip_in_contact = opts.use_public_ip_in_contact || JAMBONES_REGBOT_CONTACT_USE_IP;
this.use_sips_scheme = opts.use_sips_scheme || false;
this.outbound_sip_proxy = opts.outbound_sip_proxy;
this.fromUser = opts.from_user || this.username;
const fromDomain = opts.from_domain || this.sip_realm;
@@ -72,6 +69,7 @@ class Regbot {
}
async register(srf) {
const { createEphemeralGateway } = srf.locals.realtimeDbHelpers;
const { updateVoipCarriersRegisterStatus } = srf.locals.dbHelpers;
const { writeAlerts, localSIPDomain } = srf.locals;
try {
@@ -183,6 +181,8 @@ class Regbot {
this.timer = setTimeout(this.register.bind(this, srf), (expires / 2) * 1000);
}
const timestamp = new Date().toISOString();
//update registration status for the carrier in the database
updateVoipCarriersRegisterStatus(this.voip_carrier_sid, JSON.stringify({
status: res.status === 200 ? 'ok' : 'fail',
reason: `${res.status} ${res.reason}`,
@@ -191,6 +191,31 @@ class Regbot {
timestamp: timestamp,
expires: expires
}));
// for reg trunks, create ephemeral set of IP addresses for inbound gateways
if (this.trunk_type === 'reg') {
const addresses = [];
if (this.port) {
const addrs = await dnsResolverA(this.logger, this.sip_realm);
addresses.push(...addrs);
}
else {
const addrs = await dnsResolverSrv(this.logger, this.sip_realm, this.transport);
addresses.push(...addrs);
}
if (addresses.length) {
try {
await Promise.all(
addresses.map((ip) => createEphemeralGateway(ip, this.voip_carrier_sid, expires))
);
} catch (err) {
this.logger.error({addresses, err}, 'Error creating hash for reg-gateway');
}
this.logger.debug({addresses},
`Created ephemeral gateways for registration trunk ${this.voip_carrier_sid}, ${this.sip_realm}`);
}
}
});
} catch (err) {
this.logger.error({ err }, `${this.aor}: Error registering to ${this.ipv4}:${this.port}`);
@@ -204,5 +229,44 @@ class Regbot {
}
}
const dnsResolverA = async(logger, hostname) => {
try {
const addresses = await dns.resolve4(hostname);
logger.debug({addresses}, `Regbot: resolved ${hostname} into ${addresses.length} IPs`);
return addresses;
} catch (err) {
logger.info({err}, `Error resolving ${hostname}`);
}
return [];
};
const dnsResolverSrv = async(logger, hostname, transport) => {
let name;
switch (transport) {
case 'tls':
name = `_sips._tcp.${hostname}`;
break;
case 'tcp':
name = `_sip._tcp.${hostname}`;
break;
default:
name = `_sip._udp.${hostname}`;
}
try {
const arr = await dns.resolveSrv(name);
logger.debug({arr}, `Regbot: resolved ${hostname}/${transport} into ${arr.length} results`);
const ips = await Promise.all(
arr.map((obj) => dnsResolverA(logger, obj.name))
);
return ips.flat();
}
catch (err) {
logger.info({err}, `SRV Error resolving ${hostname}`);
}
return [];
};
module.exports = Regbot;

View File

@@ -18,6 +18,7 @@ const regbots = [];
const carriers = [];
const gateways = [];
const getCountSuccessfulRegbots = () => regbots.filter((rb) => rb.status === 'registered').length;
function pickRelevantCarrierProperties(c) {
return {
@@ -32,6 +33,7 @@ function pickRelevantCarrierProperties(c) {
register_public_ip_in_contact: c.register_public_ip_in_contact,
outbound_sip_proxy: c.outbound_sip_proxy,
account_sid: c.account_sid,
trunk_type: c.trunk_type || 'static_ip'
};
}
@@ -91,6 +93,14 @@ module.exports = async(logger, srf) => {
active: false
};
srf.locals.regbotStatus = () => {
return {
total: regbots.length,
registered: getCountSuccessfulRegbots(),
active: srf.locals.regbot.active
};
};
/* Set the Local SIP domain on srf.locals */
await getLocalSIPDomain(logger, srf); // Initial Setup
setInterval(getLocalSIPDomain, 300000, logger, srf); //Refresh SIP Domain every 5 mins
@@ -209,11 +219,10 @@ const updateCarrierRegbots = async(logger, srf) => {
}
}
if (JSON.stringify(gws) !== JSON.stringify(gateways)) hasChanged = true;
if (hasChanged) {
debug('updateCarrierRegbots: got new or changed carriers');
logger.info('updateCarrierRegbots: got new or changed carriers');
logger.info({gws}, 'updateCarrierRegbots: got new or changed carriers');
carriers.length = 0;
Array.prototype.push.apply(carriers, cs);
@@ -248,7 +257,8 @@ const updateCarrierRegbots = async(logger, srf) => {
from_user: gw.carrier.register_from_user,
from_domain: gw.carrier.register_from_domain,
use_public_ip_in_contact: gw.carrier.register_public_ip_in_contact,
outbound_sip_proxy: gw.carrier.outbound_sip_proxy
outbound_sip_proxy: gw.carrier.outbound_sip_proxy,
trunk_type: gw.carrier.trunk_type
});
regbots.push(rb);
rb.start(srf);

1048
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -31,20 +31,20 @@
"@jambonz/db-helpers": "^0.9.18",
"@jambonz/digest-utils": "^0.0.6",
"@jambonz/mw-registrar": "^0.2.7",
"@jambonz/realtimedb-helpers": "^0.8.13",
"@jambonz/realtimedb-helpers": "^0.8.18",
"@jambonz/stats-collector": "^0.1.10",
"@jambonz/time-series": "^0.2.8",
"debug": "^4.3.4",
"drachtio-mw-registration-parser": "^0.1.2",
"drachtio-mw-response-time": "^1.0.2",
"drachtio-srf": "^5.0.5",
"pino": "^8.20.0",
"pino": "^10.1.0",
"short-uuid": "^4.2.2"
},
"devDependencies": {
"clear-module": "^4.1.2",
"eslint": "^7.32.0",
"eslint-plugin-promise": "^6.1.1",
"eslint": "^9.17.0",
"eslint-plugin-promise": "^7.2.1",
"nyc": "^15.1.0",
"tape": "^5.7.5"
}

View File

@@ -1,5 +1,4 @@
/* SQLEditor (MySQL (2))*/
SET FOREIGN_KEY_CHECKS=0;
DROP TABLE IF EXISTS account_static_ips;
@@ -351,6 +350,8 @@ speech_credential_sid CHAR(36) NOT NULL,
model VARCHAR(512) NOT NULL,
reported_usage ENUM('REPORTED_USAGE_UNSPECIFIED','REALTIME','OFFLINE') DEFAULT 'REALTIME',
name VARCHAR(64) NOT NULL,
voice_cloning_key MEDIUMTEXT,
use_voice_cloning_key BOOLEAN DEFAULT false,
PRIMARY KEY (google_custom_voice_sid)
);
@@ -358,7 +359,9 @@ CREATE TABLE system_information
(
domain_name VARCHAR(255),
sip_domain_name VARCHAR(255),
monitoring_domain_name VARCHAR(255)
monitoring_domain_name VARCHAR(255),
private_network_cidr VARCHAR(8192),
log_level ENUM('info', 'debug') NOT NULL DEFAULT 'info'
);
CREATE TABLE users
@@ -412,6 +415,9 @@ register_from_user VARCHAR(128),
register_from_domain VARCHAR(255),
register_public_ip_in_contact BOOLEAN NOT NULL DEFAULT false,
register_status VARCHAR(4096),
dtmf_type ENUM('rfc2833','tones','info') NOT NULL DEFAULT 'rfc2833',
outbound_sip_proxy VARCHAR(255),
trunk_type ENUM('static_ip','auth','reg') NOT NULL DEFAULT 'static_ip',
PRIMARY KEY (voip_carrier_sid)
) COMMENT='A Carrier or customer PBX that can send or receive calls';
@@ -497,7 +503,7 @@ messaging_hook_sid CHAR(36) COMMENT 'webhook to call for inbound SMS/MMS ',
app_json TEXT,
speech_synthesis_vendor VARCHAR(64) NOT NULL DEFAULT 'google',
speech_synthesis_language VARCHAR(12) NOT NULL DEFAULT 'en-US',
speech_synthesis_voice VARCHAR(256),
speech_synthesis_voice VARCHAR(256) DEFAULT 'en-US-Standard-C',
speech_synthesis_label VARCHAR(64),
speech_recognizer_vendor VARCHAR(64) NOT NULL DEFAULT 'google',
speech_recognizer_language VARCHAR(64) NOT NULL DEFAULT 'en-US',
@@ -510,6 +516,7 @@ fallback_speech_synthesis_label VARCHAR(64),
fallback_speech_recognizer_vendor VARCHAR(64),
fallback_speech_recognizer_language VARCHAR(64),
fallback_speech_recognizer_label VARCHAR(64),
env_vars TEXT,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
record_all_calls BOOLEAN NOT NULL DEFAULT false,
PRIMARY KEY (application_sid)
@@ -552,6 +559,7 @@ siprec_hook_sid CHAR(36),
record_all_calls BOOLEAN NOT NULL DEFAULT false,
record_format VARCHAR(16) NOT NULL DEFAULT 'mp3',
bucket_credential VARCHAR(8192) COMMENT 'credential used to authenticate with storage service',
enable_debug_log BOOLEAN NOT NULL DEFAULT false,
PRIMARY KEY (account_sid)
) COMMENT='An enterprise that uses the platform for comm services';
@@ -736,4 +744,4 @@ ALTER TABLE accounts ADD FOREIGN KEY device_calling_application_sid_idxfk (devic
ALTER TABLE accounts ADD FOREIGN KEY siprec_hook_sid_idxfk (siprec_hook_sid) REFERENCES applications (application_sid);
SET FOREIGN_KEY_CHECKS=1;
SET FOREIGN_KEY_CHECKS=1;

View File

@@ -1,4 +1,4 @@
insert into voip_carriers (voip_carrier_sid, name, e164_leading_plus, requires_register, register_username, register_sip_realm, register_password, register_from_user, register_from_domain, register_public_ip_in_contact)
values ('287c1452-620d-4195-9f19-c9814ef90d78', 'westco', 1, 1, 'foo', 'sip.jambonz.org', 'bar', 'reguser', 'regdomain', 0);
insert into sip_gateways (sip_gateway_sid, voip_carrier_sid, ipv4, inbound, outbound, send_options_ping)
values ('124a5339-c62c-4075-9e19-f4de70a96597', '287c1452-620d-4195-9f19-c9814ef90d78', '172.39.0.14', true, true, true);
insert into sip_gateways (sip_gateway_sid, voip_carrier_sid, ipv4, port, inbound, outbound, send_options_ping)
values ('124a5339-c62c-4075-9e19-f4de70a96597', '287c1452-620d-4195-9f19-c9814ef90d78', '172.39.0.14', 5060, true, true, true);

View File

@@ -1,2 +1,2 @@
insert into sip_gateways (sip_gateway_sid, voip_carrier_sid, ipv4, inbound, outbound)
values ('987a5339-c62c-4075-9e19-f4de70a96597', '287c1452-620d-4195-9f19-c9814ef90d78', '172.39.0.15', false, true);
insert into sip_gateways (sip_gateway_sid, voip_carrier_sid, ipv4, port, inbound, outbound)
values ('987a5339-c62c-4075-9e19-f4de70a96597', '287c1452-620d-4195-9f19-c9814ef90d78', '172.39.0.15', 5060, false, true);

View File

@@ -0,0 +1,6 @@
delete from sip_gateways;
delete from voip_carriers;
insert into voip_carriers (voip_carrier_sid, name, e164_leading_plus, requires_register, register_username, register_sip_realm, register_password, register_from_user, register_public_ip_in_contact, trunk_type)
values ('287c1452-620d-4195-9f19-c9814ef90d78', 'westco', 1, 1, 'daveh', 'beachdog.sip.jambonz.cloud', 'foobarbazzle', 'daveh', 0, 'reg');
insert into sip_gateways (sip_gateway_sid, voip_carrier_sid, ipv4, port, inbound, outbound, send_options_ping)
values ('124a5339-c62c-4075-9e19-f4de70a96597', '287c1452-620d-4195-9f19-c9814ef90d78', 'beachdog.sip.jambonz.cloud', 5060, false, true, false);

View File

@@ -1,6 +1,6 @@
require('./docker_start');
require('./create-test-db');
// require('./regbot-tests');
require('./regbot-tests');
require('./regbot-unit-test');
require('./sip-register-tests');
require('./sip-options-tests');

View File

@@ -48,10 +48,11 @@ test('populating more test case data', (t) => {
test('trunk register tests', (t) => {
clearModule.all();
const { srf } = require('../app');
t.timeoutAfter(60000);
t.timeoutAfter(180000);
console.log('waiting 15 seconds for regbot to start up');
connect(srf)
.then(wait.bind(null, 1500))
.then(wait.bind(null, 15000))
.then(() => {
const obj = srf.locals.regbotStatus();
return t.ok(obj.total === 1 && obj.registered === 1, 'initial regbot running and successfully registered to trunk');
@@ -66,21 +67,27 @@ test('trunk register tests', (t) => {
});
})
.then(() => {
return wait(35000);
console.log('waiting 65 seconds for regbot to come around to check for new gateways');
return wait(65000);
})
.then(() => {
const obj = srf.locals.regbotStatus();
//console.log({obj}, 'regbot status after adding new gateway');
return t.ok(obj.total === 2 && obj.registered === 1, 'successfully added gateway that tests failure result');
})
.then(() => {
return new Promise((resolve, reject) => {
exec(`mysql -h 127.0.0.1 -u root --protocol=tcp -D jambones_test -e "delete from sip_gateways where sip_gateway_sid = '987a5339-c62c-4075-9e19-f4de70a96597'"`, (err, stdout, stderr) => {
exec(`mysql -h 127.0.0.1 -u root --protocol=tcp -D jambones_test < ${__dirname}/db/populate-test-data4.sql`, (err, stdout, stderr) => {
if (err) return reject(err);
t.pass('added new gateway');
t.pass('added new reg trunk');
resolve();
});
});
})
.then(() => {
console.log('waiting 65 seconds for regbot to come around to check for new reg trunk');
return wait(65000);
})
.then(() => {
if (srf.locals.lb) srf.locals.lb.disconnect();
srf.disconnect();
@@ -96,10 +103,11 @@ test('trunk register tests', (t) => {
});
});
/*
test('trunk register tests when its IP in redis cache', (t) => {
clearModule.all();
const { srf } = require('../app');
t.timeoutAfter(60000);
t.timeoutAfter(90000);
addToSet(setName, "172.39.0.10:5060");
connect(srf)
@@ -125,7 +133,6 @@ test('trunk register tests when its IP in redis cache', (t) => {
});
});
test('trunk register with sbc public IP address', (t) => {
clearModule.all();
const { srf } = require('../app');
@@ -195,4 +202,5 @@ test('trunk not register tests when its IP is not in redis cache', (t) => {
console.log(`error received: ${err}`);
t.error(err);
});
});
});
*/