… | |
… | |
163 | sub err_blocked { |
163 | sub err_blocked { |
164 | my $self = shift; |
164 | my $self = shift; |
165 | my $ip = $self->{remote_addr}; |
165 | my $ip = $self->{remote_addr}; |
166 | my $time = time2str $blocked{$ip} = $::NOW + $::BLOCKTIME; |
166 | my $time = time2str $blocked{$ip} = $::NOW + $::BLOCKTIME; |
167 | |
167 | |
|
|
168 | Coro::Event::do_timer(after => 15); |
|
|
169 | |
168 | $self->err(403, "too many connections", |
170 | $self->err(401, "too many connections", |
169 | { |
171 | { |
170 | "Content-Type" => "text/html", |
172 | "Content-Type" => "text/html", |
171 | "Retry-After" => $::BLOCKTIME |
173 | "Retry-After" => $::BLOCKTIME |
172 | }, |
174 | }, |
173 | <<EOF); |
175 | <<EOF); |
… | |
… | |
215 | $req =~ /^(?:\015\012)? |
217 | $req =~ /^(?:\015\012)? |
216 | (GET|HEAD) \040+ |
218 | (GET|HEAD) \040+ |
217 | ([^\040]+) \040+ |
219 | ([^\040]+) \040+ |
218 | HTTP\/([0-9]+\.[0-9]+) |
220 | HTTP\/([0-9]+\.[0-9]+) |
219 | \015\012/gx |
221 | \015\012/gx |
220 | or $self->err(403, "method not allowed", { Allow => "GET,HEAD" }); |
222 | or $self->err(405, "method not allowed", { Allow => "GET,HEAD" }); |
221 | |
223 | |
222 | $2 ne "1.0" |
224 | $2 ne "1.0" |
223 | or $self->err(506, "http protocol version not supported"); |
225 | or $self->err(506, "http protocol version not supported"); |
224 | |
226 | |
225 | $self->{method} = $1; |
227 | $self->{method} = $1; |
… | |
… | |
403 | |
405 | |
404 | satisfiable: |
406 | satisfiable: |
405 | # check for segmented downloads |
407 | # check for segmented downloads |
406 | if ($l && $::NO_SEGMENTED) { |
408 | if ($l && $::NO_SEGMENTED) { |
407 | if (%{$uri{$self->{remote_addr}}{$self->{uri}}} > 1) { |
409 | if (%{$uri{$self->{remote_addr}}{$self->{uri}}} > 1) { |
|
|
410 | Coro::Event::do_timer(after => 15); |
|
|
411 | |
408 | $self->err(400, "segmented downloads are not allowed"); |
412 | $self->err(400, "segmented downloads are not allowed"); |
409 | } |
413 | } |
410 | } |
414 | } |
411 | |
415 | |
412 | $hdr->{"Content-Range"} = "bytes $l-$h/$length"; |
416 | $hdr->{"Content-Range"} = "bytes $l-$h/$length"; |