Adding White or Black listing to FreeSBC
Page 1 of 1
Adding White or Black listing to FreeSBC
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.
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
Three things need to be added. At the start of the script:
In the main class:
The final script will look like this:
White and black listing file
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
1001 w
450 b
514 b
To add the white and black listing file to the system
To assign a white and black listing to a NAP
The scope needs to be set to "per_nap"
And you need to add new NAP colums to assign the files to the NAPs:
Name: black_white_list
Type attributes: dbfile
Default: black_white_list.csv
Don't forget to activate the new configuration.
In the Call Trace you will see 403 Forbidden for black listed call and you will see following messages in the Gateway logs if call have any blacklisted number;
Adding White or Black listing to Routing Script
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
- Code:
Gateway -> Routing scripts -> Example Scripts -> simple_routing.rb [Edit]
Three things need to be added. At the start of the script:
- Code:
require 'black_white_listing'
In the main class:
- Code:
include BlackWhiteListing
- Code:
before_filter :method => :black_white_listing, :scope => :global
The final script will look like this:
- Code:
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
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
1001 w
450 b
514 b
To add the white and black listing file to the system
- Click FileDB in the navigation panel
- Click Import new file
- Click Browse and select the 'black_white_list.csv' you wish to import.
- Click Import
To assign a white and black listing to a NAP
The scope needs to be set to "per_nap"
- Code:
before_filter :method => :black_white_listing, :scope => :per_nap
And you need to add new NAP colums to assign the files to the NAPs:
- Code:
Gateway -> Routes -> NAP Columns -> Create New NAP Column
Name: black_white_list
Type attributes: dbfile
Default: black_white_list.csv
Don't forget to activate the new configuration.
In the Call Trace you will see 403 Forbidden for black listed call and you will see following messages in the Gateway logs if call have any blacklisted number;
- Code:
11th, 19:22:24.053+1100 TBLV1 GW : CTBCAFGateway::GetRoutes: Found 0 contacts for user/contact '148240707' in domain 'sip.xyz.com'.
11th, 19:22:24.053+1100 TBLV1 ROUT: black_white_listing: calling=1001 -> WhiteListed -> Allowing
11th, 19:22:24.053+1100 TBLV1 ROUT: black_white_listing: called=148240707 -> BlackListed -> Rejecting
Adding White or Black listing to Routing Script
Similar topics
» Endpoint sends the register request to FreeSBC however the FreeSBC is not forwarding it to the registrar
» Adding new values to CDR
» Adding user=phone to URI and headers
» Need help with the syntax for adding NAPs with the API
» Adding 2nd (Second) IP in ProSBC AWS Platform.
» Adding new values to CDR
» Adding user=phone to URI and headers
» Need help with the syntax for adding NAPs with the API
» Adding 2nd (Second) IP in ProSBC AWS Platform.
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum