Compare commits

...

20 Commits
v0.3 ... master

Author SHA1 Message Date
qorg11 8cf0922070
Added $STORE_LINKS (line 35) which allows the user to echo the
download links on a file "~/.cache/lainsafelinks" and the file name,
so the user can keep track of the files they have uploaded to the
servers.
2020-08-06 22:52:50 +02:00
qorg11 1ce7380466
Merge branch 'master' of github.com:qorg11/lainsafe 2020-07-11 22:33:17 +02:00
qorg11 34363928cc
Updated bitcoin address 2020-07-11 22:30:11 +02:00
Dustin Van Tate Testa d23a85bac6
add aur package to readme (#8) 2020-07-11 05:33:41 +02:00
qorg11 c01d7cdc95
Added donation stuff 2020-07-05 02:16:34 +02:00
qorg11 f5967c88c0
Fix indendation in http/upload.cgi 2020-07-01 17:50:58 +02:00
qorg11 47312a4d7c
Deleted useless lines of code 2020-06-30 00:11:27 +02:00
qorg11 430df19608
Now you can tell the shit which file extensions you can't upload 2020-06-30 00:05:55 +02:00
qorg11 4f70a9db11
Fixed typo in README.MD 2020-06-29 22:48:30 +02:00
qorg11 5cf19efe6b
Packages installation 2020-06-29 22:47:44 +02:00
qorg11 32f9272595
Added git repo in the bottom of the site 2020-06-26 04:45:26 +02:00
qorg11 b3a6b70f31
Created makefile and fix shit on the manpage 2020-06-24 22:36:03 +02:00
qorg11 68c721bfb6
Some fixes to the manual 2020-06-24 06:40:46 +02:00
qorg11 a13f7b3f7d
whoops 2020-06-24 06:38:30 +02:00
qorg11 3c6d911f24
Added lainsafecli manual 2020-06-24 06:36:36 +02:00
qorg11 7330c757e0
Recommend installing LWP::UserAgent::https 2020-06-21 16:19:26 +02:00
qorg11 57dd53d582
Edited readme.md (--file is useless in newer versions) 2020-06-07 01:59:20 +02:00
qorg11 9ad059a510
Whoops 2020-05-12 17:20:01 +02:00
qorg11 b43a9155f1
Fixed typos and improved docs 2020-05-12 17:17:20 +02:00
qorg11 911418aac5
My mistake 2020-05-12 03:21:45 +02:00
7 changed files with 170 additions and 38 deletions

4
Makefile Normal file
View File

@ -0,0 +1,4 @@
install: lainsafecli
cp lainsafecli /usr/bin/
gzip -k doc/lainsafecli.1
cp doc/lainsafecli.1.gz /usr/share/man/man1

View File

@ -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

View File

@ -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.

61
doc/lainsafecli.1 Normal file
View File

@ -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.

View File

@ -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>

View File

@ -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.";
}

View File

@ -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;
}