|
6 | 6 | REGISTER_RESPONSE_REMOVE, |
7 | 7 | JAMBONES_REGBOT_USER_AGENT |
8 | 8 | } = require('./config'); |
9 | | -const {isValidDomainOrIP} = require('./utils'); |
| 9 | +const {isValidDomainOrIP, isValidIPv4} = require('./utils'); |
10 | 10 | const DEFAULT_EXPIRES = (parseInt(JAMBONES_REGBOT_DEFAULT_EXPIRES_INTERVAL) || 3600); |
11 | 11 | const MIN_EXPIRES = (parseInt(JAMBONES_REGBOT_MIN_EXPIRES_INTERVAL) || 30); |
12 | 12 | const assert = require('assert'); |
@@ -119,7 +119,8 @@ class Regbot { |
119 | 119 | proxy = `sip:${this.outbound_sip_proxy};transport=${transport}`; |
120 | 120 | this.logger.debug(`sending via proxy ${proxy}`); |
121 | 121 | } else { |
122 | | - proxy = `sip:${this.ipv4}:${this.port};transport=${transport}`; |
| 122 | + const isIPv4 = isValidIPv4(this.ipv4); |
| 123 | + proxy = `sip:${this.ipv4}${isIPv4 ? `:${this.port}` : ''};transport=${transport}`; |
123 | 124 | this.logger.debug(`sending to registrar ${proxy}`); |
124 | 125 | } |
125 | 126 | const req = await srf.request(`${scheme}:${this.sip_realm}`, { |
@@ -203,14 +204,14 @@ class Regbot { |
203 | 204 | })); |
204 | 205 |
|
205 | 206 | // for reg trunks, create ephemeral set of IP addresses for inbound gateways |
206 | | - if (this.trunk_type === 'reg') { |
| 207 | + if (this.trunk_type === 'reg' && !isValidIPv4(this.ipv4)) { |
207 | 208 | this.addresses = []; |
208 | 209 | if (this.port) { |
209 | | - const addrs = await dnsResolverA(this.logger, this.sip_realm); |
| 210 | + const addrs = await dnsResolverA(this.logger, this.ipv4); |
210 | 211 | this.addresses.push(...addrs); |
211 | 212 | } |
212 | 213 | else { |
213 | | - const addrs = await dnsResolverSrv(this.logger, this.sip_realm, this.transport); |
| 214 | + const addrs = await dnsResolverSrv(this.logger, this.ipv4, this.transport); |
214 | 215 | this.addresses.push(...addrs); |
215 | 216 | } |
216 | 217 |
|
|
0 commit comments