davehorton / drachtio-fs-load-balancing-proxy

Load-balancing SIP proxy for Freeswitch
http://davehorton.github.io/drachtio-fs-load-balancing-proxy/
MIT License
24 stars 12 forks source link

change in fsw regex #7

Open alzrck opened 2 years ago

alzrck commented 2 years ago

Hi, just wanted to mention the following.

default freeswitch (meaning with default when it's recently installed with basic config) output for 'sofia status' is

` freeswitch@itfspre> sofia status Name Type Data State

        external-ipv6   profile                   sip:mod_sofia@[::1]:5080  RUNNING (0)
             external   profile             sip:mod_sofia@172.31.35.9:5080  RUNNING (0)
external::example.com   gateway                    sip:joeuser@example.com  NOREG

================================================================================================= 2 profiles 0 aliases

`

but, many other configs can occur regarding profiles, for example, i do have a box that is a gateway to other 2 sbcs where sofia status shows

` CCLAB > sofia status Name Type Data State

                  wan   profile            sip:mod_sofia@172.31.35.18:5060  RUNNING (0)
             wan::ims   gateway                  sip:ims@172.31.35.25:5060  NOREG
            wan::gwcc   gateway                sip:gwcc@172.31.35.27:11000  NOREG
           wan::cs2k1   gateway               sip:cs2k1@172.31.35.25:15060  NOREG

================================================================================================= 1 profile 0 aliases

`

So, default regex in fsw.js matched the wrong IP (was announcing to the drachtio server the IP of one of the gateways and not the IP of the local profile itself).

So i made a small change to the regex to match it

current one is

var re = new RegExp('^\\s*' + self.profile + '\\s.*sip:[^"]+@((?:[0-9]{1,3}\\.){3}[0-9]{1,3}):(\\d+)', 'm') ;

modified one is

var re = new RegExp('^\\s+' + self.profile + '\\tprofile\\t\\s+sip:[^"]+@((?:[0-9]{1,3}\\.){3}[0-9]{1,3}):(\\d+)\\tRUNNING.+$', 'm') ;

tested with both sofia status outputs and works ok.

Best regards and thanks for your work.