mirror of
https://github.com/jambonz/sbc-sip-sidecar.git
synced 2026-01-24 22:27:52 +00:00
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:
@@ -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;
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
6
test/db/populate-test-data4.sql
Normal file
6
test/db/populate-test-data4.sql
Normal 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);
|
||||
@@ -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');
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
*/
|
||||
Reference in New Issue
Block a user