Help with a Guyana Dial Plan

Catalog of dial plans
arampe
Posts: 70
Joined: Mon Nov 15, 2010 11:38 pm

Re: Help with a Guyana Dial Plan

Post by arampe » Mon Oct 17, 2011 7:14 pm

Thanks so far...
I reapplied the dial plan code to 250809 and this is what I get .....strange.


Dialed Guyana 5922271360 ....
it seems that is goes through google voice.

Code: Select all


NATKeepAlive 19:08:37:249 sip1(4248): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.83.188.12:5060.
DialPlan 19:08:39:827 sip1(6584): New call from udp:212.150.136.17:53579 successfully authenticated by digest.
DialPlan 19:08:39:843 sip1(6584): Using dialplan 250809 for Out call to sip:5922271360@sipsorcery.com.
NewCall 19:08:39:843 sip1(6584): Executing script dial plan for call to 5922271360.
DialPlan 19:08:39:905 sip1(6584): ** Call from <sip:AdeshOffice@sipsorcery.com>;tag=626c4079630519109337db56afa521e3 to 5922271360 **
DialPlan 19:08:39:905 sip1(6584): Local time: 10/17/2011 15:08
DialPlan 19:08:39:921 sip1(6584): Number in ENUM format: 15922271360
DialPlan 19:08:39:983 sip1(6584): Calling +1 (592) 227-1360 (USA/Can) with Google Voice
DialPlan 19:08:39:999 sip1(6584): SDP on GoogleVoiceCall call had public IP not mangled, RTP socket 212.150.136.17:61730.
DialPlan 19:08:39:999 sip1(6584): UAS call progressing with Ringing.
DialPlan 19:08:39:999 sip1(6584): Logging into google.com for arampe.
DialPlan 19:08:40:046 sip1(6584): Google Voice pre-login page loaded successfully.
DialPlan 19:08:40:108 sip1(6584): GALX key r23DIAFvzwA successfully retrieved.
DialPlan 19:08:41:093 sip1(6584): Google Voice home page loaded successfully.
DialPlan 19:08:41:171 sip1(6584): Call key LIm5F3pGRt/+BONBRMAQPlzvOUA= successfully retrieved for arampe, proceeding with callback.
DialPlan 19:08:41:171 sip1(1812): SIP Proxy setting application server for next call to user 250809 as udp:69.59.142.213:5070.
DialPlan 19:08:41:311 sip1(6584): Google Voice Call to +15922271360 initiated, callback #3057604525, phone type 1, timeout 10s.
NATKeepAlive 19:08:42:311 sip1(4248): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.80.78.52:55555.
NATKeepAlive 19:08:42:327 sip1(4248): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:212.150.136.17:53579.
NATKeepAlive 19:08:42:327 sip1(4248): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.213.188.244:5060.
NATKeepAlive 19:08:42:327 sip1(4248): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.83.139.2:1025.
NATKeepAlive 19:08:42:327 sip1(4248): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.83.139.2:5061.
DialPlan 19:08:42:483 sip1(6584): Google Voice Call callback received.
DialPlan 19:08:42:483 sip1(6584): Answering client call with a response status of 200.
DialPlan 19:08:42:561 sip1(6584): Google Voice Call was successfully answered in 2.56s.
DialPlan 19:08:42:561 sip1(6584): Dialplan cleanup for 250809.
DialPlan 19:08:42:936 sip1(6584): Dial plan execution completed with normal clearing.
NATKeepAlive 19:08:47:374 sip1(4248): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.83.188.12:5060.
DialPlan 19:08:49:124 sip1(6584): Matching dialogue found for BYE to sip:69.59.142.213:5060 from udp:69.59.142.213:5060.
NATKeepAlive 19:08:52:421 sip1(4248): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.80.78.52:55555.
NATKeepAlive 19:08:52:437 sip1(4248): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:212.150.136.17:53579.
NATKeepAlive 19:08:52:437 sip1(4248): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.213.188.244:5060.
NATKeepAlive 19:08:52:437 sip1(4248): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.83.139.2:1025.
NATKeepAlive 19:08:52:437 sip1(4248): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.83.139.2:5061.

Dialed Trindad ....
This seems to be hitting the PSTN but the calls fails ..?

Code: Select all

NATKeepAlive 19:09:22:781 sip1(4248): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:212.150.136.17:53579.
NATKeepAlive 19:09:22:781 sip1(4248): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.213.188.244:5060.
NATKeepAlive 19:09:22:781 sip1(4248): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.83.139.2:1025.
NATKeepAlive 19:09:22:781 sip1(4248): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.83.139.2:5061.
NATKeepAlive 19:09:27:828 sip1(4248): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.83.188.12:5060.
NATKeepAlive 19:09:32:875 sip1(4248): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.80.78.52:55555.
NATKeepAlive 19:09:32:890 sip1(4248): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:212.150.136.17:53579.
NATKeepAlive 19:09:32:890 sip1(4248): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.213.188.244:5060.
NATKeepAlive 19:09:32:890 sip1(4248): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.83.139.2:1025.
NATKeepAlive 19:09:32:906 sip1(4248): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.83.139.2:5061.
DialPlan 19:09:35:734 sip1(6584): New call from udp:212.150.136.17:53579 successfully authenticated by digest.
DialPlan 19:09:35:750 sip1(6584): Using dialplan 250809 for Out call to sip:18686652551@sipsorcery.com.
NewCall 19:09:35:750 sip1(6584): Executing script dial plan for call to 18686652551.
DialPlan 19:09:35:812 sip1(6584): ** Call from <sip:AdeshOffice@sipsorcery.com>;tag=25c19579630519109338db56afa521e3 to 18686652551 **
DialPlan 19:09:35:812 sip1(6584): Local time: 10/17/2011 15:09
DialPlan 19:09:35:828 sip1(6584): Number in ENUM format: 18686652551
DialPlan 19:09:35:968 sip1(6584): Calling +1 (868) 665-2551 (Trinidad & Tobago) with SPA3102 at home
DialPlan 19:09:35:968 sip1(6584): Commencing Dial with: 8686652551@pstn.
DialPlan 19:09:35:968 sip1(6584): Attempting to locate a provider for call leg: sip:8686652551@pstn.
DialPlan 19:09:35:968 sip1(6584): ForkCall commencing call leg to sip:8686652551@190.83.139.2:5061.
DialPlan 19:09:35:968 sip1(6584): Switching to sip:8686652551@190.83.139.2:5061 via udp:69.59.142.213:5060.
DialPlan 19:09:35:968 sip1(6584): SDP on UAC call had public IP not mangled, RTP socket 212.150.136.17:58156.
DialPlan 19:09:36:125 sip1(6584): Information response 100 Trying for sip:8686652551@190.83.139.2:5061.
DialPlan 19:09:36:125 sip1(6584): Response 504 Service Unavailable for sip:8686652551@190.83.139.2:5061.
DialPlan 19:09:36:140 sip1(6584): Call failed: code 504, Service Unavailable
DialPlan 19:09:36:140 sip1(6584): UAS call failed with a response status of 504 and Service Unavailable.
DialPlan 19:09:36:140 sip1(6584): Dialplan cleanup for 250809.
DialPlan 19:09:36:156 sip1(6584): Dial plan execution completed with normal clearing.
NATKeepAlive 19:09:37:937 sip1(4248): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.83.188.12:5060.
NATKeepAlive 19:09:43:000 sip1(4248): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.80.78.52:55555.
NATKeepAlive 19:09:43:015 sip1(4248): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:212.150.136.17:53579.
NATKeepAlive 19:09:43:015 sip1(4248): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.213.188.244:5060.
NATKeepAlive 19:09:43:015 sip1(4248): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.83.139.2:1025.
NATKeepAlive 19:09:43:015 sip1(4248): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.83.139.2:5061.
NATKeepAlive 19:09:48:047 sip1(4248): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.83.188.12:5060.
Dialed China ...
This also goes to Google voice ...?

Code: Select all

