… | |
… | |
92 | } |
92 | } |
93 | |
93 | |
94 | sub conn::err_blocked { |
94 | sub conn::err_blocked { |
95 | my $self = shift; |
95 | my $self = shift; |
96 | my $ip = $self->{remote_addr}; |
96 | my $ip = $self->{remote_addr}; |
|
|
97 | my $ctime = $HTTP_NOW; |
97 | my $time = time2str $conn::blocked{$ip} = $::NOW + $::BLOCKTIME; |
98 | my $etime = time2str $conn::blocked{$ip} = $::NOW + $::BLOCKTIME; |
98 | |
99 | |
99 | Coro::Event::do_timer(after => 20*rand); |
100 | Coro::Event::do_timer(after => 20*rand); |
100 | |
101 | |
101 | $self->err(401, "too many connections", |
102 | $self->err(401, "too many connections", |
102 | { |
103 | { |
103 | "Content-Type" => "text/html", |
104 | "Content-Type" => "text/html", |
104 | "Retry-After" => $::BLOCKTIME, |
105 | "Retry-After" => $::BLOCKTIME, |
105 | "Warning" => "Please do NOT retry, you have been blocked", |
106 | "Warning" => "Please do NOT retry, you have been blocked. Press Cancel instead.", |
106 | "WWW-Authenticate" => "Basic realm=\"Please do NOT retry, you have been blocked\"", |
107 | "WWW-Authenticate" => "Basic realm=\"Please do NOT retry, you have been blocked. Press Cancel instead.\"", |
107 | "Connection" => "close", |
108 | "Connection" => "close", |
108 | }, |
109 | }, |
109 | <<EOF); |
110 | <<EOF); |
110 | <html> |
111 | <html> |
111 | <head> |
112 | <head> |
… | |
… | |
114 | <body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#000080" alink="#ff0000"> |
115 | <body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#000080" alink="#ff0000"> |
115 | |
116 | |
116 | <p>You have been blocked because you opened too many connections. You |
117 | <p>You have been blocked because you opened too many connections. You |
117 | may retry at</p> |
118 | may retry at</p> |
118 | |
119 | |
119 | <p><blockquote>$time.</blockquote></p> |
120 | <p><blockquote>$etime.</blockquote></p> |
|
|
121 | |
|
|
122 | <p>For your reference, the current time is:</p> |
|
|
123 | |
|
|
124 | <p><blockquote>$ctime.</blockquote></p> |
120 | |
125 | |
121 | <p>Until then, each new access will renew the block. You might want to have a |
126 | <p>Until then, each new access will renew the block. You might want to have a |
122 | look at the <a href="http://www.goof.com/pcg/marc/animefaq.html#connectionlimit">FAQ</a>.</p> |
127 | look at the <a href="http://www.goof.com/pcg/marc/animefaq.html#blocked">FAQ</a>.</p> |
123 | |
128 | |
124 | </body></html> |
129 | </body></html> |
125 | EOF |
130 | EOF |
126 | } |
131 | } |
127 | |
132 | |