diff --git a/db/jambones-sql.sql b/db/jambones-sql.sql index fcaa874..5fd9dab 100644 --- a/db/jambones-sql.sql +++ b/db/jambones-sql.sql @@ -470,6 +470,8 @@ send_options_ping BOOLEAN NOT NULL DEFAULT 0, use_sips_scheme BOOLEAN NOT NULL DEFAULT 0, pad_crypto BOOLEAN NOT NULL DEFAULT 0, protocol ENUM('udp','tcp','tls', 'tls/srtp') DEFAULT 'udp' COMMENT 'Outbound call protocol', +remove_ice BOOLEAN NOT NULL DEFAULT 0, +dtls_off BOOLEAN NOT NULL DEFAULT 0, PRIMARY KEY (sip_gateway_sid) ) COMMENT='A whitelisted sip gateway used for origination/termination'; diff --git a/db/upgrade-jambonz-db.js b/db/upgrade-jambonz-db.js index afcbfa0..196bb01 100644 --- a/db/upgrade-jambonz-db.js +++ b/db/upgrade-jambonz-db.js @@ -235,9 +235,13 @@ const sql = { 'ALTER TABLE voip_carriers ADD COLUMN trunk_type ENUM(\'static_ip\',\'auth\',\'reg\') NOT NULL DEFAULT \'static_ip\'', 'ALTER TABLE predefined_carriers ADD COLUMN trunk_type ENUM(\'static_ip\',\'auth\',\'reg\') NOT NULL DEFAULT \'static_ip\'', 'CREATE INDEX idx_sip_gateways_inbound_carrier ON sip_gateways (inbound,voip_carrier_sid)', + ], + 9006: [ + 'ALTER TABLE sip_gateways ADD COLUMN remove_ice BOOLEAN NOT NULL DEFAULT 0', + 'ALTER TABLE sip_gateways ADD COLUMN dtls_off BOOLEAN NOT NULL DEFAULT 0', 'CREATE INDEX idx_sip_gateways_inbound_lookup ON sip_gateways (inbound,netmask,ipv4)', 'CREATE INDEX idx_sip_gateways_inbound_netmask ON sip_gateways (inbound,netmask)' - ], + ] }; const doIt = async() => { let connection; @@ -273,6 +277,7 @@ const doIt = async() => { if (val < 9003) upgrades.push(...sql['9003']); if (val < 9004) upgrades.push(...sql['9004']); if (val < 9005) upgrades.push(...sql['9005']); + if (val < 9006) upgrades.push(...sql['9006']); // perform all upgrades logger.info({upgrades}, 'applying schema upgrades..'); diff --git a/lib/models/sip-gateway.js b/lib/models/sip-gateway.js index ae6094d..7b5b315 100644 --- a/lib/models/sip-gateway.js +++ b/lib/models/sip-gateway.js @@ -66,6 +66,14 @@ SipGateway.fields = [ { name: 'protocol', type: 'string' + }, + { + name: 'remove_ice', + type: 'number' + }, + { + name: 'dtls_off', + type: 'number' } ]; diff --git a/test/sip-gateways.js b/test/sip-gateways.js index ad2d988..eab54a5 100644 --- a/test/sip-gateways.js +++ b/test/sip-gateways.js @@ -161,7 +161,62 @@ test('sip gateway tests', async(t) => { }); //console.log(`result: ${JSON.stringify(result)}`); t.ok(result.statusCode === 204, 'successfully deleted sip gateway'); - + + /* add a sip gateway with remove_ice and dtls_off */ + result = await request.post('/SipGateways', { + resolveWithFullResponse: true, + auth: authAdmin, + json: true, + body: { + voip_carrier_sid, + ipv4: '192.168.1.3', + netmask: 32, + inbound: true, + outbound: true, + remove_ice: true, + dtls_off: true + } + }); + t.ok(result.statusCode === 201, 'successfully created sip gateway with remove_ice and dtls_off'); + const iceDtlsSid = result.body.sid; + + /* query sip gateway with remove_ice and dtls_off */ + result = await request.get(`/SipGateways/${iceDtlsSid}`, { + auth: authAdmin, + json: true, + }); + t.ok(result.ipv4 === '192.168.1.3', 'successfully retrieved sip gateway by sid'); + t.ok(result.remove_ice === 1, 'remove_ice is set correctly'); + t.ok(result.dtls_off === 1, 'dtls_off is set correctly'); + + /* update sip gateway to disable remove_ice */ + result = await request.put(`/SipGateways/${iceDtlsSid}`, { + auth: authAdmin, + json: true, + resolveWithFullResponse: true, + body: { + remove_ice: false + } + }); + t.ok(result.statusCode === 204, 'successfully updated sip gateway remove_ice'); + + /* verify update */ + result = await request.get(`/SipGateways/${iceDtlsSid}`, { + auth: authAdmin, + json: true, + }); + t.ok(result.remove_ice === 0, 'remove_ice was updated correctly'); + t.ok(result.dtls_off === 1, 'dtls_off remains unchanged'); + + /* delete sip gateway */ + result = await request.delete(`/SipGateways/${iceDtlsSid}`, { + resolveWithFullResponse: true, + simple: false, + json: true, + auth: authAdmin + }); + t.ok(result.statusCode === 204, 'successfully deleted sip gateway with ice/dtls flags'); + await deleteObjectBySid(request, '/VoipCarriers', voip_carrier_sid); t.end();