NATKeepAlive 19:10:13:344 sip1(4248): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.83.139.2:1025.
NATKeepAlive 19:10:13:359 sip1(4248): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.83.139.2:5061.
NATKeepAlive 19:10:18:391 sip1(4248): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.83.188.12:5060.
Registrar 19:10:18:922 sip1(4248): Binding update request for donna123@sipsorcery.com from udp:190.80.78.52:55555, expiry requested 120s granted 120s.
DialPlan 19:10:20:891 sip1(6584): New call from udp:212.150.136.17:53579 successfully authenticated by digest.
DialPlan 19:10:20:906 sip1(6584): Using dialplan 250809 for Out call to sip:8613452314456@sipsorcery.com.
NewCall 19:10:20:906 sip1(6584): Executing script dial plan for call to 8613452314456.
DialPlan 19:10:20:969 sip1(6584): ** Call from <sip:AdeshOffice@sipsorcery.com>;tag=88a8da79630519109339db56afa521e3 to 8613452314456 **
DialPlan 19:10:20:969 sip1(6584): Local time: 10/17/2011 15:10
DialPlan 19:10:20:985 sip1(6584): Number in ENUM format: 18613452314
DialPlan 19:10:21:328 sip1(6584): Calling +1 (861) 345-2314 (USA/Can) with Google Voice
DialPlan 19:10:21:328 sip1(6584): SDP on GoogleVoiceCall call had public IP not mangled, RTP socket 212.150.136.17:61854.
DialPlan 19:10:21:328 sip1(6584): UAS call progressing with Ringing.
DialPlan 19:10:21:328 sip1(6584): Logging into google.com for arampe.
DialPlan 19:10:21:391 sip1(6584): Google Voice pre-login page loaded successfully.
DialPlan 19:10:21:422 sip1(6584): GALX key bnTCUUUg1RM successfully retrieved.
DialPlan 19:10:22:594 sip1(6584): Google Voice home page loaded successfully.
DialPlan 19:10:22:656 sip1(6584): Call key LIm5F3pGRt/+BONBRMAQPlzvOUA= successfully retrieved for arampe, proceeding with callback.
DialPlan 19:10:22:656 sip1(1812): SIP Proxy setting application server for next call to user 250809 as udp:69.59.142.213:5070.
DialPlan 19:10:22:813 sip1(6584): Google Voice Call to +18613452314 initiated, callback #3057604525, phone type 1, timeout 10s.
NATKeepAlive 19:10:23:453 sip1(4248): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.80.78.52:55555.
NATKeepAlive 19:10:23:453 sip1(4248): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:212.150.136.17:53579.
NATKeepAlive 19:10:23:469 sip1(4248): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.213.188.244:5060.
NATKeepAlive 19:10:23:469 sip1(4248): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.83.139.2:1025.
NATKeepAlive 19:10:23:469 sip1(4248): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.83.139.2:5061.
DialPlan 19:10:24:156 sip1(6584): Google Voice Call callback received.
DialPlan 19:10:24:156 sip1(6584): Answering client call with a response status of 200.
DialPlan 19:10:24:203 sip1(6584): Google Voice Call was successfully answered in 2.88s.
DialPlan 19:10:24:203 sip1(6584): Dialplan cleanup for 250809.
DialPlan 19:10:24:235 sip1(6584): Dial plan execution completed with normal clearing.
NATKeepAlive 19:10:28:500 sip1(4248): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.83.188.12:5060.
Registrar 19:10:29:047 sip1(4248): Binding update request for mmplas@sipsorcery.com from udp:190.83.139.2:1025, expiry requested 3600s granted 3600s.
Registrar 19:10:29:047 sip1(4248): Binding update request for 2508091@sipsorcery.com from udp:190.83.139.2:5061, expiry requested 3600s granted 3600s.
DialPlan 19:10:29:860 sip1(6584): Matching dialogue found for BYE to sip:69.59.142.213:5060 from udp:69.59.142.213:5060.
NATKeepAlive 19:10:33:563 sip1(4248): Requesting 

Dial Plan ...

Code: Select all


# Copyright 2010 Mike Telis
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
# Donna123 - sipgate - adesh@vijaysconsulting.com - ashton1 - (518) 351-1348
# Amyboodhram - sipgate - adesh@mmplas.com - ashton1 - (650) 284-1494
# Andy and Melly - sipgate - arampe@gmail.com - ashton1 -  


require 'mikesgem'

# ************* C O N F I G U R A T I O N    S E C T I O N *************** #

Area = '868'          # my area code, this will be added to 7-digit dialouts
Tz   = -4             # my time zone (GMT format, e.g. Eastern = -5, Central = -6)

# Speed dial entries. Format: "key" => "number"

Speeddial = {
  
  '1'   => '(347) 561-4880',           # Michelle home
  '2'   => '(646) 573-2819',           # Michelle Cell
  '3'   => '(347) 210-6631',           # Vijay Cell
  '4'   => '(443) 636-7891',           # Paro Cell
  '5'   => '(360) 812-2613',           # Dad ipkall usa #
  '6'   => '008613375798811@powervoip',# Lu Peck Cell
  '7'   => '203@Nygames[ma=false]',    # Vijay home ext
  '7599373'   => '2508091@local',     # Test
  '203' => '203@Nygames',              # Vijay home ext
  '204' => '(213) 884-6354',           # Tangir Alam
  '444' => 'ecuador@local',              # Ecuador ext
  '266' => 'Bharrath@local',           # Dad home
  '269' => 'Ashtoniphone@local',           # Dad home
  '268' => 'Mellyphone@local',           # Dad home
  '253' => 'amyboodhram@local',        # Amy
  '264' => 'mmplas@local',             # office
  '263' => 'Andy_and_Melly@local',     # Home
  '265' => 'AdeshOffice@local',        # adesh
  '270' => '00115922271360@voipbusterpro',
  '273' => 'donna123@local',           # Donna Dos Santos
  '275' => '5926243120@PSTN',       # Donna Cell
  '274' => '00115926835784@powervoip',       # Ignatius cell
  '277' => '5922271360@Nygames',       # Donna Home
  '712'   => '*#2 454-1234',           # San Jose Voice Mail, dial my SJ GV using SFO GV acnt
  '713'   => '*#1 (415) 335-1234',     # San Francisco Voice Mail, dial my SFO GV using SJ GV acnt
  '714'  => '*#1 (773) 778-1234',      # San Francisco Voice Mail, dial my Chicago GV using SJ GV acnt
  '411' => '(800) 466-4411',           # Google's Directory Assistance, GOOG-411
  '200' => '303@sip.blueface.ie&612@fwd.pulver.com',
  '300' => '441923287748@Voxalot',     # BT speaking clock 
  '666' => '4153767253@podlinez.net',  # CNN Headlines (266 = "CNN")
  '677' => '8186882773@podlinez.net',  # NPR's most e-mailed stories (677 ="NPR")
  '742' => '6506441934@podlinez.net',  # Prairie Home Companion's, or PHC's
                                       # News from Lake Wobegon (742 = "PHC")
  '932' => '7755333366',               # Columbus OH-based national weather (932 = "WEA[ther]")
}

# CNAM table: number in ENUM format => caller's name

CNAM = {
'(212) 555-1212' => 'Dear mom',
'(240) 418-3987' => 'Aunty Tina',
'(718) 908-2828' => 'Ali infinity',
'(718) 656-1001' => 'Michelle Gomez Work',
'(443) 850-7625' => 'Aunty Ann Aponte',
'(864) 502-8863' => 'Daddy',
'(347) 857-9902' => 'Aunty Donna Guyana',
'(347) 441-0605' => 'Amy and Richard',
'(347) 561-4880' => 'Michelle Gomez Home',
'(443) 739-9497' => 'Diana Pinky Ramlal cell',
'(315) 895-1479' => 'Hey people Wake Up it is Six AM',
'(646) 573-2819' => 'Michelle Gomez Cell',
'(718) 502-8863' => 'Andy and Melly',
'(718) 879-8933' => 'Vijay Home', 
'(347) 210-6631' => 'Vijay Cell',
'(917) 443-2170' => 'Nishal Ramnarine',
'(754) 245-3916' => 'Rachael Diaz',
'(213) 884-6354' => 'Tangir Alam',
'(215) 333-2211' => 'Bratty kid',
}

# Uncomment next line and insert your White Pages API key, if you have it
# WP_key = '702f53d569ee0374b4b1dafa62fe72fc'     # White Pages API key

# Uncomment line below to enable misdialing safeguards
# EnableSafeguards = 1

# Excluded Prefixes. Provides a safeguard against accidentally calling premium numbers

ExcludedPrefixes = [
   ' 1 (900 | 809)',               # USA Premium
   ' 1 \d\d\d 555 1212',           # USA Directory assistance
   '44 (9 | 55 | 70 | 84 | 87)',   # UK Premium
   '49 (1 [^567] | 900)',          # Germany Premium
   '39 (1 | 84 | 89)',             # Italy Premium
   '420 90',                       # Czech Premium
   '32 (70 | 90\d)',               # Belgium Premium
]

# Yet another safeguard, list of blessed country codes

Allowed_Country = %w{
1 33 36 37[0-2] 380 39 41 420 44 49 61 7 86 883 886 90 972 998
}

# My own ENUM database

MyENUM = {
'+1 (408) 334-1234' => 'brother@local', # Brother George
}

# Enum database list

EnumDB = [
  MyENUM,                             # look in MyENUM first
'e164.org',
'e164.info',
'e164.arpa',
'e164.televolution.net',
'enum.org',
]

# Serviced domains, must be in lowercase!

Domains  = ['sipsorcery.com','sip.sipsorcery.com','sip1.sipsorcery.com','sip2.sipsorcery.com','69.59.142.213']
Host     = 'sipsorcery.com'        # Replaces "host" on incoming calls

# Google Voice accounts

GoogleVoice   = GV.new  '#2', nil, 'Google Voice', :usr => 'zzzzzzzzzz', :pwd => 'zzzzzzzzz',
                                                   :cb => '(305) 760-4525', :match => '7185028863'

Voipstunt     = VSP.new '#3', '00 ${EXTEN}@Voxalot', 'Voipstunt'
Nygames       = VSP.new '#4', '01 ${EXTEN}@Voxalot', 'Voipstunt'

PSTN          = VSP.new '#1', '${EXTEN:1}@pstn', 'SPA3102 at home'

   
# ********************  s e l e c t   V S P  *******************************

def selectVSP # VoIP provider selection

case @num
when /(^1([2-9]\d\d)[2-9]\d{6})/ # North America
@num = $1 # Truncate to 11 digits
case $2 # check area code
when "868" # Trinidad
route_to PSTN, "Trinidad & Tobago"
else
route_to GoogleVoice, 'USA/Can' # all other destinations within US & Canada
end

when /^592\d{7}$/ # Guyana
route_to PSTN, "Guyana"

when /^86/ # China
route_to PowerVOIP, 'China'

when /^\*/ # For *500, *600 and other Voxalot services
route_to Voxalot, "Voxalot Services", nil

else
rejectCall(603,"Number's too short, check & dial again") if @num.length < 9
route_to Voipstunt
end
end

# ------------ O P T I O N A L   C O N F I G U R A T I O N --------------- #

# ********************  i n c o m i n g   C a l l  *************************

def incomingCall
  sys.SetFromHeader(formatNum(@cname || @cid,true), nil, Host)  # Set FromName & FromHost for sys.Dial

  # Forward call to the bindings (ATA / softphone)
  # Change FromURI when forwarding to @local, or else Bria won't find contact in its phonebook!

  callswitch("#{@user}@local[fu=#{@cid}]",45) unless (2230..2231) === @t.hour*100 + @t.min # reject incoming calls from 10:30p to 10:31p

  @code, @reason = 480, "#{@user} is asleep" unless @code # if nothing else, must be the night hour
  @code = 486 if @trunk =~ /IPCOMM/i ## *** temporary fix for IPCOMMS ***
end

# **************************  t o   E N U M  *******************************

def to_ENUM num
  num.gsub!(/[^0-9*+]/,'') # Delete all fancy chars (only digits, '+' and '*' allowed)

  # Check if the number begins with one of international prefixes:
  #  '+' - international format
  #   00 - European style international prefix (00)
  #  011 - US style international prefix (011)

  num =~ /^(\+|00|011)/ and return $' # if yes, remove prefix and return

  case num                    # Special cases
    when /^[2-9]\d{6}$/       # Local call, 7-digit number
      '1' + Area + num        # prefix it with country and area code
    when /^[01]?([2-9]\d{9})/ # US number with or without "1" country code
      '1' + $1                # add country code and truncate number to 10-digit
    when /^\*/                # Voxalot voicemail, echotest & other special numbers
      num                     # ... as is
    else
      rejectCall(603,"Wrong number: '#{num}', check & dial again")
  end
end

# ****** E N D   O F   C O N F I G U R A T I O N    S E C T I O N ******** #

# **************************  C A L L    S W I T C H  **********************

def callswitch(num,*args)
  @timeout = args[0]
  num.gsub!(/%([0-9A-F]{2})/) {$1.to_i(16).chr} # Convert %hh into ASCII
  @num = Speeddial[num] || num  # If there is speed dial entry for it...

  if @num =~ /@/              # If we already have URI, just dial and return
    sys.Log("URI dialing: #@num")
    dial(@num,*args)
  else                        # Not URI
    rexp = VSP.tab.keys.sort {|a,b| b.length <=> a.length}.map {|x| Regexp.escape(x)}.join('|')
    if @num =~ /^(#{rexp})/   # If number starts with VSP selection prefix
      @num = $'; @forcedRoute = VSP.tab[$1]
      @noSafeGuards = (@forcedRoute.fmt =~ /Disable\s*Safe\s*Guards/i)
    end

    @num = to_ENUM(@num)      # Convert to ENUM

    rejectCall(503,"Number's empty") if @num.empty?
    sys.Log("Number in ENUM format: #{@num}")
    if @forcedRoute && !@noSafeGuards
      route_to @forcedRoute, "Forced routing!", false # if forced with prefix, skip ENUM, safeguards & VSP selection
    else
      checkNum if defined?(EnableSafeguards) && !@noSafeGuards
      selectVSP               # Pick appropriate provider for the call
    end
  end   # URI
end

# ***************************  R O U T E _ T O  ****************************

def route_to vsp, dest=nil, enum = EnumDB
  enum.to_a.each do |db|   # if enum enabled, look in all enum databases
    if uri = (db.class == Hash)? db[@num] : sys.ENUMLookup("#{@num}.#{db}")
      sys.Log("ENUM entry found: '#{uri}' in #{db.class == Hash ? 'local' : db} database")
      dial(uri)
    end
  end                   # ENUM not found or failed, call via regular VSP

  return unless vsp     # No VSP - do nothing

  uri = vsp.fmt.gsub(/\s+/,'').gsub(/\$\{EXTEN(:([^:}]+)(:([^}]+))?)?\}/) {@num[$2.to_i,$4? $4.to_i : 100]}
  dest &&= " (#{dest})"; with = vsp.name; with &&= " with #{with}"
  sys.Log("Calling #{formatNum(@num)}#{dest}#{with}")

  if vsp.is_gv?
    vsp.repeat.times do |i|
      @code, @reason = 200, "OK"  # assume OK
      sys.GoogleVoiceCall *vsp.getparams(uri, i + (vsp.rand ? @t.to_i : 0))
      sys.Log("Google Voice Call failed!")
      @code, @reason = 603, 'Service Unavailable'
    end
  else
    vsp.repeat.times do
      dial(uri, @timeout || vsp.tmo || 300) # Dial, global time-out overrides account
    end
  end
end

# *******************************  D I A L  ********************************

def dial *args
  @code, @reason = nil
  sys.Dial *args    # dial URI
  status()          # We shouldn't be here! Get error code...
  sys.Log("Call failed: code #{@code}, #{@reason}")
end

# *****************************  S T A T U S  ******************************

def status
  begin
    @code, @reason = 487, 'Cancelled by Sipsorcery'
    sys.LastDialled.each do |ptr|
      if ptr
        ptr = ptr.TransactionFinalResponse
        @code = ptr.StatusCode; @reason = ptr.ReasonPhrase; break if @code == 200
#       sys.Log("#{ptr.ToString()}")
      end
    end
  rescue
  end
end

# ************************  r e j e c t C a l l  ***************************

def rejectCall code, reason
  @code = code; @reason = reason
  sys.Respond code, reason
end

# ****************************  C H E C K   N U M **************************

def checkNum
  return if @num.match(/^\D/)  # skip if number doesn't begin with a digit

  # Reject calls to not blessed countries and premium numbers
  # (unless VSP was forced using #n dial prefix)

  rejectCall(503,"Calls to code #{formatNum(@num).split(' ')[0]} not allowed") \
    unless @num.match "^(#{Allowed_Country.join('|')})"

  rejectCall(503,"Calls to '#{formatNum($&)}' not allowed") if @num.match \
    '^(' + ExcludedPrefixes.map { |x| "(:?#{x.gsub(/\s*/,'')})" }.join('|') + ')'
end

# **********************  k e y s   t o   E N U M  *************************

def keys_to_ENUM (table)
  Hash[*table.keys.map! {|key| to_ENUM(key.dup)}.zip(table.values).flatten]
end

# **************************  g e t T I M E  *******************************

def getTime
  Time.now + ((Tz+7)*60*60) # Get current time and adjust to local. SS Server is in GMT-8
end

# *******************************  M A I N  ********************************

