diff --git a/README.md b/README.md index 6ba98f3..c2698e4 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ BFG (stands for Back/Forward/Go) is a free (absolutely), open-source, cross-platform, single-script, self-contained GUI client for a number of "small web" protocols like Gopher, Finger, Nex, Spartan and Gemini. BFG is written in under 1000 SLOC of Tcl 8.6 and depends upon Tcllib, Tk (obviously) and TclTLS. +The TclTLS dependency can be turned off in the configuration file at the expense of losing Gemini and Gopher-over-TLS support If you found any bugs, feel free to submit an issue into this repo! @@ -33,6 +34,7 @@ The following features are already (fully or partially) supported in BFG. * Dynamic window title based on the current URL * In-page text search * Ini-based customization of the current Ttk theme, content fonts and colors +* Non-TLS mode for systems without TclTLS support ## Non-supported features @@ -108,7 +110,7 @@ The following mouse bindings are currently supported: BFG ships with a `bfg.ini` file that holds your configuration values and bookmarks. The main configuration sections are: -* `[net]`: network-related configs, currently only has "timeout" parameter +* `[net]`: network-related configs, currently has "timeout" parameter and an optional "tls" parameter * `[widget]`: general UI widget appearance (ttkTheme, font (button font), entryfont, statusfont) * `[style.general]`: general content area appearance (textfont, monofont\*, foreground color, background color) * `[style.link.normal]`: normal link colors (foreground, background) @@ -177,6 +179,11 @@ The [Scroll protocol](gemini://scrollprotocol.us.to/) is essentially advertised Due to a purely technical limitation of the Gopher protocol (or rather the Gophermap format) itself, we cannot determine if a particular Gophermap entry points to a plain Gopher or a Gopher-over-TLS resource. Hence, only the links belonging to the same host/port pair that was already opened with a `gophers://` link are displayed as `gophers://` links. Everything else needs to be adjusted manually for now. Sorry for the inconvenience. +### My system (or Tclkit) doesn't have TclTLS available, can I still use BFG for plaintext protocols? + +Sure! Just supply `tls=off` (or `0`, or `none`) in the `[net]` section of the `bfg.ini` file. +You'll lose the ability to browse Gemini and Gopher-over-TLS resources but other protocols will be fully functional. + ## Credits Created by Luxferre in 2024, released into the public domain. diff --git a/bfg.ini b/bfg.ini index 194bf2f..b31c879 100644 --- a/bfg.ini +++ b/bfg.ini @@ -38,6 +38,7 @@ foreground=red [net] timeout=5000 +tls=on [style.highlight] background=yellow diff --git a/bfg.tcl b/bfg.tcl index c32a7b6..3e2a133 100755 --- a/bfg.tcl +++ b/bfg.tcl @@ -6,7 +6,6 @@ # created by Luxferre in 2024, released into public domain package require uri -package require tls package require inifile package require Tk @@ -43,6 +42,7 @@ set bfg_highlight_fgcolor $bfg_main_fgcolor set bfg_highlight_bgcolor yellow set bfg_error_fgcolor red set bfg_error_bgcolor $bfg_main_bgcolor +set bfg_tls_support 1 # read configuration from ini set confini "" @@ -52,6 +52,8 @@ set bookmarks "" if {$confini ne ""} { set val [::ini::value $confini net timeout $bfg_net_timeout] if {$val ne ""} {set bfg_net_timeout $val} + set val [::ini::value $confini net tls "on"] + if {$val ne ""} {set bfg_tls_support $val} set val [::ini::value $confini widget ttkTheme $bfg_theme] if {$val ne ""} {set bfg_theme $val} set val [::ini::value $confini widget font $bfg_widgetfont] @@ -106,6 +108,16 @@ if {$confini ne ""} { ::ini::close $confini } +# load TLS support +if {($bfg_tls_support eq "off") || ($bfg_tls_support eq "false" || ($bfg_tls_support eq "none"))} { + set bfg_tls_support 0 +} else { + set bfg_tls_support 1 +} +if {$bfg_tls_support eq 1} { + package require tls +} + # generate fonts foreach fid {widget entry status text mono} { set vname [string cat bfg_ $fid font] @@ -392,6 +404,7 @@ proc extOpen {url} { # common URL downloader # return the contents in $bfg_response proc urldl {inputurl isbinary} { + global bfg_tls_support bfg_response set parts [url2dict $inputurl] set host [dict get $parts host] set port [dict get $parts port] @@ -399,8 +412,18 @@ proc urldl {inputurl isbinary} { set selector [dict get $parts selector] set scheme [dict get $parts scheme] set is_tls 0 - if {$scheme eq "gemini"} {set is_tls 1} - if {$scheme eq "gophers"} {set is_tls 1} + if {($scheme eq "gemini") || ($scheme eq "gophers")} { + if {$bfg_tls_support eq 0} { # report unsupported content + set errmsg {BFG error: TLS support is turned off in the configuration} + if {$scheme eq "gemini"} { + set bfg_response [string cat "50 " $errmsg "\r\n"] + } + if {$scheme eq "gophers"} { + set bfg_response [string cat "3" $errmsg "\t-\t-\t-\r\n"] + } + return $scheme + } else {set is_tls 1} + } set encoding "utf-8" if {$isbinary eq 1} {set encoding "binary"} reqresp $host $port $selector $is_tls $encoding