#161 [PDT] Patch to include "check_domain"

ver 1.3.x
open
nobody
modules (140)
2
2014-09-04
2008-05-16
No

Hi, by default PDT module doesn't allow two entries in 'pdt' table with same "sdomain" and "domain" fields.

AFAIK OpenSer 1.4 includes a "check_table" parameter to allow the above.

I submit a patch that includes this feature for OpenSer 1.3.1 or 1.3.2.

I use it to implement international destination (by prefix) allow/deny system, this is, we can call to Spain, England, Finnland, USA, but not to Brasil (for example). For that I need a change in "pdt" table:

CREATE TABLE `pdt` (
`id` int(10) unsigned NOT NULL auto_increment,
`sdomain` varchar(128) NOT NULL default '*',
`prefix` varchar(32) NOT NULL,
`domain` enum('y','n') NOT NULL default 'y',
`description` varchar(20) default NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `sdomain_prefix_idx` (`sdomain`,`prefix`)
) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=latin1

- 'sdomain' field doesn't matter and it can be whatever ('*' for example).

- 'domain' becomes a SQL ENUM field ('y', 'n').
If 'domain' == 'y' then the destination is allowed, if 'n' then not.

- 'description' can be the country code (or "Spain fixed", "England mobile"...).

- 'prefix' is the E164 country/destination prefix (+34, +349, +44...).

The OpenSer code would be:

----------------
modparam("pdt", "check_domain", 0)

...

route[ROUTE_IS_PREFIX_ALLOWED] {
# Here we must arrive with RURI normalize to E164 (+XXXXXXXXX).

prefix2domain("2");
# If success, the RURI domain is modified (to 'y' so we need to replace later with our carrier IP/domain).

# If -1 then the prefix doesn't exist so not allowed.
if ($rc != 1) {
xlog("L_INFO","--- Destination $rU not allowed \n");
return(-1);
}

# If "domain" is 'n' then this destiantion is not allowed (dissabled).
if ($rd == "n") {
xlog("L_INFO","--- Destination $rU dissabled \n");
return(-1);
}

return(1);

}
# If success remember to set the RURI domain after this route.
----------------

Hope it's useful.

Discussion

  • Henning Westerholt

    Logged In: YES
    user_id=337916
    Originator: NO

    Hi Iñaki,

    do i understand this correctly, this patch justs ports already available functionality from 1.4 to the 1.3 version? Or do you also add some more extensions?

    Thanks,

    Henning

     
  • Iñaki Baz Castillo

    Logged In: YES
    user_id=1844020
    Originator: YES

    It just adds the feature from 1.4 to 1.3, no more.
    PD: In the top of my report I say "check_table" when obviously I mean "check_domain".

     
  • Henning Westerholt

    Thanks for the clarification, decrease priority to reflect this.

     
  • Henning Westerholt

    • priority: 5 --> 2
     

Log in to post a comment.