Need help to make shorter a BLACKLIST and VOICEMAL dialplan

Catalog of dial plans
qubo
Posts: 127
Joined: Tue Apr 12, 2011 6:11 am

Need help to make shorter a BLACKLIST and VOICEMAL dialplan

Post by qubo » Thu Aug 14, 2014 11:03 pm

HI I have a Blacklist and Voicemail area in my inbound dialplan.... but there is large to repeat every single rule. so any one that could help to make shorter with variables etc ?

my working dialplan is

Code: Select all

# BLACKLIST 
       case req.Header.from.FromURI.User.to_s
         when /^5255917xxxxx/ then sys.Email(ubj9BBv8PuvLUFV5ydscg@api.pushover.net", "Sipsorcery blacklisted from ", " #{req.Header.From.FromURI.User}.")&sys.Respond(403, "Forbidden")
         when /^anonymous/ then sys.Email(ubj9BBv8PuvLUFV5ydscg@api.pushover.net", "Sipsorcery blacklisted from ", " #{req.Header.From.FromURI.User}.")&sys.Respond(403, "Forbidden")
         when /^523339490009/ then sys.Email(ubj9BBv8PuvLUFV5ydscg@api.pushover.net", "Sipsorcery blacklisted from ", " #{req.Header.From.FromURI.User}.")sys.Respond(403, "Forbidden") 
       end)

# VOICEMAIL 
       case req.Header.from.FromURI.User.to_s
         when /^5255917xxxxx/ then sys.Email(ubj9BBv8PuvLUFV5ydscg@api.pushover.net", "Sipsorcery Voicemail from ", " #{req.Header.From.FromURI.User}.")&sys.Dial("1777249xxxxx@in.callcentric.com")
         when /^anonymous/ then sys.Email(ubj9BBv8PuvLUFV5ydscg@api.pushover.net", "Sipsorcery Voicemail from ", " #{req.Header.From.FromURI.User}.")&sys.Dial("1777249xxxxx@in.callcentric.com")
         when /^523339490009/ then sys.Email(ubj9BBv8PuvLUFV5ydscg@api.pushover.net", "Sipsorcery Voicemail from ", " #{req.Header.From.FromURI.User}.")&sys.Dial("1777249xxxxx@in.callcentric.com") 
       end)
but want something like these: Note is an example ( dont work ) to give an idea of what I want to implement, hope someone can help



Code: Select all

NotificationBlacklist   = "ubj9BBv8PuvLUFV5ydscg@api.pushover.net", "Sipsorcery blacklisted from ", " #{req.Header.From.FromURI.User}."
NotificationVoicemail = "ubj9BBv8PuvLUFV5ydscg@api.pushover.net", "Sipsorcery Voicemail from ", " #{req.Header.From.FromURI.User}."

# BLACKLIST 
       case req.Header.from.FromURI.User.to_s
         when /^5255917xxxxx/ then sys.Email( NotificationBlacklist )&sys.Respond(403, "Forbidden")
         when /^anonymous/ then sys.Email( NotificationBlacklist )&sys.Respond(403, "Forbidden")
         when /^523339490009/ then sys.Email( NotificationBlacklist )&sys.Respond(403, "Forbidden") 
       end)

# VOICEMAIL 
       case req.Header.from.FromURI.User.to_s
         when /^5255xxxxxxx/ then sys.Email( NotificationVoicemail )&sys.Dial("1777249xxxx@in.callcentric.com")
         when /^anonymous/ then sys.Email( NotificationVoicemail )&sys.Dial("1777249xxxx@in.callcentric.com")
         when /^52333xxxxxxx/ then sys.Email( NotificationVoicemail )&sys.Dial("1777249xxxx@in.callcentric.com") 
       end

User avatar
Aaron
Site Admin
Posts: 4563
Joined: Thu Jul 12, 2007 12:13 am

Re: Need help to make shorter a BLACKLIST and VOICEMAL dialp

Post by Aaron » Thu Aug 21, 2014 10:50 am

Try this:

Code: Select all

blackList = ["^5255917xxxxx", "^anonymous",  "^523339490009"]
voicemailList = [["^5255917xxxxx", "^anonymous",  "^523339490009"]

if blackList.test { |e| /req.Header.from.FromURI.User.to_s/ =~ e } != nil then
   sys.Email(ubj9BBv8PuvLUFV5ydscg@api.pushover.net", "Sipsorcery blacklisted from ", " #{req.Header.From.FromURI.User}.")
   sys.Respond(403, "Forbidden") 
elsif voicemailList.test { |e| /req.Header.from.FromURI.User.to_s/ =~ e } != nil then
  sys.Email(ubj9BBv8PuvLUFV5ydscg@api.pushover.net", "Sipsorcery Voicemail from ", " #{req.Header.From.FromURI.User}.")
  sys.Dial("1777249xxxxx@in.callcentric.com") 
end

qubo
Posts: 127
Joined: Tue Apr 12, 2011 6:11 am

Re: Need help to make shorter a BLACKLIST and VOICEMAL dialp

Post by qubo » Thu Aug 21, 2014 5:00 pm

thanks so much Aaron. I tried my dialplan but something is wrong could you check the code ? and plus could I put blocking full area with "^5289\d{8}" is correct ?

Code: Select all

blackList = ["^5289\d{8}", "^523334698333",  "^523336470333",  "^523339490333"]
voicemailList = ["^525591799333", "^anonymouz",  "^525591799333"]
papaList = ["^528183561333", "^528183561333",  "^anonymous"]

if blackList.test { |e| /req.Header.from.FromURI.User.to_s/ =~ e } != nil then
   sys.Email(ubj9BBv8PuvLUFV5ydscgjCn@api.pushover.net", "ANTUA Bloqueando a ", " #{req.Header.From.FromURI.User}.")
   sys.Respond(403, "Forbidden")
elsif voicemailList.test { |e| /req.Header.from.FromURI.User.to_s/ =~ e } != nil then
  sys.Email(ubj9BBv8PuvLUFV5ydscgjCn@api.pushover.net", "ANTUA al Buzon ", " #{req.Header.From.FromURI.User}.")
  sys.Dial("17772492333@in.callcentric.com")
elsif papaList.test { |e| /req.Header.from.FromURI.User.to_s/ =~ e } != nil then
  sys.Email(ubj9BBv8PuvLUFV5ydscgjCn@api.pushover.net", "Transfiriendo a PAPA ", " #{req.Header.From.FromURI.User}.")
  sys.Dial("12345xxxx@sipsorcery.com")
else
   sys.Email("ubj9BBv8PuvLUFV5ydscgjCnABHK59+p1@api.pushover.net", "ANTUA Recibiendo Llamada DE ", " #{req.Header.From.FromURI.User}.")
   sys.Email("jcolinspam.c4@m.evernote.com", "ANTUA Recibiendo Llamada DE ", " #{req.Header.From.FromURI.User}.")
   sys.Dial("12345xxxx@sipsorcery.com&17772492333@in.callcentric.com[dt=40]")
end


User avatar
Aaron
Site Admin
Posts: 4563
Joined: Thu Jul 12, 2007 12:13 am

Re: Need help to make shorter a BLACKLIST and VOICEMAL dialp

Post by Aaron » Sat Aug 23, 2014 12:33 pm

Sorry mistake on my behalf .test should have been .find. Try your corrected code as shown below.

Code: Select all

blackList = ["^5289\d{8}", "^523334698333",  "^523336470333",  "^523339490333"]
voicemailList = ["^525591799333", "^anonymouz",  "^525591799333"]
papaList = ["^528183561333", "^528183561333",  "^anonymous"]

if blackList.find { |e| /req.Header.from.FromURI.User.to_s/ =~ e } != nil then
   sys.Email(ubj9BBv8PuvLUFV5ydscgjCn@api.pushover.net", "ANTUA Bloqueando a ", " #{req.Header.From.FromURI.User}.")
   sys.Respond(403, "Forbidden")
elsif voicemailList.find { |e| /req.Header.from.FromURI.User.to_s/ =~ e } != nil then
  sys.Email(ubj9BBv8PuvLUFV5ydscgjCn@api.pushover.net", "ANTUA al Buzon ", " #{req.Header.From.FromURI.User}.")
  sys.Dial("17772492333@in.callcentric.com")
elsif papaList.find { |e| /req.Header.from.FromURI.User.to_s/ =~ e } != nil then
  sys.Email(ubj9BBv8PuvLUFV5ydscgjCn@api.pushover.net", "Transfiriendo a PAPA ", " #{req.Header.From.FromURI.User}.")
  sys.Dial("12345xxxx@sipsorcery.com")
else
   sys.Email("ubj9BBv8PuvLUFV5ydscgjCnABHK59+p1@api.pushover.net", "ANTUA Recibiendo Llamada DE ", " #{req.Header.From.FromURI.User}.")
   sys.Email("jcolinspam.c4@m.evernote.com", "ANTUA Recibiendo Llamada DE ", " #{req.Header.From.FromURI.User}.")
   sys.Dial("12345xxxx@sipsorcery.com&17772492333@in.callcentric.com[dt=40]")
end

qubo
Posts: 127
Joined: Tue Apr 12, 2011 6:11 am

Re: Need help to make shorter a BLACKLIST and VOICEMAL dialp

Post by qubo » Sat Aug 23, 2014 5:46 pm

I tried with .find instead of .test but it still is something wrong.... the internal sip 12345xxxxx@sipsorcery.com is not ringing
and the actions in elsif dont do proper actions as email or dial.

Note. latest part of dial plan has else statment with 2 diferent emails.
I put my mobile number in the papaList but didnt redirect to 1234xxxx@sipsorcery.com didnt ring even sip devices are up.
then erase my mobile number to try the else statment but didnt ring too. and no email were dispatched.

it is weird. could you check again ?

thanks so much

User avatar
Aaron
Site Admin
Posts: 4563
Joined: Thu Jul 12, 2007 12:13 am

Re: Need help to make shorter a BLACKLIST and VOICEMAL dialp

Post by Aaron » Sun Aug 24, 2014 11:31 am

Can you post up the console messages you get when attempting the calls (the Console is available in the Silverlight portal https://www.sipsorcery.com/mainsite/Home/Portal).

qubo
Posts: 127
Joined: Tue Apr 12, 2011 6:11 am

Re: Need help to make shorter a BLACKLIST and VOICEMAL dialp

Post by qubo » Sun Aug 24, 2014 9:06 pm

the Error seems to be sys.Email(ubj9BBv8Puv that need to be sys.Email("ubj9BBv8Puv now calls ring in else statment 12345xxx

BUT the dialplan still have an error..... in the list papaList there is my phonenumber and tried call me with anonymous too.
the problem is that the call with both have been thru else statment. and not for elsif papalist. even when both numbers are inside the papaList...

Code: Select all

DialPlan 21:01:25:686 sip1(9644): Dial plan execution completed without answering and had an execution error message of Dial plan syntax error.
DialPlan 21:01:25:686 sip1(9644): Call failed with a failure status of InternalServerError and Dial plan syntax error.
DialPlan 21:01:25:686 sip1(9644): UAS call failed with a response status of 500 and Dial plan syntax error.
DialPlan 21:01:25:795 sip1(9644): Using dialplan incomAntuaHD for In call to sip:1234xxxxx@sipsorcery.com;transport=UDP.
NewCall 21:01:25:842 sip1(9644): Executing script dial plan for call to 12345xxxxx.
DialPlan 21:01:25:873 sip1(9644): There was a syntax error in your dial plan on line 6, please check.
DialPlan 21:01:25:873 sip1(9644): Dialplan cleanup for inqxxxx.
DialPlan 21:01:26:217 sip1(9644): Dial plan execution completed without answering and had an execution error message of Dial plan syntax error.
DialPlan 21:01:26:217 sip1(9644): Call failed with a failure status of InternalServerError and Dial plan syntax error.
DialPlan 21:01:26:217 sip1(9644): UAS call failed with a response status of 500 and Dial plan syntax error.
DialPlan 21:01:27:514 sip1(9644): Using dialplan incomAntuaHD for In call to sip:12345xxxxx@sipsorcery.com;transport=TCP.
NewCall 21:01:27:545 sip1(9644): Executing script dial plan for call to 12345xxxxx.
DialPlan 21:01:27:561 sip1(9644): There was a syntax error in your dial plan on line 6, please check.
DialPlan 21:01:27:576 sip1(9644): Dialplan cleanup for inqxxxx.
DialPlan 21:01:27:733 sip1(9644): Dial plan execution completed without answering and had an execution error message of Dial plan syntax error.
DialPlan 21:01:27:733 sip1(9644): Call failed with a failure status of InternalServerError and Dial plan syntax error.
DialPlan 21:01:27:733 sip1(9644): UAS call failed with a response status of 500 and Dial plan syntax error.
DialPlan 21:01:27:842 sip1(9644): Using dialplan incomAntuaHD for In call to sip:12345xxxxx@sipsorcery.com;transport=UDP.
NewCall 21:01:27:858 sip1(9644): Executing script dial plan for call to 12345xxxxx.
DialPlan 21:01:27:889 sip1(9644): There was a syntax error in your dial plan on line 6, please check.
DialPlan 21:01:27:889 sip1(9644): Dialplan cleanup for inquba.
DialPlan 21:01:28:264 sip1(9644): Dial plan execution completed without answering and had an execution error message of Dial plan syntax error.
DialPlan 21:01:28:264 sip1(9644): Call failed with a failure status of InternalServerError and Dial plan syntax error.
DialPlan 21:01:28:264 sip1(9644): UAS call failed with a response status of 500 and Dial plan syntax error.
here the dialplan

Code: Select all

blackList = ["^5289\d{8}", "^523334698333",  "^5233364703338",  "^523339490333"]
voicemailList = ["^525591799331", "^anonymouz",  "^525591799333"]
papaList = ["^528183561333", "^523339490333",  "^anonymous"]

if blackList.find { |e| /req.Header.from.FromURI.User.to_s/ =~ e } != nil then
   sys.Email(ubj9BBv8PuvLUFV5ydscgjCn@api.pushover.net", "ANTUA Bloqueando a ", " #{req.Header.From.FromURI.User}.")
   sys.Respond(403, "Forbidden")
elsif voicemailList.find { |e| /req.Header.from.FromURI.User.to_s/ =~ e } != nil then
  sys.Email(ubj9BBv8PuvLUFV5ydscgjCn@api.pushover.net", "ANTUA al Buzon ", " #{req.Header.From.FromURI.User}.")
  sys.Dial("177724xxxxx@in.callcentric.com")
elsif papaList.find { |e| /req.Header.from.FromURI.User.to_s/ =~ e } != nil then
  sys.Email(ubj9BBv8PuvLUFV5ydscgjCn@api.pushover.net", "Transfiriendo a PAPA ", " #{req.Header.From.FromURI.User}.")
  sys.Dial("12345xxxxx@sipsorcery.com")
else
  sys.Email(ubj9BBv8PuvLUFV5ydscgjCnAB@api.pushover.net", "ANTUA Recibiendo Llamada ", " #{req.Header.From.FromURI.User}.")
  sys.Dial("12345xxxxx@sipsorcery.com")
end


User avatar
Aaron
Site Admin
Posts: 4563
Joined: Thu Jul 12, 2007 12:13 am

Re: Need help to make shorter a BLACKLIST and VOICEMAL dialp

Post by Aaron » Mon Aug 25, 2014 11:52 am

Looks like it's just some missing double quotes on the sys.Email call. Try this.

Code: Select all

blackList = ["^5289\d{8}", "^523334698333",  "^523336470333",  "^523339490333"]
voicemailList = ["^525591799333", "^anonymouz",  "^525591799333"]
papaList = ["^528183561333", "^528183561333",  "^anonymous"]

if blackList.find { |e| /req.Header.from.FromURI.User.to_s/ =~ e } != nil then
   sys.Email("ubj9BBv8PuvLUFV5ydscgjCn@api.pushover.net", "ANTUA Bloqueando a ", " #{req.Header.From.FromURI.User}.")
   sys.Respond(403, "Forbidden")
elsif voicemailList.find { |e| /req.Header.from.FromURI.User.to_s/ =~ e } != nil then
  sys.Email("ubj9BBv8PuvLUFV5ydscgjCn@api.pushover.net", "ANTUA al Buzon ", " #{req.Header.From.FromURI.User}.")
  sys.Dial("17772492333@in.callcentric.com")
elsif papaList.find { |e| /req.Header.from.FromURI.User.to_s/ =~ e } != nil then
  sys.Email("ubj9BBv8PuvLUFV5ydscgjCn@api.pushover.net", "Transfiriendo a PAPA ", " #{req.Header.From.FromURI.User}.")
  sys.Dial("12345xxxx@sipsorcery.com")
else
   sys.Email("ubj9BBv8PuvLUFV5ydscgjCnABHK59+p1@api.pushover.net", "ANTUA Recibiendo Llamada DE ", " #{req.Header.From.FromURI.User}.")
   sys.Email("jcolinspam.c4@m.evernote.com", "ANTUA Recibiendo Llamada DE ", " #{req.Header.From.FromURI.User}.")
   sys.Dial("12345xxxx@sipsorcery.com&17772492333@in.callcentric.com[dt=40]")
end

qubo
Posts: 127
Joined: Tue Apr 12, 2011 6:11 am

Re: Need help to make shorter a BLACKLIST and VOICEMAL dialp

Post by qubo » Tue Aug 26, 2014 3:33 pm

HI. I have been doing testing..... when I dial from mobile number and this number is in papaLIst. the log of incoming call is not showing the mobile number here the logs and maybe because the number does not appears it can not match with lists and therefore it goes with else statment. a note: the mobile number is detected by my pbx and phones but not in the logs. weird

Code: Select all

NATKeepAlive 15:21:48:418 sip1(10576): Requesting NAT keep-alive from proxy socket udp:67.222.131.147:5060 to udp:181.166.17.95:5060.
DialPlan 15:21:50:793 sip1(13852): Using dialplan incomingAntuaHQ for In call to sip:12345xxxx@sipsorcery.com;transport=TCP.
NewCall 15:21:50:808 sip1(13852): Executing script dial plan for call to 12345xxxxx.
DialPlan 15:21:50:855 sip1(13852): Email sent to ubj9BBv8PuvLUFV5ydscgjCn@api.pushover.net with subject of "ANTUA Recibiendo Llamada DE ".
DialPlan 15:21:50:855 sip1(13852): Email sent to jcolinspa@m.evernote.com with subject of "ANTUA Recibiendo Llamada DE ".
DialPlan 15:21:50:855 sip1(13852): Commencing Dial with: 12345xxxx@sipsorcery.com&17772492333@in.callcentric.com[dt=40].
DialPlan 15:21:50:855 sip1(13852): Call leg is for local domain looking up bindings for 12345xxxxx@sipsorcery.com for call leg 12345xxxxx@sipsorcery.com.
DialPlan 15:21:50:871 sip1(13852): 1 found for 12345xxxx@sipsorcery.com.
DialPlan 15:21:50:871 sip1(13852): Attempting to locate a provider for call leg: sip:17772492773@in.callcentric.com.
DialPlan 15:21:50:871 sip1(13852): ForkCall commencing call leg to sip:gw+sipsorcery@177.230.206.175:5080;transport=udp;gw=sipsorcery.
DialPlan 15:21:50:871 sip1(13852): ForkCall commencing call leg to sip:17772492773@in.callcentric.com.
DialPlan 15:21:50:871 sip1(13852): SIPClientUserAgent Call using alternate outbound proxy of udp:67.222.131.147:5060.
DialPlan 15:21:50:871 sip1(13852): Delaying call leg to sip:17772492xx3@in.callcentric.com by 40s.
DialPlan 15:21:50:871 sip1(13852): Switching to sip:gw+sipsorcery@177.230.206.175:5080 via udp:67.222.131.147:5060.
DialPlan 15:21:50:871 sip1(13852): SDP on UAC call had public IP not mangled, RTP socket 199.230.57.188:12232.
ContactRegisterInProgress 15:21:50:996 sip1(5444): Checking SIP Provider registration for VoipBusterGDL.
ContactRegisterInProgress 15:21:50:996 sip1(5444): Sending initial register for inquba and VoipBusterGDL to udp:77.72.169.129:5060.
ContactRegisterInProgress 15:21:50:996 sip1(5444): Initiating registration for inquba on sip:sip.voipbuster.com:5060.
DialPlan 15:21:51:043 sip1(13852): Information response 100 Trying for sip:gw+sipsorcery@177.230.206.175:5080;transport=udp;gw=sipsorcery.
ContactRegistered 15:21:51:308 sip1(5444): Contact successfully registered for inquba on sip:sip.voipbuster.com:5060, expiry 600s.
Registrar 15:21:51:449 sip1(10576): Binding update request for pbxxx@sipsorcery.com from tcp:177.230.206.175:42915, expiry requested 120s granted 120s.
DialPlan 15:21:51:464 sip1(13852): Information response 183 Session Progress for sip:gw+sipsorcery@177.230.206.175:5080;transport=udp;gw=sipsorcery.
DialPlan 15:21:51:464 sip1(13852): UAS call progressing with SessionProgress.
NATKeepAlive 15:21:53:464 sip1(10576): Requesting NAT keep-alive from proxy socket tcp:67.222.131.147:2060 to tcp:177.230.206.175:42915.
Registrar 15:21:55:246 sip1(10576): Binding update request for 5432xxxxx@sipsorcery.com from udp:177.230.206.175:5080, expiry requested 120s granted 120s.


User avatar
Aaron
Site Admin
Posts: 4563
Joined: Thu Jul 12, 2007 12:13 am

Re: Need help to make shorter a BLACKLIST and VOICEMAL dialp

Post by Aaron » Sun Aug 31, 2014 12:25 pm

I'm not exactly sure of the issue but it may be that the caller ID you want to match on is in a slightly different part of the From header (note that SIP does not have a concept of caller ID and the closest thing is the From header).

Instead of req.Header.From.FromURI.User.to_s you could experiment by replacing with the two fields below:

req.Header.From.ToString().to_s
req.Header.From.DisplayName.ToString().to_s

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest