gemini.sh - randomcrap - random crap programs of varying quality
 (HTM) git clone git://git.codemadness.org/randomcrap
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
       gemini.sh (638B)
       ---
            1 #!/bin/sh
            2 # fetch data via the gemini protocol, intended to view text pages.
            3 # Dependencies: netcat
            4 
            5 if test "$1" = ""; then
            6         echo "$0 <url>" >&2
            7         exit 1
            8 fi
            9 
           10 u=$(echo "$1" | sed 's@^gemini://@@g')
           11 host=$(echo "$u" | sed 's@/.*$@@g')
           12 port=$(echo "$host" | cut -s -d ':' -f 2)
           13 host=$(echo "$host" | cut -d ':' -f 1)
           14 
           15 test x"$port" = x"" && port="1965"
           16 
           17 # DEBUG
           18 #echo "host: $host"
           19 #echo "port: $port"
           20 #echo "path: $path"
           21 
           22 # OpenBSD netcat with (-c TLS connect) option.
           23 #printf '%s\r\n' "$1" | nc -c "$host" "$port"
           24 
           25 # use socat with OpenSSL protocol, !!!no peer verification!!!
           26 printf '%s\r\n' "$1" | socat - "OPENSSL:$host:$port,verify=0"