begin
  sys.Log("** Call from #{req.Header.From} to #{req.URI.User} **")
  sys.ExtendScriptTimeout(15)   # preventing long running dialscript time-out
  @t = getTime()
  sys.Log(@t.strftime('Local time: %c'))
  EnumDB.map! {|x| x.class == Hash ? keys_to_ENUM(x) : x } # rebuild local ENUM table

  if sys.In               # If incoming call...
    @cid = req.Header.from.FromURI.User.to_s    # Get caller ID

    # Prepend 10-digit numbers with "1" (US country code) and remove int'l prefix (if present)

    @cid = ('1' + @cid) if @cid =~ /^[2-9]\d\d[2-9]\d{6}$/
    @cid.sub!(/^(\+|00|011)/,'')   # Remove international prefixes, if any

    prs = req.URI.User.split('.')  # parse User into chunks
    @trunk = prs[-2]               # get trunk name
    @user  = prs[-1]               # called user name

    # Check CNAM first. If not found and US number, try to lookup caller's name in Whitepages

    if !(@cname = keys_to_ENUM(CNAM)[@cid]) && @cid =~ /^1([2-9]\d\d[2-9]\d{6})$/ && defined?(WP_key)
      url = "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20xml%20where%20url%3D'http%3A%2F%2Fapi.whitepages.com%2Freverse_phone%2F1.0%2F%3Fphone%3D#{$1}%3Bapi_key%3D#{WP_key}'%20and%20itemPath%3D'wp.listings.listing'&format=json"
      if js = sys.WebGet(url,4).to_s
        @cname, dname, city, state = %w(businessname displayname city state).map {|x| js =~ /"#{x}":"([^"]+)"/; $1}
        @cname ||= dname; @cname ||= "#{city}, #{state}" if city && state
      end
    end

    sys.Log("Caller's number: '#{@cid}'"); sys.Log("Caller's name:   '#{@cname}'") if @cname
    incomingCall()        # forward incoming call

  else                    # Outbound call ...

    # check if it's URI or phone number.
    # If destination's host is in our domain, it's a phone call

    num = req.URI.User.to_s; reqHost = req.URI.Host.to_s  # Get User and Host
    host = reqHost.downcase.slice(/[^:]+/)                # Convert to lowercase and delete optional ":port"
    num << '@' << reqHost unless Domains.include?(host)   # URI dialing unless host is in our domain list

    callswitch(num)

  end
  sys.Respond(@code,@reason) # Forward error code to ATA
rescue
   # Gives a lot more details at what went wrong (borrowed from Myatus' dialplan)
   sys.Log("** Error: " + $!) unless $!.to_s =~ /Thread was being aborted./
end
So what am I doing wrong ...

Regards
Adesh..

MikeTelis
Posts: 1582
Joined: Wed Jul 30, 2008 6:48 am

Re: Help with a Guyana Dial Plan

Post by MikeTelis » Tue Oct 18, 2011 2:42 am

Using dialplan 250809 for Out call to sip:5922271360@sipsorcery.com
The call went to Google Voice because you did not dial international prefix (011 or 00). Should dial 011 592 227 1360. Same applies to your calls to China, use international prefix!
arampe wrote:Dialed Trindad ....
This seems to be hitting the PSTN but the calls fails ..?
Yes, it got 504 response from SPA3102. Probably your device is configured to accept only 7-digit numbers, not 10-digit? If so, strip out 868 (change EXTEN:1 to EXTEN:4).

arampe
Posts: 70
Joined: Mon Nov 15, 2010 11:38 pm

Re: Help with a Guyana Dial Plan

Post by arampe » Tue Oct 18, 2011 1:41 pm

thanks mike ,,,,help !

Dialed Guyana with 011 prefix, but it hits PSTN with more numbers. only need 7 digits....

Code: Select all


NATKeepAlive 13:38:17:458 sip1(4248): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.83.139.2:1025.
NATKeepAlive 13:38:17:458 sip1(4248): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.83.139.2:5061.
NATKeepAlive 13:38:22:474 sip1(4248): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.213.188.244:50001.
NATKeepAlive 13:38:22:521 sip1(4248): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.213.188.244:5060.
NATKeepAlive 13:38:27:536 sip1(4248): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:212.150.129.78:15431.
NATKeepAlive 13:38:27:552 sip1(4248): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.80.78.52:55555.
NATKeepAlive 13:38:27:552 sip1(4248): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.83.188.12:5060.
NATKeepAlive 13:38:27:568 sip1(4248): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.83.139.2:1025.
NATKeepAlive 13:38:27:583 sip1(4248): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.83.139.2:5061.
NATKeepAlive 13:38:32:583 sip1(4248): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.213.188.244:50001.
NATKeepAlive 13:38:32:630 sip1(4248): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.213.188.244:5060.
DialPlan 13:38:33:990 sip1(5900): New call from udp:212.150.129.78:15431 successfully authenticated by digest.
DialPlan 13:38:34:005 sip1(5900): Using dialplan 250809 for Out call to sip:0115922271360@sipsorcery.com.
NewCall 13:38:34:005 sip1(5900): Executing script dial plan for call to 0115922271360.
DialPlan 13:38:34:083 sip1(5900): ** Call from <sip:AdeshOffice@sipsorcery.com>;tag=2f112f06650519108101a7c4512f4191 to 0115922271360 **
DialPlan 13:38:34:083 sip1(5900): Local time: 10/18/2011 09:38
DialPlan 13:38:34:099 sip1(5900): Number in ENUM format: 5922271360
DialPlan 13:38:34:255 sip1(5900): Calling +592 2271360 (Guyana) with SPA3102 at home
DialPlan 13:38:34:271 sip1(5900): Commencing Dial with: 922271360@pstn.
DialPlan 13:38:34:271 sip1(5900): Attempting to locate a provider for call leg: sip:922271360@pstn.
DialPlan 13:38:34:271 sip1(5900): ForkCall commencing call leg to sip:922271360@190.83.139.2:5061.
DialPlan 13:38:34:271 sip1(5900): Switching to sip:922271360@190.83.139.2:5061 via udp:69.59.142.213:5060.
DialPlan 13:38:34:271 sip1(5900): SDP on UAC call had public IP not mangled, RTP socket 212.150.129.78:61940.
DialPlan 13:38:34:443 sip1(5900): Information response 100 Trying for sip:922271360@190.83.139.2:5061.
DialPlan 13:38:34:443 sip1(5900): Response 504 Service Unavailable for sip:922271360@190.83.139.2:5061.
DialPlan 13:38:34:458 sip1(5900): Call failed: code 504, Service Unavailable
DialPlan 13:38:34:458 sip1(5900): UAS call failed with a response status of 504 and Service Unavailable.
DialPlan 13:38:34:458 sip1(5900): Dialplan cleanup for 250809.
DialPlan 13:38:34:458 sip1(5900): Dial plan execution completed with normal clearing.
NATKeepAlive 13:38:37:646 sip1(4248): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:212.150.129.78:15431.
NATKeepAlive 13:38:37:662 sip1(4248): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.80.78.52:55555.
NATKeepAlive 13:38:37:662 sip1(4248): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.83.188.12:5060.
NATKeepAlive 13:38:37:677 sip1(4248): Requesting NAT keep-alive from proxy socket udp:6

Code: Select all


# Copyright 2010 Mike Telis
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
# Donna123 - sipgate - adesh@vijaysconsulting.com - ashton1 - (518) 351-1348
# Amyboodhram - sipgate - adesh@mmplas.com - ashton1 - (650) 284-1494
# Andy and Melly - sipgate - arampe@gmail.com - ashton1 -  


require 'mikesgem'

# ************* C O N F I G U R A T I O N    S E C T I O N *************** #

Area = '868'          # my area code, this will be added to 7-digit dialouts
Tz   = -4             # my time zone (GMT format, e.g. Eastern = -5, Central = -6)

# Speed dial entries. Format: "key" => "number"

Speeddial = {
  
  '1'   => '(347) 561-4880',           # Michelle home
  '2'   => '(646) 573-2819',           # Michelle Cell
  '3'   => '(347) 210-6631',           # Vijay Cell
  '4'   => '(443) 636-7891',           # Paro Cell
  '5'   => '(360) 812-2613',           # Dad ipkall usa #
  '6'   => '008613375798811@powervoip',# Lu Peck Cell
  '7'   => '203@Nygames[ma=false]',    # Vijay home ext
  '7599373'   => '2508091@local',     # Test
  '203' => '203@Nygames',              # Vijay home ext
  '204' => '(213) 884-6354',           # Tangir Alam
  '444' => 'ecuador@local',              # Ecuador ext
  '266' => 'Bharrath@local',           # Dad home
  '269' => 'Ashtoniphone@local',           # Dad home
  '268' => 'Mellyphone@local',           # Dad home
  '253' => 'amyboodhram@local',        # Amy
  '264' => 'mmplas@local',             # office
  '263' => 'Andy_and_Melly@local',     # Home
  '265' => 'AdeshOffice@local',        # adesh
  '270' => '00115922271360@voipbusterpro',
  '273' => 'donna123@local',           # Donna Dos Santos
  '275' => '5926243120@PSTN',       # Donna Cell
  '274' => '00115926835784@powervoip',       # Ignatius cell
  '277' => '5922271360@Nygames',       # Donna Home
  '712'   => '*#2 454-1234',           # San Jose Voice Mail, dial my SJ GV using SFO GV acnt
  '713'   => '*#1 (415) 335-1234',     # San Francisco Voice Mail, dial my SFO GV using SJ GV acnt
  '714'  => '*#1 (773) 778-1234',      # San Francisco Voice Mail, dial my Chicago GV using SJ GV acnt
  '411' => '(800) 466-4411',           # Google's Directory Assistance, GOOG-411
  '200' => '303@sip.blueface.ie&612@fwd.pulver.com',
  '300' => '441923287748@Voxalot',     # BT speaking clock 
  '666' => '4153767253@podlinez.net',  # CNN Headlines (266 = "CNN")
  '677' => '8186882773@podlinez.net',  # NPR's most e-mailed stories (677 ="NPR")
  '742' => '6506441934@podlinez.net',  # Prairie Home Companion's, or PHC's
                                       # News from Lake Wobegon (742 = "PHC")
  '932' => '7755333366',               # Columbus OH-based national weather (932 = "WEA[ther]")
}

