dotconf/bin/ix
2020-09-05 16:15:14 -06:00

33 lines
511 B
Perl
Executable File

#!/usr/bin/perl
use strict;
use warnings;
use OpenBSD::Pledge;
use OpenBSD::Unveil;
use HTTP::Tiny;
unveil("/", "") or die;
pledge(qw( stdio dns inet rpath )) or die;
my $http = HTTP::Tiny->new();
sub slurp {
my ($fh) = @_;
local $/;
<$fh>;
}
sub sprunge {
my ($input) = @_;
my $url = "http://ix.io";
my @form = ( 'f:1=<-' => $input );
my $resp = $http->post_form($url, \@form)
or die "could not POST: $!";
$resp->{content};
}
my $input = slurp('STDIN');
my $url = sprunge($input);
print $url;