| 1 |
use HTTP::Date; |
| 2 |
|
| 3 |
use Coro::Event; |
| 4 |
|
| 5 |
sub conn::err_block_country { |
| 6 |
my $self = shift; |
| 7 |
my $whois = shift; |
| 8 |
|
| 9 |
$whois =~ s/&/&/g; |
| 10 |
$whois =~ s/</</g; |
| 11 |
$self->err(403, "forbidden", { "Content-Type" => "text/html", Connection => "close" }, <<EOF); |
| 12 |
<html> |
| 13 |
<head> |
| 14 |
<title>This material is licensed in your country!</title> |
| 15 |
</head> |
| 16 |
<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#000080" alink="#ff0000"> |
| 17 |
|
| 18 |
<h1>This material is licensed in your country!</h1> |
| 19 |
|
| 20 |
<p>My research has shown that your IP address |
| 21 |
(<b>$self->{remote_addr}</b>) most probably is located in this country: |
| 22 |
<b>$self->{country}</b> (ISO-3166-2 code, XX == unknown). The full record is:</p> |
| 23 |
|
| 24 |
<pre> |
| 25 |
$whois |
| 26 |
</pre> |
| 27 |
|
| 28 |
<p>My database says that the material you are trying to access is licensed |
| 29 |
in your country. If I would distribute these files to your country I would |
| 30 |
actively <em>hurt</em> the industry behind it, which includes the artists |
| 31 |
and authors of these videos/mangas. So I hope you understand that I try to |
| 32 |
avoid this.</p> |
| 33 |
|
| 34 |
<div align="right">Thanks a lot for understanding.</div> |
| 35 |
|
| 36 |
</body> |
| 37 |
</html> |
| 38 |
EOF |
| 39 |
} |
| 40 |
|
| 41 |
sub conn::err_block_referer { |
| 42 |
my $self = shift; |
| 43 |
|
| 44 |
my $uri = $self->{uri}; |
| 45 |
$uri =~ s/\/[^\/]+$/\//; |
| 46 |
|
| 47 |
$self->slog(6, "REFERER($self->{uri},$self->{h}{referer})"); |
| 48 |
|
| 49 |
$whois =~ s/&/&/g; |
| 50 |
$whois =~ s/</</g; |
| 51 |
$self->err(203, "non-authoritative", { "Content-Type" => "text/html" }, <<EOF); |
| 52 |
<html> |
| 53 |
<head> |
| 54 |
<title>Unallowed Referral</title> |
| 55 |
</head> |
| 56 |
<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#000080" alink="#ff0000"> |
| 57 |
|
| 58 |
<h1>The site which referred you has done something bad!</h1> |
| 59 |
|
| 60 |
<p>It seems that you are coming from this URL:</p> |
| 61 |
|
| 62 |
<pre>$self->{h}{referer}</pre> |
| 63 |
|
| 64 |
<p>This site has been blocked, either because it required you to pay |
| 65 |
money, forced you to click on banners, claimed these files were theirs |
| 66 |
or something very similar. Please note that you can download these files |
| 67 |
<em>without</em> having to pay, <em>without</em> clicking banners or jump |
| 68 |
through other hoops.</p> |
| 69 |
|
| 70 |
<p><b>Sites like the one you came from actively hurt the distribution of |
| 71 |
these files and the service quality for you since I can't move or correct |
| 72 |
files and you will likely not be able to see the full archive.</b></p> |
| 73 |
|
| 74 |
<p>Having that this, you can find the original content (if it is still |
| 75 |
there) by <b>following <a href="$uri">this link</a>.</b></p> |
| 76 |
|
| 77 |
<div align="right">Thanks a lot for understanding.</div> |
| 78 |
|
| 79 |
</body> |
| 80 |
</html> |
| 81 |
EOF |
| 82 |
} |
| 83 |
|
| 84 |
sub conn::err_blocked { |
| 85 |
my $self = shift; |
| 86 |
my $id = $self->{remote_id}; |
| 87 |
my $block = $conn::blocked{$id}; |
| 88 |
|
| 89 |
$block->[2]++; |
| 90 |
|
| 91 |
if ($block->[0] < $::NOW + $::BLOCKTIME) { |
| 92 |
$block->[0] = $::NOW + $::BLOCKTIME; |
| 93 |
} |
| 94 |
|
| 95 |
my $status = 403; |
| 96 |
my $hdr = { |
| 97 |
"Content-Type" => "text/html", |
| 98 |
"Retry-After" => $block->[0] - $::NOW, |
| 99 |
"Connection" => "close", |
| 100 |
}; |
| 101 |
|
| 102 |
my $ctime = $HTTP_NOW; |
| 103 |
my $etime = time2str $block->[0]; |
| 104 |
|
| 105 |
my $limit = $block->[3]; |
| 106 |
$block->[3] = $::NOW + 10; |
| 107 |
|
| 108 |
if ($limit > $::NOW) { |
| 109 |
Coro::Event::do_timer(after => $limit - $::NOW); |
| 110 |
|
| 111 |
if ($block->[2] > 30) { |
| 112 |
$block->[3] = $::NOW + 180; |
| 113 |
$status = 401; |
| 114 |
$hdr->{Warning} = "Please do NOT retry, you have been blocked. Press Cancel instead."; |
| 115 |
$hdr->{"WWW-Authenticate"} = "Basic realm=\"Please do NOT retry, you have been blocked. Press Cancel instead.\""; |
| 116 |
} |
| 117 |
} |
| 118 |
|
| 119 |
$self->err($status, $block->[1], $hdr, |
| 120 |
<<EOF); |
| 121 |
<html> |
| 122 |
<head> |
| 123 |
<title>$block->[1]</title> |
| 124 |
</head> |
| 125 |
<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#000080" alink="#ff0000"> |
| 126 |
|
| 127 |
<p>You have been blocked because you didn't behave. The exact reason was:</p> |
| 128 |
|
| 129 |
<h1><blockquote>"$block->[1]"</blockquote></h1> |
| 130 |
|
| 131 |
<p>You may retry not earlier than:</p> |
| 132 |
|
| 133 |
<p><blockquote>$etime.</blockquote></p> |
| 134 |
|
| 135 |
<p>Until then, each access will renew the block.</p> |
| 136 |
|
| 137 |
<p>For your reference, the current time and your connection ID is:</p> |
| 138 |
|
| 139 |
<p><blockquote>$ctime | $id</blockquote></p> |
| 140 |
|
| 141 |
</body></html> |
| 142 |
EOF |
| 143 |
} |
| 144 |
|
| 145 |
sub conn::err_segmented_download { |
| 146 |
my $self = shift; |
| 147 |
$self->err(400, "segmented downloads are not allowed", |
| 148 |
{ "Content-Type" => "text/html", Connection => "close" }, <<EOF); |
| 149 |
<html> |
| 150 |
<head> |
| 151 |
<title>Segmented downloads are not allowed</title> |
| 152 |
</head> |
| 153 |
<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#000080" alink="#ff0000"> |
| 154 |
|
| 155 |
<p>Segmented downloads are not allowed on this server.</p> |
| 156 |
|
| 157 |
</body></html> |
| 158 |
EOF |
| 159 |
} |
| 160 |
|
| 161 |
1; |
| 162 |
|