add new fieds for ICE and DTLS (#538)

This commit is contained in:
Sam Machin
2026-01-29 18:42:07 +00:00
committed by GitHub
parent 77dbe964aa
commit bc26651cdb
4 changed files with 72 additions and 2 deletions
+2
View File
@@ -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';
+6 -1
View File
@@ -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..');
+8
View File
@@ -66,6 +66,14 @@ SipGateway.fields = [
{
name: 'protocol',
type: 'string'
},
{
name: 'remove_ice',
type: 'number'
},
{
name: 'dtls_off',
type: 'number'
}
];
+56 -1
View File
@@ -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();