From 496d6c7a71f94fd35d354d8e2521a743db309cf4 Mon Sep 17 00:00:00 2001 From: Dave Horton Date: Wed, 21 Aug 2024 09:32:24 -0400 Subject: [PATCH] per RFC 3261 the request-uri of REGISTER must not have userinfo (#72) --- lib/sip-trunk-register.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/sip-trunk-register.js b/lib/sip-trunk-register.js index 8f54c95..6988e10 100644 --- a/lib/sip-trunk-register.js +++ b/lib/sip-trunk-register.js @@ -124,13 +124,16 @@ class Regbot { } this.logger.debug(`sending REGISTER for ${this.aor}`); - const isIPv4 = /[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}/.test(this.ipv4); + const isIPv4 = /^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/.test(this.ipv4); + const proxy = `sip:${this.ipv4}${isIPv4 ? `:${this.port}` : ''};transport=${transport}`; - const req = await srf.request(`${scheme}:${this.aor}`, { + this.logger.debug({isIPv4}, `sending via proxy ${proxy}`); + const req = await srf.request(`${scheme}:${this.sip_realm}`, { method: 'REGISTER', proxy, headers: { 'From': this.from, + 'To': this.from, 'Contact': `<${scheme}:${contactAddress};transport=${transport}>;expires=${DEFAULT_EXPIRES}`, 'Expires': DEFAULT_EXPIRES },