# CNAM table: number in ENUM format => caller's name

CNAM = {
'(212) 555-1212' => 'Dear mom',
'(240) 418-3987' => 'Aunty Tina',
'(718) 908-2828' => 'Ali infinity',
'(718) 656-1001' => 'Michelle Gomez Work',
'(443) 850-7625' => 'Aunty Ann Aponte',
'(864) 502-8863' => 'Daddy',
'(347) 857-9902' => 'Aunty Donna Guyana',
'(347) 441-0605' => 'Amy and Richard',
'(347) 561-4880' => 'Michelle Gomez Home',
'(443) 739-9497' => 'Diana Pinky Ramlal cell',
'(315) 895-1479' => 'Hey people Wake Up it is Six AM',
'(646) 573-2819' => 'Michelle Gomez Cell',
'(718) 502-8863' => 'Andy and Melly',
'(718) 879-8933' => 'Vijay Home', 
'(347) 210-6631' => 'Vijay Cell',
'(917) 443-2170' => 'Nishal Ramnarine',
'(754) 245-3916' => 'Rachael Diaz',
'(213) 884-6354' => 'Tangir Alam',
'(215) 333-2211' => 'Bratty kid',
}

# Uncomment next line and insert your White Pages API key, if you have it
# WP_key = '702f53d569ee0374b4b1dafa62fe72fc'     # White Pages API key

# Uncomment line below to enable misdialing safeguards
# EnableSafeguards = 1

# Excluded Prefixes. Provides a safeguard against accidentally calling premium numbers

ExcludedPrefixes = [
   ' 1 (900 | 809)',               # USA Premium
   ' 1 \d\d\d 555 1212',           # USA Directory assistance
   '44 (9 | 55 | 70 | 84 | 87)',   # UK Premium
   '49 (1 [^567] | 900)',          # Germany Premium
   '39 (1 | 84 | 89)',             # Italy Premium
   '420 90',                       # Czech Premium
   '32 (70 | 90\d)',               # Belgium Premium
]

# Yet another safeguard, list of blessed country codes

Allowed_Country = %w{
1 33 36 37[0-2] 380 39 41 420 44 49 61 7 86 883 886 90 972 998
}

# My own ENUM database

MyENUM = {
'+1 (408) 334-1234' => 'brother@local', # Brother George
}

# Enum database list

EnumDB = [
  MyENUM,                             # look in MyENUM first
'e164.org',
'e164.info',
'e164.arpa',
'e164.televolution.net',
'enum.org',
]

# Serviced domains, must be in lowercase!

Domains  = ['sipsorcery.com','sip.sipsorcery.com','sip1.sipsorcery.com','sip2.sipsorcery.com','69.59.142.213']
Host     = 'sipsorcery.com'        # Replaces "host" on incoming calls

# Google Voice accounts

GoogleVoice   = GV.new  '#2', nil, 'Google Voice', :usr => 'sssssssss', :pwd => 'sssssssss',
                                                   :cb => '(305) 760-4525', :match => '7185028863'

Voipstunt     = VSP.new '#3', '00 ${EXTEN}@Voxalot', 'Voipstunt'
Nygames       = VSP.new '#4', '01 ${EXTEN}@Voxalot', 'Voipstunt'

PSTN          = VSP.new '#1', '${EXTEN:1}@pstn', 'SPA3102 at home'

   
# ********************  s e l e c t   V S P  *******************************

def selectVSP # VoIP provider selection

case @num
when /(^1([2-9]\d\d)[2-9]\d{6})/ # North America
@num = $1 # Truncate to 11 digits
case $2 # check area code
when "868" # Trinidad
route_to PSTN, "Trinidad & Tobago"
else
route_to GoogleVoice, 'USA/Can' # all other destinations within US & Canada
end

when /^592\d{7}$/ # Guyana
route_to PSTN, "Guyana"

when /^86/ # China
route_to PowerVOIP, 'China'

when /^\*/ # For *500, *600 and other Voxalot services
route_to Voxalot, "Voxalot Services", nil

else
rejectCall(603,"Number's too short, check & dial again") if @num.length < 9
route_to Voipstunt
end
end

# ------------ O P T I O N A L   C O N F I G U R A T I O N --------------- #

# ********************  i n c o m i n g   C a l l  *************************

def incomingCall
  sys.SetFromHeader(formatNum(@cname || @cid,true), nil, Host)  # Set FromName & FromHost for sys.Dial

  # Forward call to the bindings (ATA / softphone)
  # Change FromURI when forwarding to @local, or else Bria won't find contact in its phonebook!

  callswitch("#{@user}@local[fu=#{@cid}]",45) unless (2230..2231) === @t.hour*100 + @t.min # reject incoming calls from 10:30p to 10:31p

  @code, @reason = 480, "#{@user} is asleep" unless @code # if nothing else, must be the night hour
  @code = 486 if @trunk =~ /IPCOMM/i ## *** temporary fix for IPCOMMS ***
end

# **************************  t o   E N U M  *******************************

def to_ENUM num
  num.gsub!(/[^0-9*+]/,'') # Delete all fancy chars (only digits, '+' and '*' allowed)

  # Check if the number begins with one of international prefixes:
  #  '+' - international format
  #   00 - European style international prefix (00)
  #  011 - US style international prefix (011)

  num =~ /^(\+|00|011)/ and return $' # if yes, remove prefix and return

  case num                    # Special cases
    when /^[2-9]\d{6}$/       # Local call, 7-digit number
      '1' + Area + num        # prefix it with country and area code
    when /^[01]?([2-9]\d{9})/ # US number with or without "1" country code
      '1' + $1                # add country code and truncate number to 10-digit
    when /^\*/                # Voxalot voicemail, echotest & other special numbers
      num                     # ... as is
    else
      rejectCall(603,"Wrong number: '#{num}', check & dial again")
  end
end

# ****** E N D   O F   C O N F I G U R A T I O N    S E C T I O N ******** #

# **************************  C A L L    S W I T C H  **********************

def callswitch(num,*args)
  @timeout = args[0]
  num.gsub!(/%([0-9A-F]{2})/) {$1.to_i(16).chr} # Convert %hh into ASCII
  @num = Speeddial[num] || num  # If there is speed dial entry for it...

  if @num =~ /@/              # If we already have URI, just dial and return
    sys.Log("URI dialing: #@num")
    dial(@num,*args)
  else                        # Not URI
    rexp = VSP.tab.keys.sort {|a,b| b.length <=> a.length}.map {|x| Regexp.escape(x)}.join('|')
    if @num =~ /^(#{rexp})/   # If number starts with VSP selection prefix
      @num = $'; @forcedRoute = VSP.tab[$1]
      @noSafeGuards = (@forcedRoute.fmt =~ /Disable\s*Safe\s*Guards/i)
    end

    @num = to_ENUM(@num)      # Convert to ENUM

    rejectCall(503,"Number's empty") if @num.empty?
    sys.Log("Number in ENUM format: #{@num}")
    if @forcedRoute && !@noSafeGuards
      route_to @forcedRoute, "Forced routing!", false # if forced with prefix, skip ENUM, safeguards & VSP selection
    else
      checkNum if defined?(EnableSafeguards) && !@noSafeGuards
      selectVSP               # Pick appropriate provider for the call
    end
  end   # URI
end

# ***************************  R O U T E _ T O  ****************************

def route_to vsp, dest=nil, enum = EnumDB
  enum.to_a.each do |db|   # if enum enabled, look in all enum databases
    if uri = (db.class == Hash)? db[@num] : sys.ENUMLookup("#{@num}.#{db}")
      sys.Log("ENUM entry found: '#{uri}' in #{db.class == Hash ? 'local' : db} database")
      dial(uri)
    end
  end                   # ENUM not found or failed, call via regular VSP

  return unless vsp     # No VSP - do nothing

  uri = vsp.fmt.gsub(/\s+/,'').gsub(/\$\{EXTEN(:([^:}]+)(:([^}]+))?)?\}/) {@num[$2.to_i,$4? $4.to_i : 100]}
  dest &&= " (#{dest})"; with = vsp.name; with &&= " with #{with}"
  sys.Log("Calling #{formatNum(@num)}#{dest}#{with}")

  if vsp.is_gv?
    vsp.repeat.times do |i|
      @code, @reason = 200, "OK"  # assume OK
      sys.GoogleVoiceCall *vsp.getparams(uri, i + (vsp.rand ? @t.to_i : 0))
      sys.Log("Google Voice Call failed!")
      @code, @reason = 603, 'Service Unavailable'
    end
  else
    vsp.repeat.times do
      dial(uri, @timeout || vsp.tmo || 300) # Dial, global time-out overrides account
    end
  end
