[Freeswitch-users] Getting logs of registrations/deregistrations

Avi Marcus avi at avimarcus.net
Mon Jun 9 20:50:41 MSD 2014


Some of my code for registration events in nodejs.. sorry, I didn't want to
just throw it up - I don't really remember how it works and what other
stuff is there.

var esl = require('modesl');

var conn = new esl.Connection('127.0.0.1', 8021, 'ClueCon', connectedToESL);


function connectedToESL(){
conn.subscribe([
 'sofia::register',
'sofia::unregister',
'sofia::register_attempt',
 'sofia::expire'
], function() {
console.log("successfully subscribed");
 });
}

var regexExpireContactIP=/@([^:]*):(\d*)/;

client.on('CUSTOM',function show_heartbeat(data){
 if(data.body['Event-Subclass']=="sofia::register"){
console.log('sofia register for user ' + data.body.username+ ' from '
+data.body['network-ip']);
 //console.log(data.body);

}
else if(data.body['Event-Subclass']=="sofia::unregister"){
 console.log('sofia DE-register for user ' + data.body.username);
//console.log(data.body);
}
 else if(data.body['Event-Subclass']=="sofia::register_attempt"){
console.log('sofia register_attempt for user ' + data.body.username+ ' from
' +data.body['network-ip']);
 //console.log(data.body);
}
else if(data.body['Event-Subclass']=="sofia::expire"){
 var ip=['','',''];
if(data.body && data.body.contact)
ip=regexExpireContactIP.exec(data.body.contact);
 console.log('sofia EXPIRE for user ' + data.body.user + ', was via ' +
ip[1]+':' + ip[2] + ', agent of ' + data.body['user-agent']);//@data.host

}
}


-Avi Marcus

1-718-989-9485 (USA)
1-866-202-5850 (USA & Canada Toll Free)
02-372-1570 (Israel)
020-3298-2875 (UK)


On Mon, Jun 9, 2014 at 6:13 PM, Alex Lake <alex at digitalmail.com> wrote:

>  Oooh, that'd be my first one - scary!
> Your logic sounds extremely plausible.
> Suspect that ESL subscription would be the technically correct way to do
> it, though.
> I think a logged warning for failed OPTIONS request seems more obvious,
> but I may as well put in both.
>
> Cheers
>
>
> On 09/06/2014 15:07, Steven Ayre wrote:
>
> You could file a wishlist Jira... if the event is raised then it'd be
> trivial to log at the same time.
>
>  The registration logs are there to support fail2ban so that you can
> automatically block attacks... that could explain why there's no logging of
> deregistration at present, since only the former is needed for fail2ban.
>
>
> On 9 June 2014 15:06, Steven Ayre <steveayre at gmail.com> wrote:
>
>> Registration is expiration based - they expire unless you send another
>> REGISTER within the expiry time.
>>
>>  I believe there's an ESL event when they expire that you can subscribe
>> to, but I don't think it appears in the logs.
>>
>>
>> On 9 June 2014 14:41, Alex Lake <alex at digitalmail.com> wrote:
>>
>>> Is there a way to get the console to show end-user registrations and
>>> de-registrations as they happen?
>>>
>>> I note that registrations are OK, you get something like this:
>>>
>>> 2014-06-09 13:37:44.091960 [WARNING] sofia_reg.c:1541 SIP auth challenge
>>> (REGISTER) on sofia profile 'internal' for
>>> [1129301 at 004-1129.sb12.dmclub.org] from ip 84.92.90.149
>>>
>>> But de-registrations are very quiet.
>>>
>>> Also, is there an api command to send a "SIP OPTIONS" message to a
>>> particular registered session?
>>>
>>> _________________________________________________________________________
>>> Professional FreeSWITCH Consulting Services:
>>> consulting at freeswitch.org
>>> http://www.freeswitchsolutions.com
>>>
>>> 
>>> 
>>>
>>> Official FreeSWITCH Sites
>>> http://www.freeswitch.org
>>> http://wiki.freeswitch.org
>>> http://www.cluecon.com
>>>
>>> FreeSWITCH-users mailing list
>>> FreeSWITCH-users at lists.freeswitch.org
>>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>>> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
>>> http://www.freeswitch.org
>>>
>>
>>
>
>
> _________________________________________________________________________
> Professional FreeSWITCH Consulting Services:consulting at freeswitch.orghttp://www.freeswitchsolutions.com
>
> FreeSWITCH-powered IP PBX: The CudaTel Communication Server
>
> Official FreeSWITCH Siteshttp://www.freeswitch.orghttp://wiki.freeswitch.orghttp://www.cluecon.com
>
> FreeSWITCH-users mailing listFreeSWITCH-users at lists.freeswitch.orghttp://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-usershttp://www.freeswitch.org
>
>
>
> No virus found in this message.
> Checked by AVG - www.avg.com
> Version: 2014.0.4570 / Virus Database: 3955/7646 - Release Date: 06/09/14
>
>
>
> _________________________________________________________________________
> Professional FreeSWITCH Consulting Services:
> consulting at freeswitch.org
> http://www.freeswitchsolutions.com
>
> 
> 
>
> Official FreeSWITCH Sites
> http://www.freeswitch.org
> http://wiki.freeswitch.org
> http://www.cluecon.com
>
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20140609/ab293c8c/attachment-0001.html 


Join us at ClueCon 2016 Aug 8-12, 2016
More information about the FreeSWITCH-users mailing list