Skip to content

Commit

Permalink
support use sips scheme for outbound tls gateway
Browse files Browse the repository at this point in the history
  • Loading branch information
xquanluu committed Jun 15, 2024
1 parent 6041b1d commit 9e1e43e
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 5 deletions.
1 change: 1 addition & 0 deletions db/jambones-sql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ outbound BOOLEAN NOT NULL COMMENT 'if true, include in least-cost routing when p
voip_carrier_sid CHAR(36) NOT NULL,
is_active BOOLEAN NOT NULL DEFAULT 1,
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',
PRIMARY KEY (sip_gateway_sid)
Expand Down
17 changes: 12 additions & 5 deletions db/jambones.sqs
Original file line number Diff line number Diff line change
Expand Up @@ -2332,7 +2332,7 @@
</location>
<size>
<width>281.00</width>
<height>260.00</height>
<height>280.00</height>
</size>
<zorder>7</zorder>
<SQLField>
Expand Down Expand Up @@ -2406,6 +2406,13 @@
<notNull><![CDATA[1]]></notNull>
<uid><![CDATA[E04C19A2-12BF-443F-AB61-96990224A18D]]></uid>
</SQLField>
<SQLField>
<name><![CDATA[use_sips_scheme]]></name>
<type><![CDATA[BOOLEAN]]></type>
<defaultValue><![CDATA[0]]></defaultValue>
<notNull><![CDATA[1]]></notNull>
<uid><![CDATA[5DCBDD48-913B-4580-B78C-9B06C939FEA8]]></uid>
</SQLField>
<SQLField>
<name><![CDATA[pad_crypto]]></name>
<type><![CDATA[BOOLEAN]]></type>
Expand Down Expand Up @@ -3111,11 +3118,11 @@
<SourceSidebarWidth><![CDATA[312.000000]]></SourceSidebarWidth>
<SQLEditorFileFormatVersion><![CDATA[4]]></SQLEditorFileFormatVersion>
<uid><![CDATA[58C99A00-06C9-478C-A667-C63842E088F3]]></uid>
<windowHeight><![CDATA[1027.000000]]></windowHeight>
<windowLocationX><![CDATA[1728.000000]]></windowLocationX>
<windowLocationY><![CDATA[65.000000]]></windowLocationY>
<windowHeight><![CDATA[1079.000000]]></windowHeight>
<windowLocationX><![CDATA[0.000000]]></windowLocationX>
<windowLocationY><![CDATA[0.000000]]></windowLocationY>
<windowScrollOrigin><![CDATA[{1, 0}]]></windowScrollOrigin>
<windowWidth><![CDATA[1675.000000]]></windowWidth>
<windowWidth><![CDATA[1676.000000]]></windowWidth>
</SQLDocumentInfo>
<AllowsIndexRenamingOnInsert><![CDATA[1]]></AllowsIndexRenamingOnInsert>
<defaultLabelExpanded><![CDATA[1]]></defaultLabelExpanded>
Expand Down
1 change: 1 addition & 0 deletions db/upgrade-jambonz-db.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ const sql = {
'ALTER TABLE sip_gateways ADD COLUMN send_options_ping BOOLEAN NOT NULL DEFAULT 0',
'ALTER TABLE applications MODIFY COLUMN speech_synthesis_voice VARCHAR(256)',
'ALTER TABLE applications MODIFY COLUMN fallback_speech_synthesis_voice VARCHAR(256)',
'ALTER TABLE sip_gateways ADD COLUMN use_sips_scheme BOOLEAN NOT NULL DEFAULT 0',
]
};

Expand Down
38 changes: 38 additions & 0 deletions test/sip-gateways.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,44 @@ 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 */
result = await request.post('/SipGateways', {
resolveWithFullResponse: true,
auth: authAdmin,
json: true,
body: {
voip_carrier_sid,
ipv4: '192.168.1.2',
netmask: 32,
inbound: true,
outbound: true,
protocol: 'tls',
use_sips_scheme: true
}
});
t.ok(result.statusCode === 201, 'successfully created sip gateway ');
const sipsSid = result.body.sid;

/* query one sip gateway */
result = await request.get(`/SipGateways/${sipsSid}`, {
auth: authAdmin,
json: true,
});
//console.log(`result: ${JSON.stringify(result)}`);
t.ok(result.ipv4 === '192.168.1.2' , 'successfully retrieved voip carrier by sid');
t.ok(result.protocol === 'tls' , 'successfully retrieved voip carrier by sid');
t.ok(result.use_sips_scheme, 'successfully retrieved voip carrier by sid');

/* delete sip gateways */
result = await request.delete(`/SipGateways/${sipsSid}`, {
resolveWithFullResponse: true,
simple: false,
json: true,
auth: authAdmin
});
//console.log(`result: ${JSON.stringify(result)}`);
t.ok(result.statusCode === 204, 'successfully deleted sip gateway');

await deleteObjectBySid(request, '/VoipCarriers', voip_carrier_sid);

Expand Down

0 comments on commit 9e1e43e

Please sign in to comment.