aboutsummaryrefslogtreecommitdiff
path: root/src/vmod-tbf.3
diff options
context:
space:
mode:
Diffstat (limited to 'src/vmod-tbf.3')
-rw-r--r--src/vmod-tbf.315
1 files changed, 12 insertions, 3 deletions
diff --git a/src/vmod-tbf.3 b/src/vmod-tbf.3
index 6ab2f63..03d7daf 100644
--- a/src/vmod-tbf.3
+++ b/src/vmod-tbf.3
@@ -10,13 +10,13 @@
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
.\" GNU General Public License for more details.
.\"
.\" You should have received a copy of the GNU General Public License
.\" along with vmod-tbf. If not, see <http://www.gnu.org/licenses/>.
-.TH VMOD-TBF 1 "November 1, 2014" "VMOD-TBF" "User Reference"
+.TH VMOD-TBF 1 "November 13, 2014" "VMOD-TBF" "User Reference"
.SH NAME
vmod-tbf \- token bucket filtering for Varnish
.SH SYNOPSIS
.B import tbf;
.BI "VOID tbf.open(STRING " dbdir ", STRING " params ");"
@@ -75,21 +75,30 @@ the above description. The \fBkey\fR argument identifies the bucket.
The function returns \fBTRUE\fR if the data are accepted and
\fBFALSE\fR otherwise. The sample usage is:
.PP
.EX
sub vcl_recv {
if (!tbf.rate("ip:" + client.ip, 1, 0.1s, 20)) {
- error 429 "Request rate exceeded."
+ error(429, "Request rate exceeded");
}
}
.EE
.PP
This example will keep the incoming requests at the rate of 10 requests
per second, allowing for bursts of up to 20 requests after each 2
second (or longer) period of inactivity.
.PP
+For VCL 4.0, replace
+.EX
+ error(429, "Request rate exceeded");
+.EE
+with
+.EX
+ return(synth(429, "Request rate exceeded"));
+.EE
+.PP
The \fBtbf.check\fR function provides a higher-level interface. Its
first argument identifies the bucket. The \fIrate\fR argument is a
textual rate specification in the form:
.PP
.BI "" N req/ K "" U
.PP
@@ -101,13 +110,13 @@ rate specification can be separated by any amount of whitespace.
For example, the following statement will limit the request rate to
ten and a half requests per second:
.PP
.EX
sub vcl_recv {
if (!tbf.check(client.ip, "10.5 req/1s")) {
- error 429 "Request rate exceeded."
+ error(429, "Request rate exceeded");
}
}
.EE
.SS Storage
.PP
Buckets are kept in a Berkeley database file. The \fBtbf.open\fR function

Return to:

Send suggestions and report system problems to the System administrator.