[r10376]: branches / 1.8 / modules / userblacklist / doc / userblacklist_admin.xml Maximize Restore History

Download this file

userblacklist_admin.xml    262 lines (252 with data), 8.3 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
<chapter>
<title>&adminguide;</title>
<section>
<title>Overview</title>
<para>
The userblacklist module allows OpenSIPS to handle blacklists
on a per user basis. This information is stored in a database
table, which is queried to decide if the number (more exactly,
the request URI user) is blacklisted or not.
</para>
<para>
An additional functionality that this module provides is the ability
to handle global blacklists. This lists are loaded on startup into
memory, thus providing a better performance then in the userblacklist
case. This global blacklists are useful to only allow calls to certain
international destinations, i.e. block all not whitelisted numbers.
They could also used to prevent the blacklisting of important
numbers, as whitelisting is supported too. This is useful for example
to prevent the customer from blocking emergency call number or service
hotlines.
</para>
<para>
The module exports two functions, <emphasis>check_blacklist</emphasis>
and <emphasis>check_user_blacklist</emphasis> for usage in the config
file. Furthermore its provide a FIFO function to reload the global
blacklist cache.
</para>
</section>
<section>
<title>Dependencies</title>
<section>
<title>&osips; Modules</title>
<para>
The module depends on the following modules (in the other words
the listed modules must be loaded before this module):
</para>
<itemizedlist>
<listitem>
<para><emphasis>database</emphasis> -- Any database module</para>
</listitem>
</itemizedlist>
</section>
<section>
<title>External Libraries or Applications</title>
<para>
The following libraries or applications must be installed
before running &osips; with this module loaded:
</para>
<itemizedlist>
<listitem>
<para><emphasis>none</emphasis></para>
</listitem>
</itemizedlist>
</section>
</section>
<section>
<title>Exported Parameters</title>
<section>
<title><varname>db_url</varname> (string)</title>
<para>
Url to the database containing the routing data.
</para>
<para>
<emphasis>
Default value is <quote>&defaultrodb;</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>db_url</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("userblacklist", "db_url", "&exampledb;")
...
</programlisting>
</example>
</section>
<section>
<title><varname>db_table</varname> (string)</title>
<para>
Name of the table where the user blacklist data is stored.
</para>
<para>
<emphasis>
Default value is <quote>userblacklist</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>db_table</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("userblacklist", "db_table", "userblacklist")
...
</programlisting>
</example>
</section>
<section>
<title><varname>use_domain</varname> (integer)</title>
<para>
If set to non-zero value, the domain column in the userblacklist is used.
</para>
<para>
<emphasis>
Default value is <quote>0</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>use_domain</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("userblacklist", "use_domain", 0)
...
</programlisting>
</example>
</section>
</section>
<section>
<title>Exported Functions</title>
<section>
<title>
<function moreinfo="none">check_user_blacklist (string user, string domain, string number, string table)</function>
</title>
<para>
Finds the longest prefix that matches the request URI user (or the number
parameter) for the given user and domain name in the database.
If a match is found and it is not set to whitelist, false is returned.
Otherwise, true is returned. Pseudo-variables or AVPs can be used for
the user, domain and number parameters. The number and table variables
are optional, the defaults are used if they are ommited. The number
parameter can be used to check for example against the from URI user.
</para>
<example>
<title><function>check_user_blacklist</function> usage</title>
<programlisting format="linespecific">
...
$avp(username) = $rU;
# rewrite the R-URI
if (!check_user_blacklist("$avp(username)", "$avp(return)"))
sl_send_reply("403", "Forbidden");
exit;
}
...
</programlisting>
</example>
</section>
<section>
<title>
<function moreinfo="none">check_blacklist (string table)</function>
</title>
<para>
Finds the longest prefix that matches the request URI for the
given table. If a match is found and it is not set to whitelist,
false is returned. Otherwise, true is returned.
</para>
<example>
<title><function>check_blacklist</function> usage</title>
<programlisting format="linespecific">
...
if (!check_blacklist("global_blacklist")))
sl_send_reply("403", "Forbidden");
exit;
}
...
</programlisting>
</example>
</section>
</section>
<section>
<title><acronym>MI</acronym> Commands</title>
<section>
<title>
<function moreinfo="none">reload_blacklist</function>
</title>
<para>
Reload the internal global blacklist cache. This is necessary after
the database tables for the global blacklist have been changed.
</para>
<example>
<title><function>reload_blacklists</function> usage</title>
<programlisting format="linespecific">
...
opensipsctl fifo reload_blacklist
...
</programlisting>
</example>
</section>
</section>
<section>
<title>Installation and Running</title>
<section>
<title>Database setup</title>
<para>
Before running &osips; with userblacklist, you have to setup the database
table where the module will read the blacklist data. For that, if
the table was not created by the installation script or you choose
to install everything by yourself you can use the userblacklist-create.sql
<acronym>SQL</acronym> script in the database directories in the
opensips/scripts folder as template.
Database and table name can be set with module parameters so they
can be changed, but the name of the columns must be as they are
in the <acronym>SQL</acronym> script.
You can also find the complete database documentation on the
project webpage, &osipsdbdocs;.
</para>
<example>
<title>Example database content - globalblacklist table</title>
<programlisting format="linespecific">
...
+----+-----------+-----------+
| id | prefix | whitelist |
+----+-----------+-----------+
| 1 | | 0 |
| 2 | 1 | 1 |
| 3 | 123456 | 0 |
| 4 | 123455787 | 0 |
+----+-----------+-----------+
...
</programlisting>
</example>
<para>
This table will setup a global blacklist for all numbers, only allowing calls
starting with <quote>1</quote>. Numbers that starting with <quote>123456</quote>
and <quote>123455787</quote> are also blacklisted, because the longest prefix
will be matched.
</para>
<example>
<title>Example database content - userblacklist table</title>
<programlisting format="linespecific">
...
+----+----------------+-------------+-----------+-----------+
| id | username | domain | prefix | whitelist |
+----+----------------+-------------+-----------+-----------+
| 23 | 49721123456788 | | 1234 | 0 |
| 22 | 49721123456788 | | 123456788 | 1 |
| 21 | 49721123456789 | | 12345 | 0 |
| 20 | 494675231 | | 499034133 | 1 |
| 19 | 494675231 | test | 499034132 | 0 |
| 18 | 494675453 | test.domain | 49901 | 0 |
| 17 | 494675454 | | 49900 | 0 |
+----+----------------+-------------+-----------+-----------+
...
</programlisting>
</example>
<para>
This table will setup user specific blacklists for certain usernames. For example
for user <quote>49721123456788</quote> the prefix <quote>1234</quote> will be not
allowed, but the number <quote>123456788</quote> is allowed. Additionally a domain
could be specified that is used for username matching if the <quote>use_domain</quote>
parameter is set.
</para>
</section>
</section>
</chapter>