0 evaluări0% au considerat acest document util (0 voturi)
282 vizualizări4 pagini
The document contains speed dial entries mapping phone numbers to SIP addresses for making calls. It defines functions for normalizing phone numbers into E.164 format and performing ENUM lookups to find SIP addresses. It also contains logic for routing calls through different providers based on number patterns, including blocking certain high cost numbers.
The document contains speed dial entries mapping phone numbers to SIP addresses for making calls. It defines functions for normalizing phone numbers into E.164 format and performing ENUM lookups to find SIP addresses. It also contains logic for routing calls through different providers based on number patterns, including blocking certain high cost numbers.
Drepturi de autor:
Attribution Non-Commercial (BY-NC)
Formate disponibile
Descărcați ca TXT, PDF, TXT sau citiți online pe Scribd
The document contains speed dial entries mapping phone numbers to SIP addresses for making calls. It defines functions for normalizing phone numbers into E.164 format and performing ENUM lookups to find SIP addresses. It also contains logic for routing calls through different providers based on number patterns, including blocking certain high cost numbers.
Drepturi de autor:
Attribution Non-Commercial (BY-NC)
Formate disponibile
Descărcați ca TXT, PDF, TXT sau citiți online pe Scribd
sys.SetFromHeader("#{req.Header.From.FromName}", nil, nil) # Set Display Na
me from phone in CallerID # **************************************** # >> ptel << is the name I used in my SIP Provider settings for calls to fix ed phones and mobiles. #***************************************** SPEED_DIAL = [ # SPEED DIAL Entries with 01 or 02 etc.. dialled number #***************************************** ' 01 ' , ' buddy1@sipsorcery.com ' , # dial buddy1 on sips orcery ' 02 ' , ' buddy2@iptel.org ' , # buddy2 on iptel.org ' 03 ' , ' 02 87654321 ' , # speed dial 02 8765 4321 phone number with pennytel account # Radio Podcasts on phone, use (*) to skip forward and (#) back in 1 minute jumps. ' 30 ' , ' 5595534621@podlinez.net ' , # Dr Karl on triplej ' 31 ' , ' 6414539840@podlinez.net ' , # ABC NewsRadio Senat e Question Time ' 32 ' , ' 6414539852@podlinez.net ' , # ABC NewsRadio House of Representatives Question Time ' 33 ' , ' 6414530997@podlinez.net ' , # All in the Mind ' 34 ' , ' 6414531005@podlinez.net ' , # Radio National, The Science Show ' 35 ' , ' 6414531002@podlinez.net ' , # Innovations www.rad ioaustralia.net.au ' 36 ' , ' 6414531004@podlinez.net ' , # StarStuff takes us on a weekly journey across the universe ' 37 ' , ' 4152234133@podlinez.net ' , # AM program ' 38 ' , ' 6502939113@podlinez.net ' , # PM program # This is a gizmo5 1222 dialled conference room, room number 0000000 ' 50 ' , ' 12220000000@proxy01.sipphone.com ' , # # Try these test numbers on speed dial ' 97 ' , ' 1234 @ loligo.com ' , # ' 98 ' , ' 904@mouselike.org ' , # ' 99 ' , ' +1800 555 8355 ' , # USA +1800 are free calls on Enum Lookup '100 ' , ' 6502939113@podlinez.net ' , # # Send these small numbers to MyNetFone '151 ' , ' @mynet ' , # MyNetFone acc balan ce '121 ' , ' @ mynet ' , # MyNetFone voicemail # Send these small numbers to pennytel '771 ' , ' @ ptel ' , # ptel acc balance '778 ' , ' @ptel ' , # ptel voicemail '*500 ' , ' @voxalot ' , # voxalot voicemail ' 131314 ' , ' (03) 9683 9999 ' , # ANZ BANK 131314 to 03 9683 9999 cheaper number ] # **************************************** # The following section is to define functions to be used later in the plan such as # How to do an Enum lookup. # **************************************** # International Enum database list from sipbroker EnumSuffix = %w[ e164.arpa e164.org e164.info e164.televolution.net enum.o rg nrenum.net ] # Only these likely for local numbers for faster lookup EnumSuffix2 = %w[ e164.org e164.arpa ] def E164num(nume164) # turn number into full international E164 format. # this section uses (61)australia country code and ( 0011)international prefix if nume164 =~ /^0011/ then nume164 = nume164[4..50] # remove international prefix (0011) 4 digit s from front of number else nume164 = "61" + nume164[1..50] if nume164 =~ /^0/ # national num ber remove leading 0 add 61 nume164 = "612" + nume164 if nume164.length == 8 # treat local number 8 digits as NSW number add 612 nume164 = "61" + nume164 if !(nume164 =~ /^61/) # add 61 to re maining australian numbers EnumSuffix = EnumSuffix2 # Use local Enum database list only end sys.Log("Number in Enum E164 format +#{nume164}") return nume164 end # ENUM lookup of number for possible sip address def EnumCall(num) nume164 = E164num(num) # first turn number into full international e164 f ormat using above rules for your country. sys.Log("Entering enumCall") EnumSuffix.each do |suffix| # check each Enum dat abase sys.Log("Searching #{suffix} for #{nume164}") # log Enum check if enumuri = sys.ENUMLookup("#{nume164}.#{suffix}") # if true dial retur ned sip sys.Log("Attempting call to #{enumuri}") sys.Dial("#{enumuri}") # dialling returned sip address sys.Log("Failed to call #{enumuri}") end end end # **************************************** SPEED_DIAL.map!{ |SDnum| SDnum.to_s.strip} # remove spacing around Spee d-dial entries. SD = Hash[*SPEED_DIAL] num = SD[req.URI.User.to_s] || req.URI.User.to_s # Get dialled numbe r Substitute with speed dial entry, if any num = num.gsub(/\ /,'') # delete all spaces. case num when /^@/ then sys.Dial("#{req.URI.User}#{num}") # Dial number to selected @provider in SPEED_DIAL when /@/ then sys.Dial(num) # Dial if sip: address from SPEED_DIAL when /%40/ then sys.Dial("#{req.URI.User.to_s.gsub(/%(..)/){$1.hex.chr} }[rm=a]") # (user%40host@sipsorcery.com) to (user@host) # Select dialout provider with 1* 2* etc.. in front of number, ${dst:2} wi ll remove the 1* prefix when /^1\*/ then sys.Dial("${dst:2}@ptel") # dial (1*number) for (n umber@ptel). when /^2\*/ then sys.Dial("${dst:2}@mynet") # dial (2*number) for ( number@mynet). # 9*+sipbroker number dialling (eg 9*234..to *234..@sipbroker.com) when /^9\*/ then sys.Dial("${dst:1}@sipbroker.com[rm=a]") # Add 0* in front of the number for sipsorcery only dial. when /^0\*/ then sys.Dial("${dst:2}@local") # 0* + number for sip sorcery.com # freenum.org style dialling eg 1234*256 for sip:1234@loligo.com when /^(\d{2,})\*(\d{2,})$/ then sys.Dial(sys.ENUMLookup("#{$1}.#{$2}.f reenum.org")) else if sys.GetCanonicalDomain(req.URI.Host.to_s) != "sipsorcery.com" sys.Log("Sip Number in #{req.URI.User}@#{req.URI.Host}") sys.Dial("#{req.URI.User}@" << "#{req.URI.Host}".downcase) # dial fu ll sip address entered sys.Respond(480, "failed sip dial.") end num = num.gsub(/[^0-9*#+]/,'') # delete all but digits on numbers. num = num.gsub(/^\+/,'0011') # replace leading + with international p refix on numbers. num = num.gsub(/\+/,'') # **************************************** # Do an Enum check on number followed by a check for a cheaper overseas provider for the number. # **************************************** # If number greater than 7 digits try an Enum check EnumCall(num) if num.length > 7 # overseas provider check case num when /^001144/ then sys.Dial("0${dst:6}@UKprovider") # dial UK provid er with local UK number # dial USA GoogleVoice with local USA number, removed 4 digit internatio nal prefix from number. when /^00111/ then sys.GoogleVoiceCall("me@gmail.com","GV_Password"," 17475551212",num[4..50],".*",7) # Gizmo5 example. end # blocked numbers case num when /^0011448/ then sys.Respond(403, "forbidden $1/min call") # bloc ked UK 448 number is $1/min end # **************************************** # If no above matches, Try dialed number or name on sipsorcery first # Then the default main provider account # **************************************** sys.Dial("#{num}@ptel") sys.Dial("#{num}@mynet") # MyNetFone if pennytel fails to complete call. end