mirror of
https://github.com/jambonz/sbc-sip-sidecar.git
synced 2026-03-22 03:08:26 +00:00
enhancements to allow customization of from header and domain/ip in Contact
This commit is contained in:
@@ -12,11 +12,17 @@ class Regbot {
|
||||
|
||||
['ipv4', 'port', 'username', 'password', 'sip_realm'].forEach((prop) => this[prop] = opts[prop]);
|
||||
|
||||
logger.debug({opts}, 'Regbot');
|
||||
this.username = opts.username;
|
||||
this.password = opts.password;
|
||||
this.sip_realm = opts.sip_realm || opts.ipv4;
|
||||
this.ipv4 = opts.ipv4;
|
||||
this.port = opts.port;
|
||||
this.use_public_ip_in_contact = opts.use_public_ip_in_contact || process.env.JAMBONES_REGBOT_CONTACT_USE_IP;
|
||||
|
||||
const fromUser = opts.from_user || this.username;
|
||||
const fromDomain = opts.from_domain || this.sip_realm;
|
||||
this.from = `sip:${fromUser}@${fromDomain}`;
|
||||
this.aor = `${this.username}@${this.sip_realm}`;
|
||||
this.status = 'none';
|
||||
}
|
||||
@@ -44,13 +50,13 @@ class Regbot {
|
||||
|
||||
async register(srf) {
|
||||
try {
|
||||
const contactAddress = process.env.JAMBONES_REGBOT_CONTACT_USE_IP ?
|
||||
const contactAddress = this.use_public_ip_in_contact ?
|
||||
`${this.username}@${srf.locals.sbcPublicIpAddress}` : this.aor;
|
||||
const req = await srf.request(`sip:${this.aor}`, {
|
||||
method: 'REGISTER',
|
||||
proxy: `sip:${this.ipv4}:${this.port}`,
|
||||
headers: {
|
||||
'From': `sip:${this.aor}`,
|
||||
'From': this.from,
|
||||
'Contact': `<sip:${contactAddress}>;expires=${DEFAULT_EXPIRES}`,
|
||||
'Expires': DEFAULT_EXPIRES
|
||||
},
|
||||
@@ -152,7 +158,10 @@ const getCarriers = async(logger, srf) => {
|
||||
port: gw.port,
|
||||
username: gw.carrier.register_username,
|
||||
password: gw.carrier.register_password,
|
||||
sip_realm: gw.carrier.register_sip_realm
|
||||
sip_realm: gw.carrier.register_sip_realm,
|
||||
from_user: gw.carrier.register_from_user,
|
||||
from_domain: gw.carrier.register_from_domain,
|
||||
use_public_ip_in_contact: gw.carrier.register_public_ip_in_contact
|
||||
});
|
||||
regbots.push(rb);
|
||||
rb.start(srf);
|
||||
|
||||
Reference in New Issue
Block a user