mirror of
https://github.com/jambonz/sbc-sip-sidecar.git
synced 2026-01-24 22:27:52 +00:00
use outbound proxy for registrations where set (#103)
* use outbound proxy for registrations where set * remove requirement that port can only be set on IP address not host * switch logging back to debug and remove unused function * Update regbot.js
This commit is contained in:
@@ -5,7 +5,7 @@ const {
|
|||||||
REGISTER_RESPONSE_REMOVE
|
REGISTER_RESPONSE_REMOVE
|
||||||
} = require('./config');
|
} = require('./config');
|
||||||
const debug = require('debug')('jambonz:sbc-registrar');
|
const debug = require('debug')('jambonz:sbc-registrar');
|
||||||
const {isValidIPv4, isValidDomainOrIP} = require('./utils');
|
const {isValidDomainOrIP} = require('./utils');
|
||||||
const DEFAULT_EXPIRES = (parseInt(JAMBONES_REGBOT_DEFAULT_EXPIRES_INTERVAL) || 3600);
|
const DEFAULT_EXPIRES = (parseInt(JAMBONES_REGBOT_DEFAULT_EXPIRES_INTERVAL) || 3600);
|
||||||
const MIN_EXPIRES = (parseInt(JAMBONES_REGBOT_MIN_EXPIRES_INTERVAL) || 30);
|
const MIN_EXPIRES = (parseInt(JAMBONES_REGBOT_MIN_EXPIRES_INTERVAL) || 30);
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
@@ -24,6 +24,7 @@ class Regbot {
|
|||||||
this.port = opts.port;
|
this.port = opts.port;
|
||||||
this.use_public_ip_in_contact = opts.use_public_ip_in_contact || JAMBONES_REGBOT_CONTACT_USE_IP;
|
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.use_sips_scheme = opts.use_sips_scheme || false;
|
||||||
|
this.outbound_sip_proxy = opts.outbound_sip_proxy;
|
||||||
|
|
||||||
this.fromUser = opts.from_user || this.username;
|
this.fromUser = opts.from_user || this.username;
|
||||||
const fromDomain = opts.from_domain || this.sip_realm;
|
const fromDomain = opts.from_domain || this.sip_realm;
|
||||||
@@ -91,10 +92,15 @@ class Regbot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.logger.debug(`sending REGISTER for ${this.aor}`);
|
this.logger.debug(`sending REGISTER for ${this.aor}`);
|
||||||
const isIPv4 = isValidIPv4(this.ipv4);
|
|
||||||
|
|
||||||
const proxy = `sip:${this.ipv4}${isIPv4 ? `:${this.port}` : ''};transport=${transport}`;
|
let proxy;
|
||||||
this.logger.debug({isIPv4}, `sending via proxy ${proxy}`);
|
if (this.outbound_sip_proxy) {
|
||||||
|
proxy = `sip:${this.outbound_sip_proxy};transport=${transport}`;
|
||||||
|
this.logger.debug(`sending via proxy ${proxy}`);
|
||||||
|
} else {
|
||||||
|
proxy = `sip:${this.ipv4}:${this.port};transport=${transport}`;
|
||||||
|
this.logger.debug(`sending to registrar ${proxy}`);
|
||||||
|
}
|
||||||
const req = await srf.request(`${scheme}:${this.sip_realm}`, {
|
const req = await srf.request(`${scheme}:${this.sip_realm}`, {
|
||||||
method: 'REGISTER',
|
method: 'REGISTER',
|
||||||
proxy,
|
proxy,
|
||||||
|
|||||||
@@ -29,7 +29,8 @@ function pickRelevantCarrierProperties(c) {
|
|||||||
register_sip_realm: c.register_sip_realm,
|
register_sip_realm: c.register_sip_realm,
|
||||||
register_from_user: c.register_from_user,
|
register_from_user: c.register_from_user,
|
||||||
register_from_domain: c.register_from_domain,
|
register_from_domain: c.register_from_domain,
|
||||||
register_public_ip_in_contact: c.register_public_ip_in_contact
|
register_public_ip_in_contact: c.register_public_ip_in_contact,
|
||||||
|
outbound_sip_proxy: c.outbound_sip_proxy
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -237,6 +238,7 @@ const updateCarrierRegbots = async(logger, srf) => {
|
|||||||
from_user: gw.carrier.register_from_user,
|
from_user: gw.carrier.register_from_user,
|
||||||
from_domain: gw.carrier.register_from_domain,
|
from_domain: gw.carrier.register_from_domain,
|
||||||
use_public_ip_in_contact: gw.carrier.register_public_ip_in_contact,
|
use_public_ip_in_contact: gw.carrier.register_public_ip_in_contact,
|
||||||
|
outbound_sip_proxy: gw.carrier.outbound_sip_proxy
|
||||||
});
|
});
|
||||||
regbots.push(rb);
|
regbots.push(rb);
|
||||||
rb.start(srf);
|
rb.start(srf);
|
||||||
|
|||||||
Reference in New Issue
Block a user