Compare commits

..
2 Commits
Author SHA1 Message Date
Hoan Luu Huu e6d41dec71 update time series version (#171) 2024-10-17 08:07:10 -04:00
Hoan Luu Huu a6b1e58b87 support change log level run time (#169)
* support change log level run time

* support change log level run time
2024-10-07 09:52:01 -04:00
7 changed files with 27 additions and 34 deletions
+3
View File
@@ -287,6 +287,9 @@ if ('test' !== process.env.NODE_ENV) {
logger.info(`updating private network cidr from ${srf.locals.privateNetworkCidr} to ${r.private_network_cidr}`);
srf.locals.privateNetworkCidr = r.private_network_cidr;
}
if (r.log_level) {
logger.level = r.log_level;
}
}
}, 20000);
}
+7 -16
View File
@@ -7,8 +7,7 @@ const {
nudgeCallCounts,
roundTripTime,
parseConnectionIp,
isPrivateVoipNetwork,
isWSS,
isPrivateVoipNetwork
} = require('./utils');
const {forwardInDialogRequests} = require('drachtio-fn-b2b-sugar');
@@ -69,10 +68,6 @@ class CallSession extends Emitter {
this.service_provider_sid = req.locals.service_provider_sid;
this.srsClients = [];
this.recordingNoAnswerTimeout = (process.env.JAMBONES_RECORDING_NO_ANSWER_TIMEOUT || 2) * 1000;
this.isUsingPrivateNetwork = isPrivateVoipNetwork(this.req.source_address);
this.protocol = isWSS(req) ? 'wss' : req.protocol;
}
get isFromMSTeams() {
@@ -192,7 +187,7 @@ class CallSession extends Emitter {
...this.rtpEngineOpts.common,
...this.rtpEngineOpts.uac.mediaOpts,
'from-tag': this.rtpEngineOpts.uas.tag,
direction: [this.isUsingPrivateNetwork ? 'private' : 'public', 'private'],
direction: [isPrivateVoipNetwork(this.req.source_address) ? 'private' : 'public', 'private'],
sdp
};
const startAt = process.hrtime();
@@ -229,8 +224,8 @@ class CallSession extends Emitter {
// set Contact header based on scenario, and transport protocol
let responseHeaders = {};
if (this.isUsingPrivateNetwork) {
this.contactHeader = `<${scheme}:${this.privateSipAddress};transport=${this.protocol}>`;
if (isPrivateVoipNetwork(this.req.source_address)) {
this.contactHeader = `<${scheme}:${this.privateSipAddress};transport=${this.req.protocol}>`;
responseHeaders = {
...responseHeaders,
'Contact': this.contactHeader
@@ -247,8 +242,8 @@ class CallSession extends Emitter {
};
}
else {
const hostport = this.srf.locals.sbcPublicIpAddress[this.protocol];
this.contactHeader = `<${scheme}:${hostport};transport=${this.protocol}>`;
const hostport = this.srf.locals.sbcPublicIpAddress[this.req.protocol];
this.contactHeader = `<${scheme}:${hostport};transport=${this.req.protocol}>`;
responseHeaders = {
...responseHeaders,
'Contact': this.contactHeader
@@ -999,19 +994,15 @@ Duration=${payload.duration} `
// eslint-disable-next-line no-unused-vars
'content-length':contentlength, 'refer-to':_referto, 'referred-by':_referredby,
// eslint-disable-next-line no-unused-vars
'X-Refer-To-Leave-Untouched': _leave, 'contact':_contact,
'X-Refer-To-Leave-Untouched': _leave,
...customHeaders
} = req.headers;
if (this.isUsingPrivateNetwork && this.privateSipAddress) {
u.host = this.privateSipAddress;
}
const response = await this.uas.request({
method: 'REFER',
headers: {
'Refer-To': `<${stringifyUri(uri)}>`,
'Referred-By': `<${stringifyUri(u)}>`,
...(this.contactHeader && {'Contact': this.contactHeader}),
...customHeaders
}
});
+2
View File
@@ -235,6 +235,8 @@ module.exports = function(srf, logger) {
callId: req.get('Call-ID'),
service_provider_sid: req.locals.service_provider_sid,
account_sid: req.locals.account_sid
}, {
...(req.locals.account.enable_debug_log && {level: 'debug'})
});
next();
+1 -7
View File
@@ -9,11 +9,6 @@ const isWSS = (req) => {
return req.getParsedHeader('Via')[0].protocol.toLowerCase().startsWith('ws');
};
const localSipPort = (req) => {
const arr = /:(\d+)$/.exec(req.receivedOn);
return arr ? arr[1] : '5060';
};
const getAppserver = (srf) => {
const len = srf.locals.featureServers.length;
return srf.locals.featureServers[idx++ % len];
@@ -267,7 +262,6 @@ module.exports = {
parseConnectionIp,
isMSTeamsCIDR,
isPrivateVoipNetwork,
parseHostPorts,
localSipPort
parseHostPorts
};
+8 -7
View File
@@ -18,7 +18,7 @@
"@jambonz/rtpengine-utils": "^0.4.4",
"@jambonz/siprec-client-utils": "^0.2.7",
"@jambonz/stats-collector": "^0.1.10",
"@jambonz/time-series": "^0.2.8",
"@jambonz/time-series": "^0.2.10",
"bent": "^7.3.12",
"cidr-matcher": "^2.1.1",
"debug": "^4.3.4",
@@ -1481,9 +1481,10 @@
}
},
"node_modules/@jambonz/time-series": {
"version": "0.2.8",
"resolved": "https://registry.npmjs.org/@jambonz/time-series/-/time-series-0.2.8.tgz",
"integrity": "sha512-iFSKPAEElb3NXVAKYlr+2Q08zNhv8SlsS4I1Bwg4gFIj4Tku0vHzoXk6WTCzMRY1hE4YbBPbImNYLW9BfzMJjw==",
"version": "0.2.10",
"resolved": "https://registry.npmjs.org/@jambonz/time-series/-/time-series-0.2.10.tgz",
"integrity": "sha512-Y7Ih2ej6SxK2kZzI1BRLL5ytaxicmIPI/uZB5Sf02kl1/O/ddJ45/xI7OipSu8SPkTuRLRJwkFgTmYekBiUHfw==",
"license": "MIT",
"dependencies": {
"debug": "^4.3.1",
"influx": "^5.9.3"
@@ -7972,9 +7973,9 @@
}
},
"@jambonz/time-series": {
"version": "0.2.8",
"resolved": "https://registry.npmjs.org/@jambonz/time-series/-/time-series-0.2.8.tgz",
"integrity": "sha512-iFSKPAEElb3NXVAKYlr+2Q08zNhv8SlsS4I1Bwg4gFIj4Tku0vHzoXk6WTCzMRY1hE4YbBPbImNYLW9BfzMJjw==",
"version": "0.2.10",
"resolved": "https://registry.npmjs.org/@jambonz/time-series/-/time-series-0.2.10.tgz",
"integrity": "sha512-Y7Ih2ej6SxK2kZzI1BRLL5ytaxicmIPI/uZB5Sf02kl1/O/ddJ45/xI7OipSu8SPkTuRLRJwkFgTmYekBiUHfw==",
"requires": {
"debug": "^4.3.1",
"influx": "^5.9.3"
+1 -1
View File
@@ -32,7 +32,7 @@
"@jambonz/rtpengine-utils": "^0.4.4",
"@jambonz/siprec-client-utils": "^0.2.7",
"@jambonz/stats-collector": "^0.1.10",
"@jambonz/time-series": "^0.2.8",
"@jambonz/time-series": "^0.2.10",
"@jambonz/digest-utils": "^0.0.5",
"@aws-sdk/client-sns": "^3.549.0",
"@aws-sdk/client-auto-scaling": "^3.549.0",
+5 -3
View File
@@ -162,7 +162,7 @@ regex VARCHAR(32) NOT NULL COMMENT 'regex-based pattern match against dialed num
description VARCHAR(1024),
priority INTEGER NOT NULL COMMENT 'lower priority routes are attempted first',
PRIMARY KEY (lcr_route_sid)
) COMMENT='An ordered list of digit patterns in an LCR table. The pat';
) COMMENT='An ordered list of digit patterns in an LCR table. The patterns are tested in sequence until one matches';
CREATE TABLE lcr
(
@@ -173,7 +173,7 @@ default_carrier_set_entry_sid CHAR(36) COMMENT 'default carrier/route to use whe
service_provider_sid CHAR(36),
account_sid CHAR(36),
PRIMARY KEY (lcr_sid)
) COMMENT='An LCR (least cost routing) table that is used by a service ';
) COMMENT='An LCR (least cost routing) table that is used by a service provider or account to make decisions about routing outbound calls when multiple carriers are available.';
CREATE TABLE password_settings
(
@@ -359,7 +359,8 @@ CREATE TABLE system_information
domain_name VARCHAR(255),
sip_domain_name VARCHAR(255),
monitoring_domain_name VARCHAR(255),
private_network_cidr VARCHAR(8192)
private_network_cidr VARCHAR(8192),
log_level ENUM('info', 'debug') NOT NULL DEFAULT 'info'
);
CREATE TABLE users
@@ -553,6 +554,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';