end

# *******************************  D I A L  ********************************

def dial *args
  @code, @reason = nil
  sys.Dial *args    # dial URI
  status()          # We shouldn't be here! Get error code...
  sys.Log("Call failed: code #{@code}, #{@reason}")
end

# *****************************  S T A T U S  ******************************

def status
  begin
    @code, @reason = 487, 'Cancelled by Sipsorcery'
    sys.LastDialled.each do |ptr|
      if ptr
        ptr = ptr.TransactionFinalResponse
        @code = ptr.StatusCode; @reason = ptr.ReasonPhrase; break if @code == 200
#       sys.Log("#{ptr.ToString()}")
      end
    end
  rescue
  end
end

# ************************  r e j e c t C a l l  ***************************

def rejectCall code, reason
  @code = code; @reason = reason
  sys.Respond code, reason
end

# ****************************  C H E C K   N U M **************************

def checkNum
  return if @num.match(/^\D/)  # skip if number doesn't begin with a digit

  # Reject calls to not blessed countries and premium numbers
  # (unless VSP was forced using #n dial prefix)

  rejectCall(503,"Calls to code #{formatNum(@num).split(' ')[0]} not allowed") \
    unless @num.match "^(#{Allowed_Country.join('|')})"

  rejectCall(503,"Calls to '#{formatNum($&)}' not allowed") if @num.match \
    '^(' + ExcludedPrefixes.map { |x| "(:?#{x.gsub(/\s*/,'')})" }.join('|') + ')'
end

# **********************  k e y s   t o   E N U M  *************************

def keys_to_ENUM (table)
  Hash[*table.keys.map! {|key| to_ENUM(key.dup)}.zip(table.values).flatten]
end

# **************************  g e t T I M E  *******************************

def getTime
  Time.now + ((Tz+7)*60*60) # Get current time and adjust to local. SS Server is in GMT-8
end

# *******************************  M A I N  ********************************

begin
  sys.Log("** Call from #{req.Header.From} to #{req.URI.User} **")
  sys.ExtendScriptTimeout(15)   # preventing long running dialscript time-out
  @t = getTime()
  sys.Log(@t.strftime('Local time: %c'))
  EnumDB.map! {|x| x.class == Hash ? keys_to_ENUM(x) : x } # rebuild local ENUM table

  if sys.In               # If incoming call...
    @cid = req.Header.from.FromURI.User.to_s    # Get caller ID

    # Prepend 10-digit numbers with "1" (US country code) and remove int'l prefix (if present)

    @cid = ('1' + @cid) if @cid =~ /^[2-9]\d\d[2-9]\d{6}$/
    @cid.sub!(/^(\+|00|011)/,'')   # Remove international prefixes, if any

    prs = req.URI.User.split('.')  # parse User into chunks
    @trunk = prs[-2]               # get trunk name
    @user  = prs[-1]               # called user name

    # Check CNAM first. If not found and US number, try to lookup caller's name in Whitepages

    if !(@cname = keys_to_ENUM(CNAM)[@cid]) && @cid =~ /^1([2-9]\d\d[2-9]\d{6})$/ && defined?(WP_key)
      url = "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20xml%20where%20url%3D'http%3A%2F%2Fapi.whitepages.com%2Freverse_phone%2F1.0%2F%3Fphone%3D#{$1}%3Bapi_key%3D#{WP_key}'%20and%20itemPath%3D'wp.listings.listing'&format=json"
      if js = sys.WebGet(url,4).to_s
        @cname, dname, city, state = %w(businessname displayname city state).map {|x| js =~ /"#{x}":"([^"]+)"/; $1}
        @cname ||= dname; @cname ||= "#{city}, #{state}" if city && state
      end
    end

    sys.Log("Caller's number: '#{@cid}'"); sys.Log("Caller's name:   '#{@cname}'") if @cname
    incomingCall()        # forward incoming call

  else                    # Outbound call ...

    # check if it's URI or phone number.
    # If destination's host is in our domain, it's a phone call

    num = req.URI.User.to_s; reqHost = req.URI.Host.to_s  # Get User and Host
    host = reqHost.downcase.slice(/[^:]+/)                # Convert to lowercase and delete optional ":port"
    num << '@' << reqHost unless Domains.include?(host)   # URI dialing unless host is in our domain list

    callswitch(num)

  end
  sys.Respond(@code,@reason) # Forward error code to ATA
rescue
   # Gives a lot more details at what went wrong (borrowed from Myatus' dialplan)
   sys.Log("** Error: " + $!) unless $!.to_s =~ /Thread was being aborted./
end

MikeTelis
Posts: 1582
Joined: Wed Jul 30, 2008 6:48 am

Re: Help with a Guyana Dial Plan

Post by MikeTelis » Tue Oct 18, 2011 6:06 pm

Once again, you can get rid of extra digits by using either EXTEN:n in the VSP descriptor, or SPA3102's dial plan.

arampe
Posts: 70
Joined: Mon Nov 15, 2010 11:38 pm

Re: Help with a Guyana Dial Plan

Post by arampe » Thu Jan 19, 2012 3:49 pm

Mike I broke something please help again ....


Dial plan first..

Code: Select all

# Copyright 2010 Mike Telis
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.

require 'mikesgem'

# ************* C O N F I G U R A T I O N    S E C T I O N *************** #

Area = '868'          # my area code, this will be added to 7-digit dialouts
Tz   = -3             # my time zone (GMT format, e.g. Eastern = -5, Central = -6)

# Speed dial entries. Format: "key" => "number"

Speeddial = {
  
  '1'   => '(347) 561-4880',           # Michelle home
  '2'   => '(646) 573-2819',           # Michelle Cell
  '3'   => '(347) 210-6631',           # Vijay Cell
  '4'   => '(443) 636-7891',           # Paro Cell
  '5'   => '(360) 812-2613',           # Dad ipkall usa #
  '6'   => '008613375798811@powervoip',# Lu Peck Cell
  '7'   => '203@Nygames[ma=false]',    # Vijay home ext
  '7599373'   => '2508091@local',     # Test
  '203' => '203@Nygames[ma=false]',              # Vijay home ext
  '444' => 'ecuador@local[ma=false]',              # Ecuador ext
  '266' => 'Bharrath@local[ma=false]',           # Dad home
  '269' => 'Ashtoniphone@local[ma=false]',           # Dad home
  '268' => 'Mellyphone@local',           # Dad home
  '253' => 'amyboodhram@local',        # Amy
  '264' => 'mmplas@local',             # office
  '263' => 'Andy_and_Melly@local[ma=false]',     # Home
  '265' => 'AdeshOffice@local[ma=false]',        # adesh
  '270' => '00115922271360@voipbusterpro',
  '273' => 'donna123@local[ma=false]',           # Donna Dos Santos
  '275' => '5926243120@Voxalot',       # Donna Cell
  '274' => '00115926835784@powervoip',       # Ignatius cell
  '277' => '5922271360@Nygames',       # Donna Home
  '712'   => '*#2 454-1234',           # San Jose Voice Mail, dial my SJ GV using SFO GV acnt
  '713'   => '*#1 (415) 335-1234',     # San Francisco Voice Mail, dial my SFO GV using SJ GV acnt
  '714'  => '*#1 (773) 778-1234',      # San Francisco Voice Mail, dial my Chicago GV using SJ GV acnt
  '411' => '(800) 466-4411',           # Google's Directory Assistance, GOOG-411
  '200' => '303@sip.blueface.ie&612@fwd.pulver.com',
  '300' => '441923287748@Voxalot',     # BT speaking clock 
  '666' => '4153767253@podlinez.net',  # CNN Headlines (266 = "CNN")
  '677' => '8186882773@podlinez.net',  # NPR's most e-mailed stories (677 ="NPR")
  '742' => '6506441934@podlinez.net',  # Prairie Home Companion's, or PHC's
                                       # News from Lake Wobegon (742 = "PHC")
  '932' => '7755333366',               # Columbus OH-based national weather (932 = "WEA[ther]")
}


# CNAM table: number in ENUM format => caller's name

CNAM = {
'(212) 555-1212' => 'Dear mom',
'(240) 418-3987' => 'Aunty Tina',
'(718) 908-2828' => 'Ali infinity',
'(718) 656-1001' => 'Michelle Work',
'(443) 850-7625' => 'Aunty Ann Aponte',
'(864) 502-8863' => 'Daddy',
'(347) 857-9902' => 'Aunty Donna Guyana',
'(347) 441-0605' => 'Amy and Richard',
'(347) 561-4880' => 'Michelle Gomez Home',
'(443) 739-9497' => 'Diana Pinky Ramlal cell',
'(315) 895-1479' => 'Rooster Wake Up',
'(646) 573-2819' => 'Michelle Gomez Cell',
'(718) 502-8863' => 'Andy and Melly',
'(718) 879-8933' => 'Vijay Home', 
'(347) 210-6631' => 'Vijay Cell',
'(917) 443-2170' => 'Nishal Ramnarine',
'(754) 245-3916' => 'Rachael Diaz',
'(213) 884-6354' => 'Tangir Alam',
'(215) 333-2211' => 'Bratty kid',
}

