Actions

Adding White or Black listing to Routing Script: Difference between revisions

m (format and typo)
Line 1: Line 1:
{{DISPLAYTITLE:Adding White or Black listing to Routing Script}}
{{DISPLAYTITLE:Adding White or Black Listing to a Routing Script}}
 
This artilce describes how to add White or Black listing to any Routing scripts. With this script, any called or calling number prefix can be blacklisted or whitelisted. This script can be assigned globally, or per NAP. For this, you choose the "scope" to be "global" or "per_nap". It also reads a .csv file which has the called and calling number list (default name 'black_white_list.csv').
 


This shows how to add White or Black listing to any Routing scripts. With this script, any called or calling number prefix can be blacklisted or whitelisted. This script can be assigned globally, or per NAP. For this you choose the "scope" to be "global" or "per_nap". It also reads a .csv file which has the called and calling number list (default name 'black_white_list.csv').
A blacklisted called number set globally will block anyone trying to reach that number (or number prefix). A whitelisted calling number will only allow calls from these calling numbers in the system - all other calls will be dropped.
A blacklisted called number set globally will block anyone trying to reach that number (or number prefix). A whitelisted calling number will only allow calls from these calling numbers in the system - all other calls will be dropped.
<br>  
<br>  
Line 7: Line 9:
== Setting up White and Black Listing Scripts<br>  ==
== Setting up White and Black Listing Scripts<br>  ==


To setup a Filter, the main script needs to be modified. The main script can be either simple_routing.rb, or any other script.<br>  
To set up a Filter, the main script needs to be modified. The main script can be either simple_routing.rb, or any other script.<br>  


First, go to the routing script section of the Web portal  
First, go to the routing script section of the Web portal  
<pre>Gateway -&gt; Routing scripts -&gt; Example Scripts -&gt; simple_routing.rb [Edit]
<pre>Gateway -&gt; Routing scripts -&gt; Example Scripts -&gt; simple_routing.rb [Edit]
</pre>  
</pre>  
Three things need to be added. At the start of the script:<br>  
Three things need to be added. At the start of the script:<br>  
<pre>require 'black_white_listing'
<pre>require 'black_white_listing'
</pre>  
</pre>  
In the main class:<br>  
In the main class:<br>  
<pre>include BlackWhiteListing
<pre>include BlackWhiteListing
</pre>  
</pre>  
<pre>before_filter :method => :black_white_listing, :scope => :global
<pre>before_filter :method => :black_white_listing, :scope => :global
</pre>  
</pre>  
<br>  
<br>  
The final script will look like this:
The final script will look like this:
<pre>
<pre>
Line 40: Line 49:
end
end
</pre>  
</pre>  
== White and black listing file <br>  ==
== White and black listing file <br>  ==


Line 69: Line 79:
The scope needs to be set to "per_nap"
The scope needs to be set to "per_nap"
<pre> before_filter :method => :black_white_listing, :scope => :per_nap </pre>  
<pre> before_filter :method => :black_white_listing, :scope => :per_nap </pre>  
And you need to add new NAP colums to assign the files to the NAPs:
 
You need to add new NAP colums to assign the files to the NAPs:
<pre>Gateway -&gt; Routes -&gt; NAP Columns -&gt; Create New NAP Column</pre>
<pre>Gateway -&gt; Routes -&gt; NAP Columns -&gt; Create New NAP Column</pre>
'''Name''': black_white_list<br>'''Type attributes''': dbfile<br>'''Default''': black_white_list.csv <br>
'''Name''': black_white_list<br>'''Type attributes''': dbfile<br>'''Default''': black_white_list.csv <br>
[[Image:NAP black white listing.png]]
[[Image:NAP black white listing.png]]

Revision as of 11:16, 13 June 2022


This artilce describes how to add White or Black listing to any Routing scripts. With this script, any called or calling number prefix can be blacklisted or whitelisted. This script can be assigned globally, or per NAP. For this, you choose the "scope" to be "global" or "per_nap". It also reads a .csv file which has the called and calling number list (default name 'black_white_list.csv').


A blacklisted called number set globally will block anyone trying to reach that number (or number prefix). A whitelisted calling number will only allow calls from these calling numbers in the system - all other calls will be dropped.

Setting up White and Black Listing Scripts

To set up a Filter, the main script needs to be modified. The main script can be either simple_routing.rb, or any other script.

First, go to the routing script section of the Web portal

Gateway -> Routing scripts -> Example Scripts -> simple_routing.rb [Edit]


Three things need to be added. At the start of the script:

require 'black_white_listing'


In the main class:

include BlackWhiteListing


before_filter :method => :black_white_listing, :scope => :global


The final script will look like this:

require 'base_routing'
require 'black_white_listing'

class NapGroupAndWeightRouting < BaseRouting
  include BlackWhiteListing
  
  before_filter :method => :black_white_listing, :scope => :global

  route_match :call_field_name => :called
  route_match :call_field_name => :calling
  route_match :call_field_name => :nap
  route_match :method => :match_nap_availability
  route_remap :call_field_name => :called, :route_field_name => :remapped_called
  route_remap :call_field_name => :calling, :route_field_name => :remapped_calling
  route_remap :call_field_name => :nap, :route_field_name => :remapped_nap
end

White and black listing file

The 'black_white_list.csv' file needs to be formatted in a specific way. There are 4 columns: The first one is indicating the calling number (or calling number prefix). The second one indicates to whitelist 'w' or blacklist 'b' the number. The third one is indicating the called number (or called number prefix). The last one indicates to whitelist 'w' or blacklist 'b' the number.
This example will blacklist the calling numbers 148240000 and 148240707, and also any calls that try to reach numbers starting with 450 or 514 :

calling calling_params called called_params
148240707 b
148240000 b
450 b
514 b

To add the white and black listing file to the system

  1. Click FileDB in the navigation panel
  2. Click Import new file
  3. Click Browse and select the 'black_white_list.csv' you wish to import.
  4. Click Import

Import new file black white listing.png

To assign a white and black listing to a NAP

The scope needs to be set to "per_nap"

 before_filter :method => :black_white_listing, :scope => :per_nap 

You need to add new NAP colums to assign the files to the NAPs:

Gateway -> Routes -> NAP Columns -> Create New NAP Column

Name: black_white_list
Type attributes: dbfile
Default: black_white_list.csv
NAP black white listing.png