Compare commits
20 Commits
Author | SHA1 | Date |
---|---|---|
qorg11 | 8cf0922070 | |
qorg11 | 1ce7380466 | |
qorg11 | 34363928cc | |
Dustin Van Tate Testa | d23a85bac6 | |
qorg11 | c01d7cdc95 | |
qorg11 | f5967c88c0 | |
qorg11 | 47312a4d7c | |
qorg11 | 430df19608 | |
qorg11 | 4f70a9db11 | |
qorg11 | 5cf19efe6b | |
qorg11 | 32f9272595 | |
qorg11 | b3a6b70f31 | |
qorg11 | 68c721bfb6 | |
qorg11 | a13f7b3f7d | |
qorg11 | 3c6d911f24 | |
qorg11 | 7330c757e0 | |
qorg11 | 57dd53d582 | |
qorg11 | 9ad059a510 | |
qorg11 | b43a9155f1 | |
qorg11 | 911418aac5 |
|
@ -0,0 +1,4 @@
|
|||
install: lainsafecli
|
||||
cp lainsafecli /usr/bin/
|
||||
gzip -k doc/lainsafecli.1
|
||||
cp doc/lainsafecli.1.gz /usr/share/man/man1
|
33
README.MD
33
README.MD
|
@ -10,7 +10,26 @@
|
|||
|
||||
## lainsafecli
|
||||
|
||||
```lainsafecli``` is a simple interface for lainsafe.
|
||||
### Installation
|
||||
|
||||
#### Debian
|
||||
Lainsafe has official packages for Debian, they shold work for any
|
||||
dpkg-based distro, such as Ubuntu and so on
|
||||
|
||||
You can download a possible outdated deb package
|
||||
[here](http://repo.qorg11.net/debian/pool/main/l/lainsafecli/lainsafecli_0.3_all.deb)
|
||||
|
||||
If you want updates for your package, you have to add
|
||||
`repo.qorg11.net` to your sources.list:
|
||||
|
||||
~~~
|
||||
echo "deb http://repo.qorg11.net/debian stable main" >> /etc/apt/sources.list
|
||||
wget http://repo.qorg11.net/repo.key -q -O - | sudo apt-key add
|
||||
sudo apt updates
|
||||
sudo apt install lainsafecli
|
||||
~~~
|
||||
#### Arch
|
||||
[AUR - `lainsafecli`](https://aur.archlinux.org/packages/lainsafecli/)
|
||||
|
||||
### lainsafecli configuration
|
||||
|
||||
|
@ -29,12 +48,12 @@ Lain ascii art to appear when you upload a file.
|
|||
|
||||
```--help``` Displays a simple help message and exits.
|
||||
|
||||
```--file``` the file you want to upload
|
||||
```--file``` the file you want to upload (useless in newer versions)
|
||||
|
||||
### Example
|
||||
|
||||
~~~
|
||||
$ lainsafecli --server https://lainsafe.delegao.moe --file sicp.png
|
||||
$ lainsafecli --server https://lainsafe.delegao.moe sicp.png
|
||||
|
||||
|
||||
|
||||
|
@ -62,3 +81,11 @@ $ lainsafecli --server https://lainsafe.delegao.moe --file sicp.png
|
|||
https://lainsafe.delegao.moe/files/EWwEnBHk.png
|
||||
|
||||
~~~
|
||||
|
||||
# Donate
|
||||
|
||||
Thanks!
|
||||
|
||||
[Liberapay](https://liberapay.com/qorg11)
|
||||
|
||||
Bitcoin: bc1qghl6f27dpgktynpvkrxte2s3gm9pcv8vlwuzum
|
||||
|
|
40
doc/index.md
40
doc/index.md
|
@ -6,37 +6,43 @@
|
|||
|
||||
## Lainsafe installation
|
||||
|
||||
Just put index.html and upload.cgi in a http directory. I use fcgi to run my cgi scripts. So it's what i recommend. To install fcgi on debian, run: ```# apt install fcgiwrap```
|
||||
Just put index.html and upload.cgi in a HTTP directory. I use fcgi to run my cgi scripts. So it's what i recommend. To install fcgi on Debian, run: ```# apt install fcgiwrap```
|
||||
|
||||
here's an example configuration for lainsafe, using nginx.
|
||||
|
||||
~~~
|
||||
server
|
||||
{
|
||||
server_name lainsafe.foo.tld;
|
||||
server_name lainsafe.foo.tld;
|
||||
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
client_max_body_size 100m; # max size 100MBs, change 10 to 100 in upload.cgi in line 30
|
||||
root /var/www/lainsafe;
|
||||
|
||||
root /var/www/lainsafe;
|
||||
|
||||
location ~ \.cgi$ {
|
||||
gzip off;
|
||||
include /etc/nginx/fastcgi_params;
|
||||
fastcgi_pass unix:/var/run/fcgiwrap.socket;
|
||||
fastcgi_index index.cgi;
|
||||
fastcgi_param SCRIPT_FILENAME /var/www/lainsafe/$fastcgi_script_name;
|
||||
}
|
||||
location ~ \.cgi$ {
|
||||
gzip off;
|
||||
include /etc/nginx/fastcgi_params;
|
||||
fastcgi_pass unix:/var/run/fcgiwrap.socket;
|
||||
fastcgi_index index.cgi;
|
||||
fastcgi_param SCRIPT_FILENAME /var/www/lainsafe/$fastcgi_script_name;
|
||||
}
|
||||
}
|
||||
~~~
|
||||
|
||||
## lainsafecli
|
||||
|
||||
lainsafecli is a command line interface for lainsafe. It can be used in whatever that runs perl. Instalation is simple: if you're running debian install the libwww-perl package. If you are not running debian, search for that package in your repositories. Or use ```# cpan -i LWP::UserAgent```
|
||||
lainsafecli is a command line interface for lainsafe. It can be used
|
||||
in whatever that runs Perl. Installation is simple: if you're running
|
||||
Debian install the libwww-perl package. If you are not running Debian,
|
||||
search for that package in your repositories. Or use ```# cpan -i
|
||||
LWP::UserAgent``` Also LWP::UserAgent::https is needed. In Debian,
|
||||
install liblwp-protocol-https-perl, in other distros try # cpan -i
|
||||
LWP::UserAgent
|
||||
|
||||
### Installation
|
||||
|
||||
I haven't made a package for lainsafecli yet. So instalation is basically:
|
||||
I haven't made a package for lainsafecli yet. So installation is basically:
|
||||
|
||||
~~~
|
||||
# wget https://raw.githubusercontent.com/qorg11/lainsafe/master/lainsafecli \
|
||||
|
@ -56,7 +62,7 @@ These parameters are located in the line 34 of lainsafecli.
|
|||
```$DEFAULT_SERVER``` the server that will be used if --server is not
|
||||
specified.
|
||||
```$DISPLAY_ASCII``` By default is true, change to 0 if you don't want
|
||||
the Lain ascii art to appear when you upload a file.
|
||||
the Lain ASCII art to appear when you upload a file.
|
||||
|
||||
the most "official" lainsafe instance is <https://lainsafe.delegao.moe>.
|
||||
|
||||
|
@ -124,4 +130,4 @@ files through ```lainsafecli```.
|
|||
Only one parameter: ```$MAX_SIZE``` specify, in megabytes, the max size of files allowed. So for example. If you want to set 100MBs as max size . ```$MAX_SIZE``` would be like this: ```$MAX_SIZE = 1024*1024*100```
|
||||
|
||||
If someone tries to upload a file bigger than 100MBs. It will return
|
||||
Max size for a file is 100 MBs, then, uploda.cgi will die.
|
||||
Max size for a file is 100 MBs, then, upload.cgi will die.
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
.\" Manpage for lainsafecli.
|
||||
.TH lainsafecli 1
|
||||
.SH NAME
|
||||
lainsafecli \- Command line interface for lainsafe
|
||||
.SH SYNOPSIS
|
||||
lainsafecli
|
||||
.I
|
||||
[--server=server]
|
||||
file
|
||||
|
||||
.SH DESCRIPTION
|
||||
|
||||
.I lainsafecli
|
||||
uploads a file to a given lainsafe server. This server may
|
||||
be specified with the
|
||||
.I --server
|
||||
flag. If
|
||||
.I --server
|
||||
is not given. The content of the variable
|
||||
.I $DEFAULT_SERVER
|
||||
will be used instead. This variable is in the script. In the official
|
||||
packages. this is https://lainsafe.delegao.moe
|
||||
|
||||
.SH OPTIONS
|
||||
|
||||
.I --server
|
||||
Sets the server to use. If it is not given $DEFAULT_SERVER will be used instead.
|
||||
|
||||
.I --help
|
||||
Displays a simple help message and exits. This also specify which
|
||||
server will be used if no
|
||||
.I --server
|
||||
is given.
|
||||
|
||||
.SH TROUBLESHOOTING
|
||||
|
||||
.B "whatever" is not running lainsafe. But works in the browser.
|
||||
|
||||
This only happens with https lainsafe instances. To solve that. Make
|
||||
sure that the module
|
||||
.I LWP::UserAgent::https
|
||||
is installed. You can install it using
|
||||
.I cpan(1)
|
||||
|
||||
.B HTTP 413 is returned
|
||||
|
||||
The file you specified is too big for the instance. Try using another
|
||||
instance. By default lainsafe supports up to 100MBs. But this can be configured in lainsafe
|
||||
.B AND
|
||||
the web server. If the file exceds whatever your
|
||||
.B server
|
||||
allows. lainsafe can set another limit. If the lainsafe limit is less
|
||||
than the server limit. lainsafe will return its own error message.
|
||||
|
||||
.SH AUTHORS
|
||||
|
||||
qorg11 <qorg@vxempire.xyz>
|
||||
|
||||
.SH LICENSE
|
||||
|
||||
GPLv3 or later.
|
|
@ -14,11 +14,13 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# along with lainsafe. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
my $disk_size = `df -h | awk 'NR==2 {print \$2; exit}'`;
|
||||
my $disk_usage = `df -h | awk 'NR==2 {print \$3; exit}')`;
|
||||
my $disk_size = `df -h | awk 'NR==2 {print \$2; exit}'`;
|
||||
my $disk_usage = `df -h | awk 'NR==2 {print \$3; exit}'`;
|
||||
my $disk_free = `df -h | awk 'NR==2 {print \$4; exit}'`;
|
||||
my $disk_percentage = `df -h | awk 'NR==2 {print \$5; exit}'`;
|
||||
|
||||
print "Content-type: text/html\n\n";
|
||||
|
||||
print "<!DOCTYPE html>
|
||||
<html lang=\"en\">
|
||||
<head>
|
||||
|
@ -34,6 +36,7 @@ print "<!DOCTYPE html>
|
|||
<input type='file' name='file' size='30'>
|
||||
<input type='submit' value='upload'>
|
||||
</form>
|
||||
<a href='https://github.com/qorg11/lainsafe'>star me</a>
|
||||
|
||||
|
||||
</body>
|
||||
|
|
|
@ -27,8 +27,9 @@ $size = $ENV{CONTENT_LENGTH};
|
|||
|
||||
# Configuration
|
||||
|
||||
$MAX_SIZE = 1024*1024*10; # Change for your size
|
||||
$MAX_SIZE_MB = $MAX_SIZE / 1024 / 1024; # Don't change this
|
||||
our $MAX_SIZE = 1024*1024*10; # Change for your size
|
||||
our $MAX_SIZE_MB = $MAX_SIZE / 1024 / 1024; # Don't change this
|
||||
our @not_allowed_extensions = qw(sh out exe);
|
||||
|
||||
if($filename eq "")
|
||||
{
|
||||
|
@ -45,20 +46,43 @@ if($size > $MAX_SIZE)
|
|||
my $extension = $filename;
|
||||
$extension =~ s/.*\.//; # tar.gz sucks with this
|
||||
|
||||
# Generate random string
|
||||
my @chars = ("A".."Z", "a".."z");
|
||||
my $string;
|
||||
$string .= $chars[rand @chars] for 1..8;
|
||||
|
||||
my $upload_filehandle = $q->upload("file");
|
||||
|
||||
$filename = $string . "." . $extension;
|
||||
my $allowed_extension = 1;
|
||||
|
||||
open(FILE,">$upload_dir/$filename");
|
||||
binmode(FILE);
|
||||
while(<$upload_filehandle>)
|
||||
foreach(@not_allowed_extensions)
|
||||
{
|
||||
print FILE;
|
||||
if($filename =~ /\.$_$/i)
|
||||
{
|
||||
$allowed_extension = 0;
|
||||
last;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
close FILE;
|
||||
if($allowed_extension)
|
||||
{
|
||||
|
||||
print $ENV{HTTP_REFERER} . "$upload_dir$filename";
|
||||
open(FILE,">$upload_dir/$filename");
|
||||
binmode(FILE);
|
||||
|
||||
while(<$upload_filehandle>)
|
||||
{
|
||||
print FILE;
|
||||
}
|
||||
|
||||
close FILE;
|
||||
|
||||
print $ENV{HTTP_REFERER} . "$upload_dir$filename";
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
print "The file extension .$extension is not allowed in this instance.";
|
||||
}
|
||||
|
|
23
lainsafecli
23
lainsafecli
|
@ -28,14 +28,13 @@ my $help;
|
|||
my $DEFAULT_SERVER;
|
||||
my $file;
|
||||
my $DISPLAY_ASCII;
|
||||
|
||||
my $STORE_LINKS;
|
||||
# Default options, if no specified.
|
||||
$DEFAULT_SERVER = "https://lainsafe.delegao.moe";
|
||||
$DISPLAY_ASCII = 1; # 0 if you don't want the ascii
|
||||
|
||||
$STORE_LINKS = 1; # 0 if you don't want to keep track of your upload
|
||||
|
||||
my $ASCII_ART = <<'EOF';
|
||||
|
||||
|
||||
_..-- ----- --.._
|
||||
,-'' `-.
|
||||
, \
|
||||
|
@ -86,10 +85,6 @@ $file = $ARGV[@ARGV-1];
|
|||
|
||||
die "File does not exist\n" if !-e $file;
|
||||
|
||||
die "Give a file\n" unless defined $file;
|
||||
|
||||
|
||||
|
||||
my $url_to_upload = $DEFAULT_SERVER . "/upload.cgi";
|
||||
my $req;
|
||||
|
||||
|
@ -114,4 +109,16 @@ $req = $ua->post($url_to_upload,
|
|||
|
||||
|
||||
print $ASCII_ART if $DISPLAY_ASCII;
|
||||
if($req->{_content} =~ /instance/) # If someone knows how to do it another way, I'm all ears
|
||||
{
|
||||
print $req->{_content} . "\n";
|
||||
exit;
|
||||
}
|
||||
print $DEFAULT_SERVER . "/" . $req->{_content} . "\n";
|
||||
|
||||
if($STORE_LINKS)
|
||||
{
|
||||
open FILE,'>>',"$ENV{HOME}/.cache/lainsafelinks" or die $!;
|
||||
print FILE $DEFAULT_SERVER . "/" . $req->{_content} . " $file" ."\n";
|
||||
close FILE;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue