From e737a3ed97e63e411835ca7ca680111b5788b81d Mon Sep 17 00:00:00 2001 From: drowe67 Date: Tue, 12 Jan 2010 01:40:52 +0000 Subject: [PATCH] building list of Voip providers, still need to edit sip.conf based on list git-svn-id: https://svn.code.sf.net/p/freetel/code@109 01035d8c-6547-0410-b346-abe4f91aad63 --- easy-asterisk-gui/set_voiplines.pl | 12 ++++-- easy-asterisk-gui/sip.conf | 18 +++++++- easy-asterisk-gui/tooltips.html | 10 +++++ easy-asterisk-gui/voiplines.pl | 67 ++++++++++++++++++++++++++++-- easy-asterisk-gui/voiplines.sh | 6 ++- 5 files changed, 105 insertions(+), 8 deletions(-) diff --git a/easy-asterisk-gui/set_voiplines.pl b/easy-asterisk-gui/set_voiplines.pl index 880b3ba0..80575118 100755 --- a/easy-asterisk-gui/set_voiplines.pl +++ b/easy-asterisk-gui/set_voiplines.pl @@ -31,14 +31,20 @@ while () { if (/^\[/) { $next_state = "finished"; } + if (/^;.*\[/) { + $next_state = "finished"; + } - if (/user=/) { + if (/^user=/) { print "user=$user\n"; } - elsif (/secret=/) { + elsif (/^fromuser=/) { + print "fromuser=$user\n"; + } + elsif (/^secret=/) { print "secret=$pass\n"; } - elsif (/host=/) { + elsif (/^host=/) { print "host=$host\n"; } else { diff --git a/easy-asterisk-gui/sip.conf b/easy-asterisk-gui/sip.conf index 2b39f560..c315f867 100644 --- a/easy-asterisk-gui/sip.conf +++ b/easy-asterisk-gui/sip.conf @@ -533,7 +533,7 @@ allow=ulaw,g729 ; Pre-configured SIP trunks -[voip] +[voip] ; "Generic" easy-asterisk do not remove this comment type=friend context=default user=user @@ -544,3 +544,19 @@ disallow=all allow=ulaw,g729 qualify=yes +;[oeg] ; "OEG" easy-asterisk do not remove this comment +;host=voip.oeg.com.au +;secret=pass +;user=your user number +;fromdomain=voip.oeg.com.au +;fromuser=your user number +;insecure=port,invite +;type=friend +;disallow=all +;allow=g729,ulaw +;dtmfmod=rfc2833 +;qualify=yes +;canreinvite=no +;nat=yes +;context=default + diff --git a/easy-asterisk-gui/tooltips.html b/easy-asterisk-gui/tooltips.html index 6abf14a2..5ea1fabf 100644 --- a/easy-asterisk-gui/tooltips.html +++ b/easy-asterisk-gui/tooltips.html @@ -99,3 +99,13 @@ is present, or the IP phone has not been set up. +
+ A VOIP line allows you to make and receive + phones calls over the Internet. Normally a + VOIP line is provided by an Internet Telephony + Service Provider (ITSP). They will give you + an account, which includes the user and + password details that you can fill in below. + Refresh this page on your browser to see if + your VOIP line is working.
+ diff --git a/easy-asterisk-gui/voiplines.pl b/easy-asterisk-gui/voiplines.pl index bbb1ca66..feeac43e 100755 --- a/easy-asterisk-gui/voiplines.pl +++ b/easy-asterisk-gui/voiplines.pl @@ -27,14 +27,17 @@ while () { $next_state = "finished"; #print "$next_state\n"; } + if (/^;.*\[/) { # commented out next stanza + $next_state = "finished"; + } - if (/user=(.*)/) { + if (/^user=(.*)/) { $user = $1; } - if (/secret=(.*)/) { + if (/^secret=(.*)/) { $pass = $1; } - if (/host=(.*)/) { + if (/^host=(.*)/) { $host = $1; } } @@ -43,8 +46,66 @@ while () { } close SIP; +# Determine list of possible VOIP lines to use + +open SIP, "/etc/asterisk/sip.conf"; + +@voiplines=(); + +while () { + if (/^;\[.* \"(.*)\" easy-asterisk/) { + push (@voiplines, $1); + #print "$1\n"; + } + if (/^\[.* \"(.*)\" easy-asterisk/) { + push (@voiplines, $1); + $voipline_current = $1; + #print "$1\n"; + } +} +close SIP; + +# Determine if Asterisk can see our Voip Line (SIP trunk) + +my %voip = (); # SIP trunks status keyed on sip.conf names + # if no entry we can't see SIP trunk + +open SIP, "sipshowpeers.txt"; +while () { + if (/^(voip[0-9]*)[\s\/].*(OK)/) { + $voip{$1} = $2; + #print "'$1' '$2' $voip{$1}\n"; + $e = $1; + if (/\s([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\s/) { + $ipad{$e} = $1; + #print "'$1'\n"; + } + } +} + +close SIP; + # generate form fields ------------------------------------------- +print "Provider\n"; +print "\n"; + print "User:\n"; print "Password:"; print "Host:"; +if ($voip{"voip"} eq "OK") { + $icon = "\"VOIP"; +} +else { + $icon = "\"VOIP"; +} +print "Voip Line Status:$icon"; diff --git a/easy-asterisk-gui/voiplines.sh b/easy-asterisk-gui/voiplines.sh index 0bf0bcb8..dddb8bf1 100644 --- a/easy-asterisk-gui/voiplines.sh +++ b/easy-asterisk-gui/voiplines.sh @@ -15,6 +15,10 @@ if [ $? -eq 1 ]; then exit fi +# See if we have can reach the VOIP Line host + +asterisk "-rx sip show peers" 2>/dev/null > sipshowpeers.txt + # Construct the web page ------------------------------- cat <  
-

VOIP Line

+

VOIP Line

  EOF -- 2.25.1