building list of Voip providers, still need to edit sip.conf based on list
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Tue, 12 Jan 2010 01:40:52 +0000 (01:40 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Tue, 12 Jan 2010 01:40:52 +0000 (01:40 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@109 01035d8c-6547-0410-b346-abe4f91aad63

easy-asterisk-gui/set_voiplines.pl
easy-asterisk-gui/sip.conf
easy-asterisk-gui/tooltips.html
easy-asterisk-gui/voiplines.pl
easy-asterisk-gui/voiplines.sh

index 880b3ba096ef45e818e9b81d2ea3bb97ec865263..805751189b0ddf8102d26c97d93409c18a67fe15 100755 (executable)
@@ -31,14 +31,20 @@ while (<SIP>) {
        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 {
index 2b39f5604a19f401aeef87cfda6d5816444c6249..c315f8673b337d8f8a4602cfa5a5d59e33ef9a25 100644 (file)
@@ -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
+
index 6abf14a22802eee7dfa58ad517f364d30eadef77..5ea1fabf3b06bd5b956a7b5549bc13bd426bed0c 100644 (file)
                         is present, or the IP phone has not been set
                         up.</div>
 
+<div id="voiplines_voiplines" class="tip">
+                        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.  </div>
+
index bbb1ca66b55cccf59288716403e5212e56382fea..feeac43e42108014dd3f512570cc2fe55a0ea3ae 100755 (executable)
@@ -27,14 +27,17 @@ while (<SIP>) {
            $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 (<SIP>) {
 }
 close SIP;
 
+# Determine list of possible VOIP lines to use
+
+open SIP, "/etc/asterisk/sip.conf";
+
+@voiplines=();
+
+while (<SIP>) { 
+    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 (<SIP>) { 
+    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 "<tr><td>Provider</td><td>\n";
+print "<select name=\"voiplines\">\n";
+foreach (@voiplines) {
+    if ($_ eq $voipline_current) {
+       print "<option selected=\"yes\">$_</option>\n";
+    }
+    else {
+       print "<option>$_</option>\n";
+    }
+}
+print "</select></td></tr>\n";
+
 print "<tr><td>User:</td><td><input type=\"text\" name=\"user\" value=\"$user\"></td></tr>\n";
 print "<tr><td>Password:</td><td><input type=\"password\" name=\"pass\" value=\"$pass\"></td></tr>";
 print "<tr><td>Host:</td><td><input type=\"text\" name=\"host\" value=\"$host\"></td></tr>";
+if ($voip{"voip"} eq "OK") {
+    $icon = "<img src=\"tick.png\" alt=\"VOIP Line OK\" />";
+}
+else {
+    $icon = "<img src=\"cross.png\" alt=\"VOIP Line OK\" />";
+}
+print "<tr><td>Voip Line Status:</td><td>$icon</td></tr>";
index 0bf0bcb849d9f3ecec214508428a6b50a7a930b6..dddb8bf154c9eccbfd50ca51eb5a07fa1e75b659 100644 (file)
@@ -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 <<EOF
@@ -41,7 +45,7 @@ cat <<EOF
     <table align="right" width=600>
       <tr><td>&nbsp</td></tr>
       <form action="set_voiplines.sh" method="get">
-      <tr><td align="left" valign="top"><h2>VOIP Line</h2></td></tr>
+      <tr><td onMouseOver="popUp(event,'voiplines_voiplines')" onmouseout="popUp(event,'voiplines_voiplines')" align="left" valign="top"><h2>VOIP Line</h2></td></tr>
 
       <tr><td>&nbsp</td></tr>
 EOF