| 1 |
Blst Module - Blocklist Management |
| 2 |
|
| 3 |
Andrei Pelinescu-Onciul |
| 4 |
|
| 5 |
iptelorg GmbH |
| 6 |
|
| 7 |
Copyright © 2007 iptelorg GmbH |
| 8 |
__________________________________________________________________ |
| 9 |
|
| 10 |
Table of Contents |
| 11 |
|
| 12 |
1. Admin Guide |
| 13 |
|
| 14 |
1. Overview |
| 15 |
2. Functions |
| 16 |
|
| 17 |
2.1. blst_add([timeout]) |
| 18 |
2.2. blst_add_retry_after(min, max) |
| 19 |
2.3. blst_del() |
| 20 |
2.4. blst_is_blocklisted() |
| 21 |
2.5. blst_set_ignore([flags]) |
| 22 |
2.6. blst_rpl_set_ignore([flags]) |
| 23 |
2.7. blst_clear_ignore([flags]) |
| 24 |
2.8. blst_rpl_clear_ignore([flags]) |
| 25 |
|
| 26 |
List of Examples |
| 27 |
|
| 28 |
1.1. blst_add usage |
| 29 |
1.2. blst_add_retry_after usage |
| 30 |
1.3. blst_del usage |
| 31 |
1.4. blst_is_blocklisted usage |
| 32 |
1.5. blst_set_ignore usage |
| 33 |
1.6. blst_clear_ignore usage |
| 34 |
|
| 35 |
Chapter 1. Admin Guide |
| 36 |
|
| 37 |
Table of Contents |
| 38 |
|
| 39 |
1. Overview |
| 40 |
2. Functions |
| 41 |
|
| 42 |
2.1. blst_add([timeout]) |
| 43 |
2.2. blst_add_retry_after(min, max) |
| 44 |
2.3. blst_del() |
| 45 |
2.4. blst_is_blocklisted() |
| 46 |
2.5. blst_set_ignore([flags]) |
| 47 |
2.6. blst_rpl_set_ignore([flags]) |
| 48 |
2.7. blst_clear_ignore([flags]) |
| 49 |
2.8. blst_rpl_clear_ignore([flags]) |
| 50 |
|
| 51 |
1. Overview |
| 52 |
|
| 53 |
This module exports blocklist related functions to the script. |
| 54 |
|
| 55 |
2. Functions |
| 56 |
|
| 57 |
2.1. blst_add([timeout]) |
| 58 |
2.2. blst_add_retry_after(min, max) |
| 59 |
2.3. blst_del() |
| 60 |
2.4. blst_is_blocklisted() |
| 61 |
2.5. blst_set_ignore([flags]) |
| 62 |
2.6. blst_rpl_set_ignore([flags]) |
| 63 |
2.7. blst_clear_ignore([flags]) |
| 64 |
2.8. blst_rpl_clear_ignore([flags]) |
| 65 |
|
| 66 |
2.1. blst_add([timeout]) |
| 67 |
|
| 68 |
Adds the source of the current message to the blocklist for timeout |
| 69 |
seconds. If timeout is missing or 0 it uses the default blocklist |
| 70 |
timeout (dst_blocklist_expire). |
| 71 |
|
| 72 |
Example 1.1. blst_add usage |
| 73 |
... |
| 74 |
if (src_ip==10.0.0.0/9) |
| 75 |
blst_add(30); # 30 s |
| 76 |
else |
| 77 |
blst_add(); # use default blocklist timeout |
| 78 |
... |
| 79 |
|
| 80 |
2.2. blst_add_retry_after(min, max) |
| 81 |
|
| 82 |
Adds the source of the current message to the blocklist for the time |
| 83 |
interval specified in the Retry-After header. If the Retry-After header |
| 84 |
is missing, it will fail (returns false). If the Retry-After value is |
| 85 |
less than min, then min seconds will be used instead. If the |
| 86 |
Retry-After value is greater than max, then max seconds will be used |
| 87 |
instead. |
| 88 |
|
| 89 |
Example 1.2. blst_add_retry_after usage |
| 90 |
... |
| 91 |
# on_reply route |
| 92 |
if (msg_status==503){ # blocklist 503 source for Retry-After seconds |
| 93 |
if (! blst_add_retry_after(30, 3600)) |
| 94 |
blst_add(60); # if no retry_after header add it for 60s |
| 95 |
} |
| 96 |
... |
| 97 |
|
| 98 |
2.3. blst_del() |
| 99 |
|
| 100 |
Removes the source of the current message from the blocklist. If the |
| 101 |
address is not present in the blocklist at the time of the call it |
| 102 |
returns false. |
| 103 |
|
| 104 |
Example 1.3. blst_del usage |
| 105 |
... |
| 106 |
blst_del(); |
| 107 |
... |
| 108 |
|
| 109 |
2.4. blst_is_blocklisted() |
| 110 |
|
| 111 |
Returns true if the source of the current message is blocklisted. |
| 112 |
|
| 113 |
Example 1.4. blst_is_blocklisted usage |
| 114 |
... |
| 115 |
if (blst_is_blocklisted()){ |
| 116 |
log("message from a blocklisted source"); |
| 117 |
drop; |
| 118 |
} |
| 119 |
... |
| 120 |
|
| 121 |
2.5. blst_set_ignore([flags]) |
| 122 |
|
| 123 |
Set errors that will not be taken into account when deciding whether to |
| 124 |
blocklist a destination for the current message or a local reply to the |
| 125 |
current message. |
| 126 |
|
| 127 |
blst_set_ignore(..) works for forwarding the current message and |
| 128 |
blst_rpl_set_ignore(...) works for local replies to the current |
| 129 |
message. |
| 130 |
|
| 131 |
The variants of these functions with no parameters will ignore |
| 132 |
everything (equivalent to passing 0xff). |
| 133 |
|
| 134 |
The flags are stored internally as a bitmask, and are applied by |
| 135 |
bitwise ANDing them together. The following flags are available: |
| 136 |
* 0x02 - generic send error (send denied/ failed). |
| 137 |
* 0x04 - connect failed (TCP, TLS or SCTP). |
| 138 |
* 0x08 - ICMP error (not currently used). |
| 139 |
* 0x10 - SIP transaction timeout. |
| 140 |
* 0x20 - 503 reply (stateful mode only). For more details see |
| 141 |
tmblst_503. |
| 142 |
|
| 143 |
Note |
| 144 |
|
| 145 |
TCP and TLS send and connect errors are handled per connection and not |
| 146 |
per message. The connection blocklist ignore flags are inherited from |
| 147 |
the message that caused the connection establishment. |
| 148 |
|
| 149 |
Example 1.5. blst_set_ignore usage |
| 150 |
... |
| 151 |
blst_set_ignore(6); # ignore send and connect errors |
| 152 |
... |
| 153 |
|
| 154 |
2.6. blst_rpl_set_ignore([flags]) |
| 155 |
|
| 156 |
See function blst_set_ignore([flags]). |
| 157 |
|
| 158 |
2.7. blst_clear_ignore([flags]) |
| 159 |
|
| 160 |
Clears blocklist ignore flags previously set by the corresponding |
| 161 |
blst_set_ignore(...) or blst_rpl_set_ignore(...) functions. |
| 162 |
|
| 163 |
See also blst_set_ignore. |
| 164 |
|
| 165 |
Example 1.6. blst_clear_ignore usage |
| 166 |
... |
| 167 |
blst_clear_ignore(4); # ignore connect errors |
| 168 |
... |
| 169 |
|
| 170 |
2.8. blst_rpl_clear_ignore([flags]) |
| 171 |
|
| 172 |
See function blst_clear_ignore([flags]). |