Help with call blocking
Help with call blocking
I have been working on this for four days, all day, with no success. I have copied and pasted from Telis, Mnipp, TheFug and another. My outgoing has always worked fine (that I copied a couple months ago). I started getting 3AM calls immediately after signing up for IPkall last week. I saw that Telis added call blocking to his plan and I have been trying to paste it to various incoming plans with failure.
I don't need anything complicated, I just would like to add numbers that I could block. I have enclosed my outgoing (working fine) and the two incoming plans that seem to not mess up my outgoing but still don't block anything for me. Any advice very appreciated.
All my personal info has been substituted.
Area = '704'
# Google Voice accounts: login, password, callback number, match, phone type, callback tmo
GVaccounts = [
['cky@earthlink.net','Tdfdg','17472824822', '.*',7,12],
['cky@earthlink.net','Tdfdg','14016498593', '.*',1,10],
['cky@earthlink.net','Tdfdg','12532564635', '.*',1,10],
]
def gvcall(num,acnt)
a = GVaccounts[acnt % GVaccounts.length] # fetch params
sys.GoogleVoiceCall(*((a[0,3] << num) + a[3,10])) # insert number as 4th param
end
begin
sys.Log("** Call from #{req.Header.From.to_s} to #{req.URI.User} **")
if sys.Out # if outbound call
num = req.URI.User.to_s # Get a string copy of the number to dial
case num
when /^[2-9]\d{6}$/ # Local call, 7-digit number
num = '1'+ Area + num # prefix it with country and area code
when /^[01]?([2-9]\d{9})/ # US number with or without "1" country code
num = '1' + $1 # add country code and truncate number to 10-digit
else sys.Respond(603,'Wrong number, check & dial again')
end
sys.Log("Calling #{num} via Google Voice")
r = Time.now.to_i
3.times { |x| gvcall num,r+x }
else # sys.Out
sys.Dial("#{sys.Username}@local")
end
rescue
sys.Log("** Error: " + $!) unless $!.to_s =~ /Thread was being aborted./
end
# ruby # IN
sys.Trace = false
req.Header.From.FromName = "#{req.Header.From.FromURI.User}" # Workaround for sipgate callerid problem
# Logic for receiving incoming calls.
# BLACKLIST of unwanted Callers
case req.Header.from.FromURI.User.to_s
when /^4153385516$/ then sys.Respond(403, "Forbidden")
end
if sys.IsAvailable("#{req.URI.User}","sipsorcery.com") then
sys.Dial("#{req.URI.User}@local")
else
sys.Respond(480, "Not available")
end
MY OTHER SEPARATE ATTEMPT
# your INCOMING call processing.
# read Time
Tz = -5 # Time zone (GMT+10)Sydney AEST time change to (+11 ADST for daylight saving time)
t = Time.now.utc + (Tz*60*60) # Get current time in utc+0 and adjust to sydney time utc+10(or utc+11).
sys.Log(t.strftime('Local time: %c')) # log time
hhmm = t.strftime("%H%M")
starttime = '0800' # 8:00am(0800) to
stoptime = '0759' # 11:30pm(2330) 24 hour time
openhours = stoptime < starttime ? !((stoptime...starttime) === hhmm) : (starttime...stoptime) === hhmm
# SIP tracing : true or false
sys.Trace = false
sys.Log("call from #{req.Header.From.FromURI.ToString()} to #{req.URI.User}.") # log call
# The Following sets the incoming CALLERID NAME if not set
fromname = req.Header.From.FromName.to_s # create a copy of FromName
username = req.Header.from.FromURI.User.to_s # create a copy of userName
if fromname == "" or fromname == username then # if FromName empty or the same as username
if username =~ /^[0-9]*[0-9]$/
fromname = req.Header.From.FromURI.host.to_s # if a number display caller's host, else full address.
else
fromname = username + " " + req.Header.From.FromURI.host.to_s
end
end
sys.SetFromHeader(fromname, nil, nil) # Set FromName
sys.Log("FromName: '#{fromname}'") # log caller name
# BLACKLIST of unwanted Callers
case req.Header.from.FromURI.User.to_s
when /^4153385516$/ then sys.Respond(403, "Forbidden") # block calls from 999999 example
end
if sys.IsAvailable() and openhours then # if online and not midnight
sys.Dial("#{sys.Username}@local",60) # ring your phone for 60 seconds
sys.Respond(480, "(#{sys.Username}) Not Available") # response if not answered.
else
sys.Respond(480, "(#{sys.Username}) Not Available") if openhours # response if phone is not online.
hhmm = t.strftime("%I:%M %p") # Time (HH:MM AM) format
sys.Respond(480, "(#{hhmm})I'm asleep,call later") # response if middle of night.
end
I don't need anything complicated, I just would like to add numbers that I could block. I have enclosed my outgoing (working fine) and the two incoming plans that seem to not mess up my outgoing but still don't block anything for me. Any advice very appreciated.
All my personal info has been substituted.
Area = '704'
# Google Voice accounts: login, password, callback number, match, phone type, callback tmo
GVaccounts = [
['cky@earthlink.net','Tdfdg','17472824822', '.*',7,12],
['cky@earthlink.net','Tdfdg','14016498593', '.*',1,10],
['cky@earthlink.net','Tdfdg','12532564635', '.*',1,10],
]
def gvcall(num,acnt)
a = GVaccounts[acnt % GVaccounts.length] # fetch params
sys.GoogleVoiceCall(*((a[0,3] << num) + a[3,10])) # insert number as 4th param
end
begin
sys.Log("** Call from #{req.Header.From.to_s} to #{req.URI.User} **")
if sys.Out # if outbound call
num = req.URI.User.to_s # Get a string copy of the number to dial
case num
when /^[2-9]\d{6}$/ # Local call, 7-digit number
num = '1'+ Area + num # prefix it with country and area code
when /^[01]?([2-9]\d{9})/ # US number with or without "1" country code
num = '1' + $1 # add country code and truncate number to 10-digit
else sys.Respond(603,'Wrong number, check & dial again')
end
sys.Log("Calling #{num} via Google Voice")
r = Time.now.to_i
3.times { |x| gvcall num,r+x }
else # sys.Out
sys.Dial("#{sys.Username}@local")
end
rescue
sys.Log("** Error: " + $!) unless $!.to_s =~ /Thread was being aborted./
end
# ruby # IN
sys.Trace = false
req.Header.From.FromName = "#{req.Header.From.FromURI.User}" # Workaround for sipgate callerid problem
# Logic for receiving incoming calls.
# BLACKLIST of unwanted Callers
case req.Header.from.FromURI.User.to_s
when /^4153385516$/ then sys.Respond(403, "Forbidden")
end
if sys.IsAvailable("#{req.URI.User}","sipsorcery.com") then
sys.Dial("#{req.URI.User}@local")
else
sys.Respond(480, "Not available")
end
MY OTHER SEPARATE ATTEMPT
# your INCOMING call processing.
# read Time
Tz = -5 # Time zone (GMT+10)Sydney AEST time change to (+11 ADST for daylight saving time)
t = Time.now.utc + (Tz*60*60) # Get current time in utc+0 and adjust to sydney time utc+10(or utc+11).
sys.Log(t.strftime('Local time: %c')) # log time
hhmm = t.strftime("%H%M")
starttime = '0800' # 8:00am(0800) to
stoptime = '0759' # 11:30pm(2330) 24 hour time
openhours = stoptime < starttime ? !((stoptime...starttime) === hhmm) : (starttime...stoptime) === hhmm
# SIP tracing : true or false
sys.Trace = false
sys.Log("call from #{req.Header.From.FromURI.ToString()} to #{req.URI.User}.") # log call
# The Following sets the incoming CALLERID NAME if not set
fromname = req.Header.From.FromName.to_s # create a copy of FromName
username = req.Header.from.FromURI.User.to_s # create a copy of userName
if fromname == "" or fromname == username then # if FromName empty or the same as username
if username =~ /^[0-9]*[0-9]$/
fromname = req.Header.From.FromURI.host.to_s # if a number display caller's host, else full address.
else
fromname = username + " " + req.Header.From.FromURI.host.to_s
end
end
sys.SetFromHeader(fromname, nil, nil) # Set FromName
sys.Log("FromName: '#{fromname}'") # log caller name
# BLACKLIST of unwanted Callers
case req.Header.from.FromURI.User.to_s
when /^4153385516$/ then sys.Respond(403, "Forbidden") # block calls from 999999 example
end
if sys.IsAvailable() and openhours then # if online and not midnight
sys.Dial("#{sys.Username}@local",60) # ring your phone for 60 seconds
sys.Respond(480, "(#{sys.Username}) Not Available") # response if not answered.
else
sys.Respond(480, "(#{sys.Username}) Not Available") if openhours # response if phone is not online.
hhmm = t.strftime("%I:%M %p") # Time (HH:MM AM) format
sys.Respond(480, "(#{hhmm})I'm asleep,call later") # response if middle of night.
end
I would suggest removing the (^) character so you would be matching the number against the last 10 digits incase there were country code etc in front.
when /4153385516$/ then sys.Respond(403, "Forbidden") # block calls from 999999 example
blocks +44 4153385516, 04153385516 etc..
when /4153385516$/ then sys.Respond(403, "Forbidden") # block calls from 999999 example
blocks +44 4153385516, 04153385516 etc..
billion 7404VGP
dialplan (<9*:*>[0-9*][0-9*].T<:@sipbroker>|[0-9*].T)
dialplan (<9*:*>[0-9*][0-9*].T<:@sipbroker>|[0-9*].T)
The key is to be aware the callerid is usually either in the From URI User req.Header.From.FromURI.User or the From header display name req.Header.From.FromName so you should do some kind of check against them both.
Here's an example that might help get you started.
Regards,
Aaron
Here's an example that might help get you started.
Code: Select all
# Unless you know you need the line below I wouldn't recommend using it, doing so limits by half the callerid fields you have to filter on.
#req.Header.From.FromName = "#{req.Header.From.FromURI.User}" # Workaround for sipgate callerid problem
# Logic for receiving incoming calls.
# BLACKLIST of unwanted Callers
blacklist = ["4153385516",
"1234567890",
"666666666"]
if blacklist.include?(req.Header.From.FromURI.User) || blacklist.include?(req.Header.From.FromName)
sys.Log("Nasty caller, bye bye")
sys.Respond(488, "Piss off")
else
sys.Log("Nice caller, hello")
if sys.IsAvailable("#{req.URI.User}","sipsorcery.com") then
sys.Dial("#{req.URI.User}@local")
else
sys.Respond(480, "Not available")
end
end
Aaron
Where are you seeing this number, if it is callerID the number maybe in the FROM NAME part not USER.
I suggest test and block both.
I also removed the $ to match any form with those numbers together, beginning middle or end.
I suggest test and block both.
Code: Select all
case req.Header.from.FromURI.User.to_s
when /4153385516/ then sys.Respond(403, "Forbidden")
end
case req.Header.From.FromName.to_s
when /4153385516/ then sys.Respond(403, "Forbidden")
end
billion 7404VGP
dialplan (<9*:*>[0-9*][0-9*].T<:@sipbroker>|[0-9*].T)
dialplan (<9*:*>[0-9*][0-9*].T<:@sipbroker>|[0-9*].T)
Gentlemen,
I tried several test with no success, all calls get through. I see the number on the phone's caller ID in the number slot always and depending on which number I in with the ID can also be in the name slot, but always in the number slot.
TEST 1
#ruby in
# BLACKLIST of unwanted Callers
req.Header.From.FromName = "#{req.Header.From.FromURI.User}"
case req.Header.from.FromURI.User.to_s
when /4153385516/ then sys.Respond(403, "Forbidden")
end
case req.Header.From.FromName.to_s
when /4153385516/ then sys.Respond(403, "Forbidden")
end if sys.IsAvailable("#{req.URI.User}","sipsorcery.com") then
sys.Dial("#{req.URI.User}@local")
else
sys.Respond(480, "Not available")
end
TEST 2
# BLACKLIST of unwanted Callers
case req.Header.from.FromURI.User.to_s
when /4153385516/ then sys.Respond(403, "Forbidden")
end
case req.Header.From.FromName.to_s
when /4153385516/ then sys.Respond(403, "Forbidden")
end if sys.IsAvailable("#{req.URI.User}","sipsorcery.com") then
sys.Dial("#{req.URI.User}@local")
else
sys.Respond(480, "Not available")
end
TEST 3
# ruby # IN
# Unless you know you need the line below I wouldn't recommend using it, doing so limits by half the callerid fields you have to filter on.
#req.Header.From.FromName = "#{req.Header.From.FromURI.User}" # Workaround for sipgate callerid problem
# Logic for receiving incoming calls.
# BLACKLIST of unwanted Callers
blacklist = ["4153385516",
"1234567890",
"666666666"]
if blacklist.include?(req.Header.From.FromURI.User) || blacklist.include?(req.Header.From.FromName)
sys.Log("Nasty caller, bye bye")
sys.Respond(488, "Piss off")
else
sys.Log("Nice caller, hello")
if sys.IsAvailable("#{req.URI.User}","sipsorcery.com") then
sys.Dial("#{req.URI.User}@local")
else
sys.Respond(480, "Not available")
end
end
I tried several test with no success, all calls get through. I see the number on the phone's caller ID in the number slot always and depending on which number I in with the ID can also be in the name slot, but always in the number slot.
TEST 1
#ruby in
# BLACKLIST of unwanted Callers
req.Header.From.FromName = "#{req.Header.From.FromURI.User}"
case req.Header.from.FromURI.User.to_s
when /4153385516/ then sys.Respond(403, "Forbidden")
end
case req.Header.From.FromName.to_s
when /4153385516/ then sys.Respond(403, "Forbidden")
end if sys.IsAvailable("#{req.URI.User}","sipsorcery.com") then
sys.Dial("#{req.URI.User}@local")
else
sys.Respond(480, "Not available")
end
TEST 2
# BLACKLIST of unwanted Callers
case req.Header.from.FromURI.User.to_s
when /4153385516/ then sys.Respond(403, "Forbidden")
end
case req.Header.From.FromName.to_s
when /4153385516/ then sys.Respond(403, "Forbidden")
end if sys.IsAvailable("#{req.URI.User}","sipsorcery.com") then
sys.Dial("#{req.URI.User}@local")
else
sys.Respond(480, "Not available")
end
TEST 3
# ruby # IN
# Unless you know you need the line below I wouldn't recommend using it, doing so limits by half the callerid fields you have to filter on.
#req.Header.From.FromName = "#{req.Header.From.FromURI.User}" # Workaround for sipgate callerid problem
# Logic for receiving incoming calls.
# BLACKLIST of unwanted Callers
blacklist = ["4153385516",
"1234567890",
"666666666"]
if blacklist.include?(req.Header.From.FromURI.User) || blacklist.include?(req.Header.From.FromName)
sys.Log("Nasty caller, bye bye")
sys.Respond(488, "Piss off")
else
sys.Log("Nice caller, hello")
if sys.IsAvailable("#{req.URI.User}","sipsorcery.com") then
sys.Dial("#{req.URI.User}@local")
else
sys.Respond(480, "Not available")
end
end
I see nothing wrong with test2 or test3 in blocking a number you see in CallerID unless sipsorcery is not involved in the incoming call. If the call is not listed in the sipsorcery calls list the incoming is either your fixed line, a sipprovider registered directly by the phone not sipsorcery or someone hitting your phones IP address.
billion 7404VGP
dialplan (<9*:*>[0-9*][0-9*].T<:@sipbroker>|[0-9*].T)
dialplan (<9*:*>[0-9*][0-9*].T<:@sipbroker>|[0-9*].T)
Still not working
Mnipp
The ATA registers with SS. Just now my blocked Voxox # called my GV # that forwards to G5 that then forwards to SS and then my phone rings and on CID both name and number lines show the Voxox number.
Also the SS calls list shows the call. I used plan 2 this time.
The ATA registers with SS. Just now my blocked Voxox # called my GV # that forwards to G5 that then forwards to SS and then my phone rings and on CID both name and number lines show the Voxox number.
Also the SS calls list shows the call. I used plan 2 this time.
Re: Still not working
Have you tried logging the contents of the variables?deskbound wrote:Mnipp
The ATA registers with SS. Just now my blocked Voxox # called my GV # that forwards to G5 that then forwards to SS and then my phone rings and on CID both name and number lines show the Voxox number.
Also the SS calls list shows the call. I used plan 2 this time.
sys.Log("** FromUser:#{req.Header.from.FromURI.User.to_s} FromName:#{req.Header.From.FromName} URIUser:#{req.URI.User}**")
Then compare to 4153385516
Code: Select all
TEST 2
# BLACKLIST of unwanted Callers
sys.Log("** FromUser:#{req.Header.from.FromURI.User.to_s} FromName:#{req.Header.From.FromName} URIUser:#{req.URI.User}**")
case req.Header.from.FromURI.User.to_s
when /4153385516/ then sys.Respond(403, "Forbidden")
end
case req.Header.From.FromName.to_s
when /4153385516/ then sys.Respond(403, "Forbidden")
end
if sys.IsAvailable("#{req.URI.User}","sipsorcery.com") then
sys.Dial("#{req.URI.User}@local")
else
sys.Respond(480, "Not available")
end