mirror of
https://github.com/jambonz/sbc-sip-sidecar.git
synced 2026-01-24 22:27:52 +00:00
support use sips schema when it's enabled from gateway configuration (#67)
* support use sips schema when it's enabled from gateway configuration * wip * add LICENSE file
This commit is contained in:
@@ -13,12 +13,13 @@ class OptionsBot {
|
||||
this.protocol = gateway.protocol;
|
||||
this.expiry = (process.env.SEND_OPTIONS_PING_INTERVAL || 60);
|
||||
|
||||
const useSipsScheme = gateway.protocol.includes('tls') && gateway.use_sips_scheme;
|
||||
const isIPv4 = /[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}/.test(gateway.ipv4);
|
||||
const transport = gateway.protocol.includes('/') ? gateway.protocol.substring(0, gateway.protocol.indexOf('/')) :
|
||||
gateway.protocol;
|
||||
this.proxy = `sip:${this.ipv4}${isIPv4 ? `:${this.port}` : ''};transport=${transport}`;
|
||||
this.uri = `sip${gateway.protocol.includes('tls') ?
|
||||
's' : ''}:${gateway.ipv4}${gateway.port && !gateway.protocol.includes('tls') ? `:${gateway.port}` : ''}`;
|
||||
this.uri = `sip${useSipsScheme ?
|
||||
's' : ''}:${gateway.ipv4}${gateway.port && !useSipsScheme ? `:${gateway.port}` : ''}`;
|
||||
}
|
||||
|
||||
async options(srf) {
|
||||
|
||||
@@ -47,6 +47,7 @@ class Regbot {
|
||||
this.ipv4 = opts.ipv4;
|
||||
this.port = opts.port;
|
||||
this.use_public_ip_in_contact = opts.use_public_ip_in_contact || JAMBONES_REGBOT_CONTACT_USE_IP;
|
||||
this.use_sips_scheme = opts.use_sips_scheme || false;
|
||||
|
||||
this.fromUser = opts.from_user || this.username;
|
||||
const fromDomain = opts.from_domain || this.sip_realm;
|
||||
@@ -88,8 +89,9 @@ class Regbot {
|
||||
const isIPv4 = /[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}/.test(this.ipv4);
|
||||
const transport = this.protocol.includes('/') ? this.protocol.substring(0, this.protocol.indexOf('/')) :
|
||||
this.protocol;
|
||||
const useSipsScheme = transport === 'tls' && this.use_sips_scheme;
|
||||
const proxy = `sip:${this.ipv4}${isIPv4 ? `:${this.port}` : ''};transport=${transport}`;
|
||||
const req = await srf.request(`sip${transport === 'tls' ? 's' : ''}:${this.aor}`, {
|
||||
const req = await srf.request(`sip${useSipsScheme ? 's' : ''}:${this.aor}`, {
|
||||
method: 'REGISTER',
|
||||
proxy,
|
||||
headers: {
|
||||
@@ -302,6 +304,7 @@ const updateCarrierRegbots = async(logger, srf) => {
|
||||
ipv4: gw.ipv4,
|
||||
port: gw.port,
|
||||
protocol: gw.protocol,
|
||||
use_sips_scheme: gw.use_sips_scheme,
|
||||
username: gw.carrier.register_username,
|
||||
password: gw.carrier.register_password,
|
||||
sip_realm: gw.carrier.register_sip_realm,
|
||||
|
||||
Reference in New Issue
Block a user