[svn-commits] mvanbaak: trunk r121197 - in /trunk: CHANGES apps/app_privacy.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Sun Jun 8 06:40:44 CDT 2008


Author: mvanbaak
Date: Sun Jun  8 06:40:44 2008
New Revision: 121197

URL: http://svn.digium.com/view/asterisk?view=rev&rev=121197
Log:
add a new argument to PrivacyManager to specify a context
where the entered phone number is checked.

You can now define a set of extensions/exten patterns that describe
valid phone numbers. PrivacyManager will check that context for a match
with the given phone number.
This way you get better control. For example people blindly hitting
10 digits just to get past privacymanager

Example line in extensions.conf:
exten => incoming,n,PrivacyManager(3,10,route-outgoing)

Modified:
    trunk/CHANGES
    trunk/apps/app_privacy.c

Modified: trunk/CHANGES
URL: http://svn.digium.com/view/asterisk/trunk/CHANGES?view=diff&rev=121197&r1=121196&r2=121197
==============================================================================
--- trunk/CHANGES (original)
+++ trunk/CHANGES Sun Jun  8 06:40:44 2008
@@ -79,6 +79,9 @@
    complete documentation.
  * ChanIsAvail has a new option, 'a', which will return all available channels instead
    of just the first one if you give the function more then one channel to check.
+ * PrivacyManager now takes an option where you can specify a context where the 
+   given number will be matched. This way you have more control over who is allowed
+   and it stops the people who blindly enter 10 digits.
 
 SIP Changes
 -----------

Modified: trunk/apps/app_privacy.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_privacy.c?view=diff&rev=121197&r1=121196&r2=121197
==============================================================================
--- trunk/apps/app_privacy.c (original)
+++ trunk/apps/app_privacy.c Sun Jun  8 06:40:44 2008
@@ -46,13 +46,14 @@
 static char *synopsis = "Require phone number to be entered, if no CallerID sent";
 
 static char *descrip =
-  "  PrivacyManager([maxretries][,minlength]): If no Caller*ID \n"
+  "  PrivacyManager([maxretries][,minlength][,context]): If no Caller*ID \n"
   "is sent, PrivacyManager answers the channel and asks the caller to\n"
   "enter their phone number. The caller is given 'maxretries' attempts to do so.\n"
   "The application does nothing if Caller*ID was received on the channel.\n"
   "   maxretries  default 3  -maximum number of attempts the caller is allowed \n"
   "               to input a callerid.\n"
   "   minlength   default 10 -minimum allowable digits in the input callerid number.\n"
+  "   context     context to check the given Caller*ID against patterns.\n"
   "The application sets the following channel variable upon completion: \n"
   "PRIVACYMGRSTATUS  The status of the privacy manager's attempt to collect \n"
   "                  a phone number from the user. A text string that is either:\n" 
@@ -73,6 +74,7 @@
 		AST_APP_ARG(maxretries);
 		AST_APP_ARG(minlength);
 		AST_APP_ARG(options);
+		AST_APP_ARG(checkcontext);
 	);
 
 	if (!ast_strlen_zero(chan->cid.cid_num)) {
@@ -101,7 +103,6 @@
 				else
 					ast_log(LOG_WARNING, "Invalid min length argument\n");
 			}
-
 		}		
 
 		/* Play unidentified call */
@@ -125,9 +126,21 @@
 				break;
 
 			/* Make sure we get at least digits */
-			if (strlen(phone) >= minlength ) 
-				break;
-			else {
+			if (strlen(phone) >= minlength ) {
+				/* if we have a checkcontext argument, do pattern matching */
+				if (!ast_strlen_zero(args.checkcontext)) {
+					if (!ast_exists_extension(NULL, args.checkcontext, phone, 1, NULL)) {
+						res = ast_streamfile(chan, "privacy-incorrect", chan->language);
+						if (!res) {
+							res = ast_waitstream(chan, "");
+						}
+					} else {
+						break;
+					}
+				} else {
+					break;
+				}
+			} else {
 				res = ast_streamfile(chan, "privacy-incorrect", chan->language);
 				if (!res)
 					res = ast_waitstream(chan, "");




More information about the svn-commits mailing list