summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjake <jake@jakes-mail.top>2022-01-12 02:41:09 -0500
committerjake <jake@jakes-mail.top>2022-01-12 02:41:09 -0500
commit89f6639c84051362f6c1fe1ffda2d54fc104ac46 (patch)
tree743e84293a55ff4903e721827d652395dc9c7eed
Initial commit (v0.0.1)
-rwxr-xr-xgmi.pl33
1 files changed, 33 insertions, 0 deletions
diff --git a/gmi.pl b/gmi.pl
new file mode 100755
index 0000000..b16a178
--- /dev/null
+++ b/gmi.pl
@@ -0,0 +1,33 @@
+#!/usr/bin/perl
+
+# this is a gemini client
+
+use strict;
+use warnings;
+use utf8;
+use bytes;
+
+our $VERSION = '0.0.1';
+
+# Modules
+use IO::Socket::SSL; # CPAN
+use URL::XS qw(parse_url split_url_path parse_url_query); # CPAN
+
+# Global variables
+# ARGV[0]: gemini://website.com/request-path.gmi
+my $url = $ARGV[0];
+$url = parse_url($url);
+
+my $cl = IO::Socket::SSL->new(
+ PeerHost => "$url->{host}",
+ PeerPort => '1965',
+
+ SSL_verify_mode => SSL_VERIFY_NONE,
+ # will update version when support is better or
+ # when gemini removes TLSv1_2 as a supported version
+ SSL_version => 'TLSv1_2',
+
+) or die "error=$!, ssl_error=$SSL_ERROR";
+
+print $cl "$url->{scheme}://$url->{host}/$url->{path}\r\n";
+print <$cl>;