mirror of
https://github.com/jambonz/sbc-inbound.git
synced 2026-01-24 22:37:51 +00:00
detect wss transport
This commit is contained in:
@@ -7,7 +7,9 @@ const {
|
||||
nudgeCallCounts,
|
||||
roundTripTime,
|
||||
parseConnectionIp,
|
||||
isPrivateVoipNetwork
|
||||
isPrivateVoipNetwork,
|
||||
isWSS,
|
||||
//localSipPort
|
||||
} = require('./utils');
|
||||
|
||||
const {forwardInDialogRequests} = require('drachtio-fn-b2b-sugar');
|
||||
@@ -70,6 +72,9 @@ class CallSession extends Emitter {
|
||||
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;
|
||||
//this.localSipPort = localSipPort(req);
|
||||
}
|
||||
|
||||
get isFromMSTeams() {
|
||||
@@ -227,7 +232,7 @@ 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.req.protocol}>`;
|
||||
this.contactHeader = `<${scheme}:${this.privateSipAddress};transport=${this.protocol}>`;
|
||||
responseHeaders = {
|
||||
...responseHeaders,
|
||||
'Contact': this.contactHeader
|
||||
@@ -244,8 +249,8 @@ class CallSession extends Emitter {
|
||||
};
|
||||
}
|
||||
else {
|
||||
const hostport = this.srf.locals.sbcPublicIpAddress[this.req.protocol];
|
||||
this.contactHeader = `<${scheme}:${hostport};transport=${this.req.protocol}>`;
|
||||
const hostport = this.srf.locals.sbcPublicIpAddress[this.protocol];
|
||||
this.contactHeader = `<${scheme}:${hostport};transport=${this.protocol}>`;
|
||||
responseHeaders = {
|
||||
...responseHeaders,
|
||||
'Contact': this.contactHeader
|
||||
|
||||
@@ -9,6 +9,11 @@ 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];
|
||||
@@ -262,6 +267,7 @@ module.exports = {
|
||||
parseConnectionIp,
|
||||
isMSTeamsCIDR,
|
||||
isPrivateVoipNetwork,
|
||||
parseHostPorts
|
||||
parseHostPorts,
|
||||
localSipPort
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user