How to give all your Friends, Family a ISN: number. Even those on a normal fixed line. ISN:<<prefix>><<num>>*<<tdsn>>
First apply for a *<<tdsn>> number on the freenum.org website.
Login into your sipsorcery account and add a new sipaccount for example
JoBoggsPBX and set it for incoming only
Goto Dial Plans and add the inplan below name it anything you like and set it as the inplan on your new sipaccount.
In the first lines of the inplan set a small prefix number you like and set myPBXacc to the name of your new sipaccount.
Also set the first line in the dialler to your local TimeZone example tz=10 is (GMT+10 hours) TimeZone.
To test the script dial this sip:address example <<prefix>><<num>>.<<myPBXacc>>@sipsorcery.com
change <<myPBXacc>> to the name of your new sipaccount eg JoBoggsPBX, and try the test number sip:
1234.JoBoggsPBX@sipsorcery.com
Once you recieve your *<<tdsn>> number goto freenum.org login page and select send me password with your email address.
Login and change the Wildcard from
Code: Select all
!^\\+*([^\\*]*)!sip:\\1@sip.big.edu!
to example
Code: Select all
!^\\+*([^\\*]*)!sip:\\1.JoBoggsPBX@sipsorcery.com!
It will stay inactive while the
state of the freenum.org entry is
NEW. Once it changes to
OK your update and *<<tdsn>> number is active.
In my case update the entry Saturday wait until late Monday afternoon for an active service.
Any further changes to the freenum.org Wildcard may take a hour or two to spread though the Domain Name system.
Happy Dialling.
Code: Select all
# dial this pattern ISN:<<prefix>><<num>>*<<tdsn>> into private number list.
prefix = '321' # Set a small common prefix on all private numbers.
myPBXacc = 'JoBoggsPBX' # Name of added sipaccount this inplan was applied to.IMPORTANT THIS IS CORRECT
status = 'no known number' # default status message
# Setup dialler with local presets eg.(GMT+10 hours)TimeZone, 7:30am opentime, 11:00pm closetime in 24 hour time.
def dialler(tocall, tz=10, starttime="0730", stoptime="2300")
t = Time.now.utc + (tz*60*60)
hhmm = t.strftime("%H%M")
openhours = stoptime < starttime ? !((stoptime...starttime) === hhmm) : (starttime...stoptime) === hhmm
if openhours
sys.log("calling #{tocall}")
status = sys.Dial(tocall)
sys.log("failed call to #{tocall}")
else
hhmm = t.strftime("%I:%M %p") # Time (HH:MM AM) format
sys.log("to late to call #{tocall}")
sys.Respond(480, "(#{hhmm}) call later") # response if middle of their night.
end
return status
end
req.URI.User.to_s =~ /^(.*)\.#{myPBXacc}/ # get dialled number in front of sipaccount name into $1
num = $1 # copy into num
fullnum = num # copy into fullnum
# pass on a CallerID from caller.
fromname = req.Header.From.FromName.to_s
fromuser = req.Header.from.FromURI.User.to_s
fromhost = req.Header.from.FromURI.Host.to_s
if fromuser =~ /^[0-9]*[0-9]$/
if fromname == "" or fromuser == fromname
sys.SetFromHeader(fromhost, fromuser, nil)
else
sys.SetFromHeader(fromname, fromuser, nil)
end
else
if fromname == ""
sys.SetFromHeader("#{fromuser} #{fromhost}", nil, nil)
else
sys.SetFromHeader(fromname, nil, nil)
end
end
# Test numbers as dialled no prefix.
case num
when '1234' then status = sys.Dial("1234@loligo.com") # John Todds screaming monkeys followed by echo test
when '12345' then status = sys.Dial("echo@iptel.org") # echo test on iptel.org
# Well Known numbers to be used directly no private prefix, use dialler for time friendly calling.
when '765765' then status = dialler("#{num}@friendssip.com",0) # know this london sip number.Use 0 TimeZone
when '890890' then status = dialler("#{num}@local") # pass this number to sipsorcery.com aus TimeZone
when /^888\d{7}$/ then status = sys.Dial("#{num}@incoming.pennytel.com")
when /^378(09\d{5,})$/
status = sys.Dial("#{$1}@mynet1[fu=09xxxxx8]") # MyNetFone line 1 09xxxxx8
status = sys.Dial("#{$1}@mynet2[fu=09xxxxx9]") # MyNetFone line 2 09xxxxx9
end
# remove prefix from front of number
prelen = prefix.length
if num[0..(prelen-1)] == prefix then
num = num[prelen..50]
# private number list with prefix removed, use dialler for time friendly calling.
case num
when '01' then status = dialler("buddy1@sipsorcery.com") # dial buddy1 in AUSTRALIA TIMEZONE on sipsorcery
when '02' then status = dialler("buddy2@iptel.org",-5) # buddy2 in NEW YORK TIMEZONE on iptel.org
when '03' then status = dialler("0287654321@ptel",10,"0800","2200") # |02 8765 4321 phone number with pennytel account
end # |no calling after 10:00pm (GMT+10) Time
end
code = 480
if status.to_s == 'Failed'
status = 'Busy Number'
code = 486
end
sys.log("#{fullnum} failed, reason #{status}")
sys.Respond(code, "#{fullnum} #{status}") # exit if invalid number