Added support for i2p, completely useless since there aren't any i2p

lainsafe instances. but okay
This commit is contained in:
qorg11 2020-09-04 19:31:01 +02:00
parent 82061f08fb
commit 8ea7f1159f
No known key found for this signature in database
GPG Key ID: 343FC20A4ACA62B9
1 changed files with 24 additions and 11 deletions

View File

@ -24,20 +24,21 @@ use warnings;
# variables # variables
my $help; my $help;
my $tor; my $tor;
my $i2p;
my $get_response; my $get_response;
my $DEFAULT_SERVER; my $DEFAULT_SERVER;
my $file; my $file;
my $DISPLAY_ASCII; my $DISPLAY_ASCII;
my $STORE_LINKS; my $STORE_LINKS;
my $LINKS_FILE; my $LINKS_FILE;
my $tor_enabled = 1; my $proxy_enabled = 1;
# Default options, if no specified. # Default options, if no specified.
$DEFAULT_SERVER = "https://lainsafe.duckdns.org"; $DEFAULT_SERVER = "https://lainsafe.duckdns.org";
$DISPLAY_ASCII = 1; # 0 if you don't want the ascii $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 $STORE_LINKS = 1; # 0 if you don't want to keep track of your upload
$LINKS_FILE = "$ENV{HOME}/.cache/lainsafelinks"; $LINKS_FILE = "$ENV{HOME}/.cache/lainsafelinks";
eval "use LWP::Protocol::socks; 1" or $tor_enabled = 0; eval "use LWP::Protocol::socks; 1" or $proxy_enabled = 0;
my $ASCII_ART = <<'EOF'; my $ASCII_ART = <<'EOF';
_..-- ----- --.._ _..-- ----- --.._
,-'' `-. ,-'' `-.
@ -67,10 +68,10 @@ EOF
sub help sub help
{ {
print "lainsafecli, a command line interface for lainsafe.\n"; print "lainsafecli, a command line interface for lainsafe.\n";
print "USAGE: lainsafecli [--tor] [--server] FILE\n\n"; print "USAGE: lainsafecli [--tor | --i2p] [--server] FILE\n\n";
print "if --server not given, $DEFAULT_SERVER is used.\n"; print "if --server not given, $DEFAULT_SERVER is used.\n";
print "--tor is available\n" if $tor_enabled; print "--tor and --i2p are available\n" if $proxy_enabled;
print "--tor is unavailable, flag is ignored\n" unless $tor_enabled; print "--tor and --i2p are unavailable, flag are ignored\n" unless $proxy_enabled;
exit; exit;
} }
@ -79,16 +80,27 @@ sub enable_tor
my $checker = $ua->proxy([qw(http https)] => 'socks://localhost:9050'); my $checker = $ua->proxy([qw(http https)] => 'socks://localhost:9050');
} }
sub enable_i2p
{
my $checker = $ua->proxy([qw(http https)] => 'socks://localhost:4444');
}
## PROGRAM ## PROGRAM
GetOptions ("server=s" => \$DEFAULT_SERVER, GetOptions ("server=s" => \$DEFAULT_SERVER,
"help|" => \$help, "help|" => \$help,
"tor"=> \$tor, "tor"=> \$tor,
"i2p"=>\$i2p,
"get-response"=>\$get_response "get-response"=>\$get_response
); );
&help if $help || not defined $ARGV[0]; &help if $help || not defined $ARGV[0];
&enable_tor if $tor and $tor_enabled; if ($i2p and $tor) {
print "What are you trying to do? I don't really get you sometimes...\n";
exit;
}
&enable_tor if $tor and $proxy_enabled;
&enable_i2p if $i2p and $proxy_enabled;
# check if file is given # check if file is given
@ -113,11 +125,11 @@ if (!$ua->get($url_to_upload)->is_success) {
$req = $ua->post($url_to_upload, $req = $ua->post($url_to_upload,
Content_Type => 'form-data', Content_Type => 'form-data',
Content => [ Content => [
"file" => [ $file ], "file" => [ $file ],
], ],
); );
print $ASCII_ART if $DISPLAY_ASCII; print $ASCII_ART if $DISPLAY_ASCII;
@ -133,3 +145,4 @@ if ($STORE_LINKS) {
print FILE $req->{_content} . " $file" ."\n"; print FILE $req->{_content} . " $file" ."\n";
close FILE; close FILE;
} }
print $i2p;