0

Get rid of prefix

This commit is contained in:
eleksir
2020-09-19 11:48:43 +03:00
parent bd158cb106
commit 370dc372bc
3 changed files with 8 additions and 12 deletions

View File

@@ -10,10 +10,10 @@
указания правильного referer-а.
Эта прокся призвана частично решить эту проблему через создание линков вида
`https://сайт/префикс/joyproxy/img1.reactor.cc/pics/post/mp4/видосик.mp4`
`https://сайт/joyproxy/img1.reactor.cc/pics/post/mp4/видосик.mp4`
Сгенерировать ссылку можно запостив урл с видосиком в форму на страничке
`https://сайт/префикс/joyurl`
`https://сайт/joyurl`
## Как это работает?

View File

@@ -52,7 +52,6 @@ sub joyproxy ($) {
sub joyurl (@) {
my $str = shift;
my $host = shift;
my $prefix = shift;
$str = uri_unescape($str);
if (length($str) < 60) {
@@ -73,9 +72,8 @@ sub joyurl (@) {
$fname = substr($url[4], 0, -5) if (substr($url[4], -5, 6) eq '.webm');
$str = sprintf(
"https://%s/%s/joyproxy/%s/%s/%s/mp4/%s.mp4",
"https://%s/joyproxy/%s/%s/%s/mp4/%s.mp4",
$host,
$prefix,
$url[0],
$url[1],
$url[2],
@@ -90,7 +88,7 @@ sub joyurl (@) {
$str = '';
}
my $msg = "<html>\n<body>\n<form method='get' action='$prefix/joyurl'>\n<input type='text' name='joyurl' size=100 autofocus><br />\n<input type='submit' value='Post it!'' style='font-size:115%;'' />\n<br>$str\n</body>\n</html>\n";
my $msg = "<html>\n<body>\n<form method='get' action='joyurl'>\n<input type='text' name='joyurl' size=100 autofocus><br />\n<input type='submit' value='Post it!'' style='font-size:115%;'' />\n<br>$str\n</body>\n</html>\n";
return ('200', 'text/html', $msg);
}

View File

@@ -9,8 +9,6 @@ use joyproxy qw(joyurl joyproxy);
$| = 1;
my $prefix = "api";
my $app = sub {
my $env = shift;
@@ -18,7 +16,7 @@ my $app = sub {
my $status = '404';
my $content = 'text/plain';
if ($env->{PATH_INFO} =~ /$prefix\/joyproxy\/(.+)/) {
if ($env->{PATH_INFO} =~ /^\/joyproxy\/(.+)/) {
my $joyproxyurl = $1;
($status, $content, $msg) = ('400', $content, "Bad Request?\n");
@@ -27,11 +25,11 @@ my $app = sub {
}
}
if ($env->{PATH_INFO} =~ /$prefix\/joyurl/) {
if ($env->{PATH_INFO} =~ /^\/joyurl/) {
if (defined($env->{QUERY_STRING})) {
($status, $content, $msg) = joyurl($env->{QUERY_STRING}, $env->{HTTP_HOST}, $prefix);
($status, $content, $msg) = joyurl($env->{QUERY_STRING}, $env->{HTTP_HOST});
} else {
($status, $content, $msg) = joyurl('', $env->{HTTP_HOST}, $prefix);
($status, $content, $msg) = joyurl('', $env->{HTTP_HOST});
}
}