mirror of
https://github.com/jambonz/sbc-sip-sidecar.git
synced 2025-12-19 04:27:46 +00:00
Fix/regtrunks (#118)
* restore only use port if proxy is IPv4 address
broke in this commit 543f52d3dd
* use sip gateway host for DNS lookup of ephemeral gw and only if not an IP address
This commit is contained in:
@@ -6,7 +6,7 @@ const {
|
||||
REGISTER_RESPONSE_REMOVE,
|
||||
JAMBONES_REGBOT_USER_AGENT
|
||||
} = require('./config');
|
||||
const {isValidDomainOrIP} = require('./utils');
|
||||
const {isValidDomainOrIP, isValidIPv4} = require('./utils');
|
||||
const DEFAULT_EXPIRES = (parseInt(JAMBONES_REGBOT_DEFAULT_EXPIRES_INTERVAL) || 3600);
|
||||
const MIN_EXPIRES = (parseInt(JAMBONES_REGBOT_MIN_EXPIRES_INTERVAL) || 30);
|
||||
const assert = require('assert');
|
||||
@@ -119,7 +119,8 @@ class Regbot {
|
||||
proxy = `sip:${this.outbound_sip_proxy};transport=${transport}`;
|
||||
this.logger.debug(`sending via proxy ${proxy}`);
|
||||
} else {
|
||||
proxy = `sip:${this.ipv4}:${this.port};transport=${transport}`;
|
||||
const isIPv4 = isValidIPv4(this.ipv4);
|
||||
proxy = `sip:${this.ipv4}${isIPv4 ? `:${this.port}` : ''};transport=${transport}`;
|
||||
this.logger.debug(`sending to registrar ${proxy}`);
|
||||
}
|
||||
const req = await srf.request(`${scheme}:${this.sip_realm}`, {
|
||||
@@ -203,14 +204,14 @@ class Regbot {
|
||||
}));
|
||||
|
||||
// for reg trunks, create ephemeral set of IP addresses for inbound gateways
|
||||
if (this.trunk_type === 'reg') {
|
||||
if (this.trunk_type === 'reg' && !isValidIPv4(this.ipv4)) {
|
||||
this.addresses = [];
|
||||
if (this.port) {
|
||||
const addrs = await dnsResolverA(this.logger, this.sip_realm);
|
||||
const addrs = await dnsResolverA(this.logger, this.ipv4);
|
||||
this.addresses.push(...addrs);
|
||||
}
|
||||
else {
|
||||
const addrs = await dnsResolverSrv(this.logger, this.sip_realm, this.transport);
|
||||
const addrs = await dnsResolverSrv(this.logger, this.ipv4, this.transport);
|
||||
this.addresses.push(...addrs);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user