# Uncomment next line and insert your White Pages API key, if you have it
# WP_key = '702f53d569eee72fc'     # White Pages API key

# Uncomment line below to enable misdialing safeguards
# EnableSafeguards = 1

# Excluded Prefixes. Provides a safeguard against accidentally calling premium numbers

ExcludedPrefixes = [
   ' 1 (900 | 809)',               # USA Premium
   ' 1 \d\d\d 555 1212',           # USA Directory assistance
   '44 (9 | 55 | 70 | 84 | 87)',   # UK Premium
   '49 (1 [^567] | 900)',          # Germany Premium
   '39 (1 | 84 | 89)',             # Italy Premium
   '420 90',                       # Czech Premium
   '32 (70 | 90\d)',               # Belgium Premium
]

# Yet another safeguard, list of blessed country codes

Allowed_Country = %w{
1 33 36 37[0-2] 380 39 41 420 44 49 61 7 86 883 886 90 972 998
}

# My own ENUM database

MyENUM = {
'+1 (408) 334-1234' => 'brother@local', # Brother George
}

# Enum database list

EnumDB = [
  MyENUM,                             # look in MyENUM first
'e164.org',
'e164.info',
'e164.arpa',
'e164.televolution.net',
'enum.org',
]

# Serviced domains, must be in lowercase!

Domains  = ['sipsorcery.com','sip.sipsorcery.com','sip1.sipsorcery.com','sip2.sipsorcery.com','69.59.142.213']
Host     = 'sipsorcery.com'        # Replaces "host" on incoming calls

# Google Voice accounts

GoogleVoice   = GV.new  '#1', nil, 'Google Voice', :usr => '000000', :pwd => '000000000',
                                                   :cb => '(305) 760-4000', :match => '7180008863'

PSTN          = VSP.new '#2', '${EXTEN:1}@pstn', 'SPA3102 at home'
Voipstunt     = VSP.new '#3', '00 ${EXTEN}@smartvoip', 'Smartvoip'
nygames       = VSP.new '#4', '01 ${dst:6}@nygames', 'Guyana'
   
# ********************  s e l e c t   V S P  *******************************

def selectVSP # VoIP provider selection

case @num
when /(^1([2-9]\d\d)[2-9]\d{6})/ # North America
@num = $1 # Truncate to 11 digits
case $2 # check area code
when "868" # Trinidad
route_to PSTN, "Trinidad & Tobago"
else
route_to GoogleVoice, 'USA/Can' # all other destinations within US & Canada
end

when /^592\d{7}$/ # Guyana
route_to nygames, "Guyana"

when /^86/ # China
route_to PowerVOIP, 'China'

when /^\*/ # For *500, *600 and other Voxalot services
route_to Voxalot, "Voxalot Services", nil

else
rejectCall(603,"Number's too short, check & dial again") if @num.length < 9
route_to Voipstunt
end
end


# ------------ O P T I O N A L   C O N F I G U R A T I O N --------------- #

# ********************  i n c o m i n g   C a l l  *************************

def incomingCall
  sys.SetFromHeader(formatNum(@cname || @cid,true), nil, Host)  # Set FromName & FromHost for sys.Dial

  # Forward call to the bindings (ATA / softphone)
  # Change FromURI when forwarding to @local, or else Bria won't find contact in its phonebook!

  callswitch("#{@user}@local[fu=#{@cid}]",45) unless (2330..2231) === @t.hour*100 + @t.min # reject incoming calls from 11:30p to 11:31p

  @code, @reason = 480, "#{@user} is asleep" unless @code # if nothing else, must be the night hour
  @code = 486 if @trunk =~ /IPCOMM/i ## *** temporary fix for IPCOMMS ***
end

# **************************  t o   E N U M  *******************************

def to_ENUM num
  num.gsub!(/[^0-9*+]/,'') # Delete all fancy chars (only digits, '+' and '*' allowed)

  # Check if the number begins with one of international prefixes:
  #  '+' - international format
  #   00 - European style international prefix (00)
  #  011 - US style international prefix (011)

  num =~ /^(\+|00|011)/ and return $' # if yes, remove prefix and return

  case num                    # Special cases
    when /^[2-9]\d{6}$/       # Local call, 7-digit number
      '1' + Area + num        # prefix it with country and area code
    when /^[01]?([2-9]\d{9})/ # US number with or without "1" country code
      '1' + $1                # add country code and truncate number to 10-digit
    when /^\*/                # Voxalot voicemail, echotest & other special numbers
      num                     # ... as is
    else
      rejectCall(603,"Wrong number: '#{num}', check & dial again")
  end
end

# ****** E N D   O F   C O N F I G U R A T I O N    S E C T I O N ******** #

# **************************  C A L L    S W I T C H  **********************

def callswitch(num,*args)
  @timeout = args[0]
  num.gsub!(/%([0-9A-F]{2})/) {$1.to_i(16).chr} # Convert %hh into ASCII
  @num = Speeddial[num] || num  # If there is speed dial entry for it...

  if @num =~ /@/              # If we already have URI, just dial and return
    sys.Log("URI dialing: #@num")
    dial(@num,*args)
  else                        # Not URI
    rexp = VSP.tab.keys.sort {|a,b| b.length <=> a.length}.map {|x| Regexp.escape(x)}.join('|')
    if @num =~ /^(#{rexp})/   # If number starts with VSP selection prefix
      @num = $'; @forcedRoute = VSP.tab[$1]
      @noSafeGuards = (@forcedRoute.fmt =~ /Disable\s*Safe\s*Guards/i)
    end

    @num = to_ENUM(@num)      # Convert to ENUM

    rejectCall(503,"Number's empty") if @num.empty?
    sys.Log("Number in ENUM format: #{@num}")
    if @forcedRoute && !@noSafeGuards
      route_to @forcedRoute, "Forced routing!", false # if forced with prefix, skip ENUM, safeguards & VSP selection
    else
      checkNum if defined?(EnableSafeguards) && !@noSafeGuards
      selectVSP               # Pick appropriate provider for the call
    end
  end   # URI
end

# ***************************  R O U T E _ T O  ****************************

def route_to vsp, dest=nil, enum = EnumDB
  enum.to_a.each do |db|   # if enum enabled, look in all enum databases
    if uri = (db.class == Hash)? db[@num] : sys.ENUMLookup("#{@num}.#{db}")
      sys.Log("ENUM entry found: '#{uri}' in #{db.class == Hash ? 'local' : db} database")
      dial(uri)
    end
  end                   # ENUM not found or failed, call via regular VSP

  return unless vsp     # No VSP - do nothing

  uri = vsp.fmt.gsub(/\s+/,'').gsub(/\$\{EXTEN(:([^:}]+)(:([^}]+))?)?\}/) {@num[$2.to_i,$4? $4.to_i : 100]}
  dest &&= " (#{dest})"; with = vsp.name; with &&= " with #{with}"
  sys.Log("Calling #{formatNum(@num)}#{dest}#{with}")

  if vsp.is_gv?
    vsp.repeat.times do |i|
      @code, @reason = 200, "OK"  # assume OK
      sys.GoogleVoiceCall *vsp.getparams(uri, i + (vsp.rand ? @t.to_i : 0))
      sys.Log("Google Voice Call failed!")
      @code, @reason = 603, 'Service Unavailable'
    end
  else
    vsp.repeat.times do
      dial(uri, @timeout || vsp.tmo || 300) # Dial, global time-out overrides account
    end
  end
end

# *******************************  D I A L  ********************************

def dial *args
  @code, @reason = nil
  sys.Dial *args    # dial URI
  status()          # We shouldn't be here! Get error code...
  sys.Log("Call failed: code #{@code}, #{@reason}")
end

# *****************************  S T A T U S  ******************************

def status
  begin
    @code, @reason = 487, 'Cancelled by Sipsorcery'
    sys.LastDialled.each do |ptr|
      if ptr
        ptr = ptr.TransactionFinalResponse
        @code = ptr.StatusCode; @reason = ptr.ReasonPhrase; break if @code == 200
#       sys.Log("#{ptr.ToString()}")
      end
    end
  rescue
  end
end

# ************************  r e j e c t C a l l  ***************************

def rejectCall code, reason
  @code = code; @reason = reason
  sys.Respond code, reason
end

# ****************************  C H E C K   N U M **************************

def checkNum
  return if @num.match(/^\D/)  # skip if number doesn't begin with a digit

  # Reject calls to not blessed countries and premium numbers
  # (unless VSP was forced using #n dial prefix)

  rejectCall(503,"Calls to code #{formatNum(@num).split(' ')[0]} not allowed") \
    unless @num.match "^(#{Allowed_Country.join('|')})"

  rejectCall(503,"Calls to '#{formatNum($&)}' not allowed") if @num.match \
    '^(' + ExcludedPrefixes.map { |x| "(:?#{x.gsub(/\s*/,'')})" }.join('|') + ')'
