dotconf/bin/ix

36 lines
584 B
Plaintext
Raw Permalink Normal View History

#!/usr/bin/perl
use strict;
use warnings;
2021-01-24 08:08:39 -07:00
use HTTP::Tiny;
2021-01-24 08:08:39 -07:00
if ($^O eq "openbsd") {
require OpenBSD::Pledge;
require OpenBSD::Unveil;
2021-02-09 07:44:13 -07:00
OpenBSD::Unveil::unveil("/", "") or die;
OpenBSD::Pledge::pledge(qw( stdio dns inet rpath )) or die;
2021-01-24 08:08:39 -07:00
}
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;