-- Leo's gemini proxy

-- Connecting to git.thebackupbox.net:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini

repo: geminiclient
action: blob
revision:
path_from: gemini-get
revision_from: refs/heads/master:
path_to:
revision_to:

git.thebackupbox.net

geminiclient

git://git.thebackupbox.net/geminiclient

blob of:

geminiclient

/ gemini-get

refs/heads/master:/gemini-get
 #!/usr/bin/env bash

 #printf "openssl s_client isn't working right. probably libressl version is borked.\n" >&2
 #printf "because of that, we're using ncat --ssl which might break because no SNI.\n" >&2

 if [ ! "$1" ];then
   printf "usage: gemini-get gemini:uri\n"
   printf '   or: gemini-get gemini-proxy:uri\n'
   printf "the output is to stdout and is in raw message/gemini format.\n"
   printf "any arguments after the first will be passed to openssl s_client.\n"
   printf "for example, to use a client cert: gemini-get gemini:uri -key ~/epoch.key.pem -cert ~/epoch.cert.pem\n"
   exit 1
 fi

 uri="$1"
 shift
 uri_minus_fragment="$(printf "%s\n" "$uri" | cut '-d#' -f1)"

 scheme="$(printf "%s\n" "$uri" | uricut -s)"

 host="$(printf "%s\n" "$uri" | uricut -d)"
 port="$(printf "%s\n" "$uri" | uricut -P)"

 if [ "$scheme" = "gemini-proxy" ];then
   uri="$(uriescape "$(uriunescape "$(printf "%s\n" "$uri" | uricut -p | cut -b2-)")")"
 fi

 if [ ! "$port" ];then
   port=1965
 fi

 printf '%s\r\n' "$uri_minus_fragment" \
   | openssl s_client "$@" -servername "$host" -ign_eof -quiet -connect "$host":"$port" \
  2>/dev/null
 #echo $?

-- Response ended

-- Page fetched on Sun Jun 2 10:48:14 2024