end

# **********************  k e y s   t o   E N U M  *************************

def keys_to_ENUM (table)
  Hash[*table.keys.map! {|key| to_ENUM(key.dup)}.zip(table.values).flatten]
end

# **************************  g e t T I M E  *******************************

def getTime
  Time.now + ((Tz+7)*60*60) # Get current time and adjust to local. SS Server is in GMT-8
end

# *******************************  M A I N  ********************************

begin
  sys.Log("** Call from #{req.Header.From} to #{req.URI.User} **")
  sys.ExtendScriptTimeout(15)   # preventing long running dialscript time-out
  @t = getTime()
  sys.Log(@t.strftime('Local time: %c'))
  EnumDB.map! {|x| x.class == Hash ? keys_to_ENUM(x) : x } # rebuild local ENUM table

  if sys.In               # If incoming call...
    @cid = req.Header.from.FromURI.User.to_s    # Get caller ID

    # Prepend 10-digit numbers with "1" (US country code) and remove int'l prefix (if present)

    @cid = ('1' + @cid) if @cid =~ /^[2-9]\d\d[2-9]\d{6}$/
    @cid.sub!(/^(\+|00|011)/,'')   # Remove international prefixes, if any

    prs = req.URI.User.split('.')  # parse User into chunks
    @trunk = prs[-2]               # get trunk name
    @user  = prs[-1]               # called user name

    # Check CNAM first. If not found and US number, try to lookup caller's name in Whitepages

    if !(@cname = keys_to_ENUM(CNAM)[@cid]) && @cid =~ /^1([2-9]\d\d[2-9]\d{6})$/ && defined?(WP_key)
      url = "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20xml%20where%20url%3D'http%3A%2F%2Fapi.whitepages.com%2Freverse_phone%2F1.0%2F%3Fphone%3D#{$1}%3Bapi_key%3D#{WP_key}'%20and%20itemPath%3D'wp.listings.listing'&format=json"
      if js = sys.WebGet(url,4).to_s
        @cname, dname, city, state = %w(businessname displayname city state).map {|x| js =~ /"#{x}":"([^"]+)"/; $1}
        @cname ||= dname; @cname ||= "#{city}, #{state}" if city && state
      end
    end

    sys.Log("Caller's number: '#{@cid}'"); sys.Log("Caller's name:   '#{@cname}'") if @cname
    incomingCall()        # forward incoming call

  else                    # Outbound call ...

    # check if it's URI or phone number.
    # If destination's host is in our domain, it's a phone call

    num = req.URI.User.to_s; reqHost = req.URI.Host.to_s  # Get User and Host
    host = reqHost.downcase.slice(/[^:]+/)                # Convert to lowercase and delete optional ":port"
    num << '@' << reqHost unless Domains.include?(host)   # URI dialing unless host is in our domain list

    callswitch(num)

  end
  sys.Respond(@code,@reason) # Forward error code to ATA
rescue
   # Gives a lot more details at what went wrong (borrowed from Myatus' dialplan)
   sys.Log("** Error: " + $!) unless $!.to_s =~ /Thread was being aborted./
end



error when dialing Guyana.

Code: Select all

NATKeepAlive 15:44:13:578 sip1(52724): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.83.139.2:5062.
NATKeepAlive 15:44:13:578 sip1(52724): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.83.188.3:5060.
NATKeepAlive 15:44:13:594 sip1(52724): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:212.150.136.3:51947.
DialPlan 15:44:20:969 sip1(86984): New call from udp:190.83.139.2:5062 successfully authenticated by digest.
DialPlan 15:44:20:984 sip1(86984): Using dialplan 250809 for Out call to sip:0115922271360@sipsorcery.com.
NewCall 15:44:21:000 sip1(86984): Executing script dial plan for call to 0115922271360.
DialPlan 15:44:21:063 sip1(86984): ** Call from "mmplas" <sip:mmplas@sipsorcery.com>;tag=228ffe29940ca356o0 to 0115922271360 **
DialPlan 15:44:21:063 sip1(86984): Local time: 01/19/2012 14:44
DialPlan 15:44:21:078 sip1(86984): Number in ENUM format: 5922271360
DialPlan 15:44:21:078 sip1(86984): ** Error: undefined method `nygames' for #<Object:0x00000b8 @t=Thu Jan 19 14:44:21 -0500 2012, @timeout=nil, @num="5922271360">
DialPlan 15:44:21:094 sip1(86984): Dialplan cleanup for 250809.
DialPlan 15:44:21:313 sip1(86984): Dial plan execution completed without answering and with no last failure status.
DialPlan 15:44:21:313 sip1(86984): UAS call failed with a response status of 480.
NATKeepAlive 15:44:23:703 sip1(52724): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.83.139.2:5062.
NATKeepAlive 15:44:23:703 sip1(52724): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.83.188.3:5060.
NATKeepAlive 15:44:23:719 sip1(52724): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:212.150.136.3:51947.
NATKeepAlive 15:44:33:813 sip1(52724): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.83.139.2:5062.
NATKeepAlive 15:44:33:813 sip1(52724): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.83.188.3:5060.
NATKeepAlive 15:44:33:829 sip1(52724): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:212.150.136.3:51947.
Attachments
Service Providers.PNG
Service Providers.PNG (108.67 KiB) Viewed 3434 times

MikeTelis
Posts: 1582
Joined: Wed Jul 30, 2008 6:48 am

Re: Help with a Guyana Dial Plan

Post by MikeTelis » Thu Jan 19, 2012 3:57 pm

At a glance, the problem is here:

nygames = VSP.new '#4', '01 ${dst:6}@nygames', 'Guyana'

Should be:

nygames = VSP.new '#4', '01 ${EXTEN:6}@nygames', 'Guyana'

arampe
Posts: 70
Joined: Mon Nov 15, 2010 11:38 pm

Re: Help with a Guyana Dial Plan

Post by arampe » Thu Jan 19, 2012 4:01 pm

Thank You MIke,

but still not fixed...

Code: Select all

2.213:5060 to udp:190.83.188.3:5060.
NATKeepAlive 16:00:05:046 sip1(52724): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:212.150.129.70:16143.
NATKeepAlive 16:00:10:109 sip1(52724): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.83.139.2:5062.
NATKeepAlive 16:00:10:109 sip1(52724): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.83.188.3:5060.
DialPlan 16:00:13:609 sip1(76436): New call from udp:190.83.139.2:5062 successfully authenticated by digest.
DialPlan 16:00:13:624 sip1(76436): Using dialplan 250809 for Out call to sip:0115922271360@sipsorcery.com.
NewCall 16:00:13:624 sip1(76436): Executing script dial plan for call to 0115922271360.
DialPlan 16:00:13:687 sip1(76436): ** Call from "mmplas" <sip:mmplas@sipsorcery.com>;tag=5ac62b6e7045c2fao0 to 0115922271360 **
DialPlan 16:00:13:703 sip1(76436): Local time: 01/19/2012 12:00
DialPlan 16:00:13:703 sip1(76436): Number in ENUM format: 5922271360
DialPlan 16:00:13:718 sip1(76436): ** Error: undefined method `nygames' for #<Object:0x00000c4 @t=Thu Jan 19 12:00:13 -0800 2012, @timeout=nil, @num="5922271360">
DialPlan 16:00:13:734 sip1(76436): Dialplan cleanup for 250809.
DialPlan 16:00:13:937 sip1(76436): Dial plan execution completed without answering and with no last failure status.
DialPlan 16:00:13:937 sip1(76436): UAS call failed with a response status of 480.
NATKeepAlive 16:00:15:171 sip1(52724): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:212.150.129.70:16143.
NATKeepAlive 16:00:20:218 sip1(52724): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.83.139.2:5062.
NATKeepAlive 16:00:20:218 sip1(52724): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.83.188.3:5060.
NATKeepAlive 16:00:25:281 sip1(52724): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:212.150.129.70:16143.
NATKeepAlive 16:00:30:344 sip1(52724): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.83.139.2:5062.
NATKeepAlive 16:00:30:344 sip1(52724): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:190.83.188.3:5060.

MikeTelis
Posts: 1582
Joined: Wed Jul 30, 2008 6:48 am

Re: Help with a Guyana Dial Plan

Post by MikeTelis » Thu Jan 19, 2012 4:17 pm

Oh, one more thing: nygames is not a constant! Constant names must begin with capital letter. That is, replace:

Nygames = VSP.new '#4', '01 ${EXTEN:6}@nygames', 'Guyana'

and

route_to Nygames, "Guyana"

Note capital N.

arampe
Posts: 70
Joined: Mon Nov 15, 2010 11:38 pm

Re: Help with a Guyana Dial Plan

Post by arampe » Thu Jan 19, 2012 5:08 pm

Thank you ...u r the man !

Post Reply