mirror of
https://github.com/jambonz/sbc-inbound.git
synced 2026-01-24 22:37:51 +00:00
migrate ci to github actions
This commit is contained in:
19
.github/workflows/npm-publish.yml
vendored
Normal file
19
.github/workflows/npm-publish.yml
vendored
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
name: CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-node@v1
|
||||||
|
with:
|
||||||
|
node-version: 12
|
||||||
|
- run: npm install
|
||||||
|
- run: npm run jslint
|
||||||
|
- run: npm test
|
||||||
|
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
# sbc-inbound [](http://travis-ci.org/jambonz/sbc-inbound)
|
# sbc-inbound 
|
||||||
|
|
||||||
This application provides a part of the SBC (Session Border Controller) functionality of jambonz. It handles incoming INVITE requests from carrier sip trunks or from sip devices and webrtc applications. SIP INVITEs from known carriers are allowed in, while INVITEs from sip devices are challenged to authenticate. SIP traffic that is allowed in is sent on to a jambonz application server in a private subnet.
|
This application provides a part of the SBC (Session Border Controller) functionality of jambonz. It handles incoming INVITE requests from carrier sip trunks or from sip devices and webrtc applications. SIP INVITEs from known carriers are allowed in, while INVITEs from sip devices are challenged to authenticate. SIP traffic that is allowed in is sent on to a jambonz application server in a private subnet.
|
||||||
|
|
||||||
|
|||||||
6
package-lock.json
generated
6
package-lock.json
generated
@@ -424,9 +424,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@jambonz/db-helpers": {
|
"@jambonz/db-helpers": {
|
||||||
"version": "0.5.3",
|
"version": "0.5.5",
|
||||||
"resolved": "https://registry.npmjs.org/@jambonz/db-helpers/-/db-helpers-0.5.3.tgz",
|
"resolved": "https://registry.npmjs.org/@jambonz/db-helpers/-/db-helpers-0.5.5.tgz",
|
||||||
"integrity": "sha512-3v366e5yzDbp5QZ3g/vgao78pXsCPXqWHUbf8timL3eSHv6BnfF/NlXt2qVwMP1ayZmFcGhygLSGYN2a+GOJQA==",
|
"integrity": "sha512-p+qtBjWUGaZ/+5NNfTbIDz7pcyEB4Kh4X1Egh+caGwQLGSm4lFIl0979wKpoW0/KLDFnG61QkQh1j50Ewq1Xmg==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"debug": "^4.3.1",
|
"debug": "^4.3.1",
|
||||||
"mysql2": "^2.2.5",
|
"mysql2": "^2.2.5",
|
||||||
|
|||||||
@@ -20,12 +20,12 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node app",
|
"start": "node app",
|
||||||
"test": "NODE_ENV=test JAMBONES_MYSQL_HOST=localhost JAMBONES_MYSQL_USER=jambones_test JAMBONES_MYSQL_PASSWORD=jambones_test JAMBONES_MYSQL_DATABASE=jambones_test JAMBONES_REDIS_HOST=localhost JAMBONES_REDIS_PORT=16379 JAMBONES_LOGLEVEL=error DRACHTIO_SECRET=cymru DRACHTIO_HOST=127.0.0.1 DRACHTIO_PORT=9060 JAMBONES_RTPENGINES=127.0.0.1:12222 JAMBONES_FEATURE_SERVERS=172.38.0.11 node test/ | ./node_modules/.bin/tap-spec",
|
"test": "NODE_ENV=test JAMBONES_MYSQL_HOST=127.0.0.1 JAMBONES_MYSQL_USER=jambones_test JAMBONES_MYSQL_PASSWORD=jambones_test JAMBONES_MYSQL_DATABASE=jambones_test JAMBONES_REDIS_HOST=localhost JAMBONES_REDIS_PORT=16379 JAMBONES_LOGLEVEL=error DRACHTIO_SECRET=cymru DRACHTIO_HOST=127.0.0.1 DRACHTIO_PORT=9060 JAMBONES_RTPENGINES=127.0.0.1:12222 JAMBONES_FEATURE_SERVERS=172.38.0.11 node test/ | ./node_modules/.bin/tap-spec",
|
||||||
"coverage": "./node_modules/.bin/nyc --reporter html --report-dir ./coverage npm run test",
|
"coverage": "./node_modules/.bin/nyc --reporter html --report-dir ./coverage npm run test",
|
||||||
"jslint": "eslint app.js lib"
|
"jslint": "eslint app.js lib"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@jambonz/db-helpers": "^0.5.3",
|
"@jambonz/db-helpers": "^0.5.5",
|
||||||
"@jambonz/realtimedb-helpers": "^0.2.20",
|
"@jambonz/realtimedb-helpers": "^0.2.20",
|
||||||
"@jambonz/rtpengine-utils": "^0.1.7",
|
"@jambonz/rtpengine-utils": "^0.1.7",
|
||||||
"@jambonz/stats-collector": "^0.1.4",
|
"@jambonz/stats-collector": "^0.1.4",
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ const exec = require('child_process').exec ;
|
|||||||
const pwd = process.env.TRAVIS ? '' : '-p$MYSQL_ROOT_PASSWORD';
|
const pwd = process.env.TRAVIS ? '' : '-p$MYSQL_ROOT_PASSWORD';
|
||||||
|
|
||||||
test('creating jambones_test database', (t) => {
|
test('creating jambones_test database', (t) => {
|
||||||
exec(`mysql -h localhost -u root ${pwd} < ${__dirname}/db/create_test_db.sql`, (err, stdout, stderr) => {
|
exec(`mysql -h 127.0.0.1 -u root --protocol=tcp < ${__dirname}/db/create_test_db.sql`, (err, stdout, stderr) => {
|
||||||
if (err) return t.end(err);
|
if (err) return t.end(err);
|
||||||
t.pass('database successfully created');
|
t.pass('database successfully created');
|
||||||
t.end();
|
t.end();
|
||||||
@@ -11,7 +11,7 @@ test('creating jambones_test database', (t) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('creating schema', (t) => {
|
test('creating schema', (t) => {
|
||||||
exec(`mysql -h localhost -u root ${pwd} -D jambones_test < ${__dirname}/db/jambones-sql.sql`, (err, stdout, stderr) => {
|
exec(`mysql -h 127.0.0.1 -u root --protocol=tcp -D jambones_test < ${__dirname}/db/jambones-sql.sql`, (err, stdout, stderr) => {
|
||||||
if (err) return t.end(err);
|
if (err) return t.end(err);
|
||||||
t.pass('schema successfully created');
|
t.pass('schema successfully created');
|
||||||
t.end();
|
t.end();
|
||||||
@@ -19,7 +19,7 @@ test('creating schema', (t) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('populating test case data', (t) => {
|
test('populating test case data', (t) => {
|
||||||
exec(`mysql -h localhost -u root ${pwd} -D jambones_test < ${__dirname}/db/populate-test-data.sql`, (err, stdout, stderr) => {
|
exec(`mysql -h 127.0.0.1 -u root --protocol=tcp -D jambones_test < ${__dirname}/db/populate-test-data.sql`, (err, stdout, stderr) => {
|
||||||
if (err) return t.end(err);
|
if (err) return t.end(err);
|
||||||
t.pass('test data set created');
|
t.pass('test data set created');
|
||||||
t.end();
|
t.end();
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
create database jambones_test;
|
create database jambones_test;
|
||||||
create user jambones_test@localhost IDENTIFIED WITH mysql_native_password by 'jambones_test';
|
create user jambones_test@'%' IDENTIFIED WITH mysql_native_password by 'jambones_test';
|
||||||
grant all on jambones_test.* to jambones_test@localhost;
|
grant all on jambones_test.* to jambones_test@'%';
|
||||||
|
|||||||
@@ -55,8 +55,8 @@ api_key_sid CHAR(36) NOT NULL UNIQUE ,
|
|||||||
token CHAR(36) NOT NULL UNIQUE ,
|
token CHAR(36) NOT NULL UNIQUE ,
|
||||||
account_sid CHAR(36),
|
account_sid CHAR(36),
|
||||||
service_provider_sid CHAR(36),
|
service_provider_sid CHAR(36),
|
||||||
expires_at TIMESTAMP NULL,
|
expires_at TIMESTAMP NULL DEFAULT NULL,
|
||||||
last_used TIMESTAMP NULL,
|
last_used TIMESTAMP NULL DEFAULT NULL,
|
||||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
PRIMARY KEY (api_key_sid)
|
PRIMARY KEY (api_key_sid)
|
||||||
) ENGINE=InnoDB COMMENT='An authorization token that is used to access the REST api';
|
) ENGINE=InnoDB COMMENT='An authorization token that is used to access the REST api';
|
||||||
@@ -98,6 +98,10 @@ description VARCHAR(255),
|
|||||||
account_sid CHAR(36) COMMENT 'if provided, indicates this entity represents a customer PBX that is associated with a specific account',
|
account_sid CHAR(36) COMMENT 'if provided, indicates this entity represents a customer PBX that is associated with a specific account',
|
||||||
application_sid CHAR(36) COMMENT 'If provided, all incoming calls from this source will be routed to the associated application',
|
application_sid CHAR(36) COMMENT 'If provided, all incoming calls from this source will be routed to the associated application',
|
||||||
e164_leading_plus BOOLEAN NOT NULL DEFAULT false,
|
e164_leading_plus BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
requires_register BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
register_username VARCHAR(64),
|
||||||
|
register_sip_realm VARCHAR(64),
|
||||||
|
register_password VARCHAR(64),
|
||||||
PRIMARY KEY (voip_carrier_sid)
|
PRIMARY KEY (voip_carrier_sid)
|
||||||
) ENGINE=InnoDB COMMENT='A Carrier or customer PBX that can send or receive calls';
|
) ENGINE=InnoDB COMMENT='A Carrier or customer PBX that can send or receive calls';
|
||||||
|
|
||||||
@@ -148,8 +152,9 @@ CREATE TABLE applications
|
|||||||
application_sid CHAR(36) NOT NULL UNIQUE ,
|
application_sid CHAR(36) NOT NULL UNIQUE ,
|
||||||
name VARCHAR(64) NOT NULL,
|
name VARCHAR(64) NOT NULL,
|
||||||
account_sid CHAR(36) NOT NULL COMMENT 'account that this application belongs to',
|
account_sid CHAR(36) NOT NULL COMMENT 'account that this application belongs to',
|
||||||
call_hook_sid CHAR(36) COMMENT 'webhook to call for inbound calls to phone numbers owned by this account',
|
call_hook_sid CHAR(36) COMMENT 'webhook to call for inbound calls ',
|
||||||
call_status_hook_sid CHAR(36) COMMENT 'webhook to call for call status events',
|
call_status_hook_sid CHAR(36) COMMENT 'webhook to call for call status events',
|
||||||
|
messaging_hook_sid CHAR(36) COMMENT 'webhook to call for inbound SMS/MMS ',
|
||||||
speech_synthesis_vendor VARCHAR(64) NOT NULL DEFAULT 'google',
|
speech_synthesis_vendor VARCHAR(64) NOT NULL DEFAULT 'google',
|
||||||
speech_synthesis_language VARCHAR(12) NOT NULL DEFAULT 'en-US',
|
speech_synthesis_language VARCHAR(12) NOT NULL DEFAULT 'en-US',
|
||||||
speech_synthesis_voice VARCHAR(64),
|
speech_synthesis_voice VARCHAR(64),
|
||||||
@@ -242,6 +247,8 @@ ALTER TABLE applications ADD FOREIGN KEY call_hook_sid_idxfk (call_hook_sid) REF
|
|||||||
|
|
||||||
ALTER TABLE applications ADD FOREIGN KEY call_status_hook_sid_idxfk (call_status_hook_sid) REFERENCES webhooks (webhook_sid);
|
ALTER TABLE applications ADD FOREIGN KEY call_status_hook_sid_idxfk (call_status_hook_sid) REFERENCES webhooks (webhook_sid);
|
||||||
|
|
||||||
|
ALTER TABLE applications ADD FOREIGN KEY messaging_hook_sid_idxfk (messaging_hook_sid) REFERENCES webhooks (webhook_sid);
|
||||||
|
|
||||||
CREATE INDEX service_provider_sid_idx ON service_providers (service_provider_sid);
|
CREATE INDEX service_provider_sid_idx ON service_providers (service_provider_sid);
|
||||||
CREATE INDEX name_idx ON service_providers (name);
|
CREATE INDEX name_idx ON service_providers (name);
|
||||||
CREATE INDEX root_domain_idx ON service_providers (root_domain);
|
CREATE INDEX root_domain_idx ON service_providers (root_domain);
|
||||||
|
|||||||
@@ -8,6 +8,19 @@ networks:
|
|||||||
- subnet: 172.38.0.0/16
|
- subnet: 172.38.0.0/16
|
||||||
|
|
||||||
services:
|
services:
|
||||||
|
mysql:
|
||||||
|
image: mysql:5.7
|
||||||
|
ports:
|
||||||
|
- "3306:3306"
|
||||||
|
environment:
|
||||||
|
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost", "--protocol", "tcp"]
|
||||||
|
timeout: 5s
|
||||||
|
retries: 10
|
||||||
|
networks:
|
||||||
|
sbc-inbound:
|
||||||
|
ipv4_address: 172.38.0.2
|
||||||
sbc:
|
sbc:
|
||||||
image: drachtio/drachtio-server:latest
|
image: drachtio/drachtio-server:latest
|
||||||
command: drachtio --contact "sip:*;transport=udp" --loglevel debug --sofia-loglevel 9
|
command: drachtio --contact "sip:*;transport=udp" --loglevel debug --sofia-loglevel 9
|
||||||
@@ -16,6 +29,9 @@ services:
|
|||||||
networks:
|
networks:
|
||||||
sbc-inbound:
|
sbc-inbound:
|
||||||
ipv4_address: 172.38.0.10
|
ipv4_address: 172.38.0.10
|
||||||
|
depends_on:
|
||||||
|
mysql:
|
||||||
|
condition: service_healthy
|
||||||
|
|
||||||
appserver:
|
appserver:
|
||||||
image: drachtio/sipp:latest
|
image: drachtio/sipp:latest
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
require('./docker_start');
|
require('./docker_start');
|
||||||
require('./create-test-db');
|
require('./create-test-db');
|
||||||
require('./sip-tests');
|
require('./sip-tests');
|
||||||
require('./remove-test-db');
|
|
||||||
require('./docker_stop');
|
require('./docker_stop');
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
const test = require('tape').test ;
|
|
||||||
const exec = require('child_process').exec ;
|
|
||||||
const pwd = process.env.TRAVIS ? '' : '-p$MYSQL_ROOT_PASSWORD';
|
|
||||||
|
|
||||||
test('dropping jambones_test database', (t) => {
|
|
||||||
exec(`mysql -h localhost -u root ${pwd} < ${__dirname}/db/remove_test_db.sql`, (err, stdout, stderr) => {
|
|
||||||
if (err) return t.end(err);
|
|
||||||
t.pass('database successfully dropped');
|
|
||||||
t.end();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
12
test/sipp.js
12
test/sipp.js
@@ -1,5 +1,5 @@
|
|||||||
const { spawn } = require('child_process');
|
const { spawn } = require('child_process');
|
||||||
const debug = require('debug')('test:sipp');
|
const debug = require('debug')('jambonz:ci');
|
||||||
let network;
|
let network;
|
||||||
const obj = {};
|
const obj = {};
|
||||||
let output = '';
|
let output = '';
|
||||||
@@ -27,7 +27,7 @@ obj.output = () => {
|
|||||||
obj.sippUac = (file, bindAddress) => {
|
obj.sippUac = (file, bindAddress) => {
|
||||||
const cmd = 'docker';
|
const cmd = 'docker';
|
||||||
const args = [
|
const args = [
|
||||||
'run', '-ti', '--rm', '--net', `${network}`,
|
'run', '--rm', '--net', `${network}`,
|
||||||
'-v', `${__dirname}/scenarios:/tmp/scenarios`,
|
'-v', `${__dirname}/scenarios:/tmp/scenarios`,
|
||||||
'drachtio/sipp', 'sipp', '-sf', `/tmp/scenarios/${file}`,
|
'drachtio/sipp', 'sipp', '-sf', `/tmp/scenarios/${file}`,
|
||||||
'-m', '1',
|
'-m', '1',
|
||||||
@@ -37,7 +37,7 @@ obj.sippUac = (file, bindAddress) => {
|
|||||||
'sbc'
|
'sbc'
|
||||||
];
|
];
|
||||||
|
|
||||||
if (bindAddress) args.splice(5, 0, '--ip', bindAddress);
|
if (bindAddress) args.splice(4, 0, '--ip', bindAddress);
|
||||||
|
|
||||||
//console.log(args.join(' '));
|
//console.log(args.join(' '));
|
||||||
clearOutput();
|
clearOutput();
|
||||||
@@ -57,11 +57,11 @@ obj.sippUac = (file, bindAddress) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
child_process.stdout.on('data', (data) => {
|
child_process.stdout.on('data', (data) => {
|
||||||
//debug(`stdout: ${data}`);
|
debug(`stderr: ${data}`);
|
||||||
addOutput(data.toString());
|
addOutput(data.toString());
|
||||||
});
|
});
|
||||||
child_process.stdout.on('data', (data) => {
|
child_process.stderr.on('data', (data) => {
|
||||||
//debug(`stdout: ${data}`);
|
debug(`stderr: ${data}`);
|
||||||
addOutput(data.toString());
|
addOutput(data.toString());
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user