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,
|
REGISTER_RESPONSE_REMOVE,
|
||||||
JAMBONES_REGBOT_USER_AGENT
|
JAMBONES_REGBOT_USER_AGENT
|
||||||
} = require('./config');
|
} = require('./config');
|
||||||
const {isValidDomainOrIP} = require('./utils');
|
const {isValidDomainOrIP, isValidIPv4} = 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');
|
||||||
@@ -119,7 +119,8 @@ class Regbot {
|
|||||||
proxy = `sip:${this.outbound_sip_proxy};transport=${transport}`;
|
proxy = `sip:${this.outbound_sip_proxy};transport=${transport}`;
|
||||||
this.logger.debug(`sending via proxy ${proxy}`);
|
this.logger.debug(`sending via proxy ${proxy}`);
|
||||||
} else {
|
} 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}`);
|
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}`, {
|
||||||
@@ -203,14 +204,14 @@ class Regbot {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
// for reg trunks, create ephemeral set of IP addresses for inbound gateways
|
// 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 = [];
|
this.addresses = [];
|
||||||
if (this.port) {
|
if (this.port) {
|
||||||
const addrs = await dnsResolverA(this.logger, this.sip_realm);
|
const addrs = await dnsResolverA(this.logger, this.ipv4);
|
||||||
this.addresses.push(...addrs);
|
this.addresses.push(...addrs);
|
||||||
}
|
}
|
||||||
else {
|
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);
|
this.addresses.push(...addrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user