Implemented an option to turn off TLS support

This commit is contained in:
Luxferre
2024-10-08 11:55:44 +03:00
parent f558616122
commit bf5c6b1db8
3 changed files with 35 additions and 4 deletions
+8 -1
View File
@@ -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 (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. 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! 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 * Dynamic window title based on the current URL
* In-page text search * In-page text search
* Ini-based customization of the current Ttk theme, content fonts and colors * Ini-based customization of the current Ttk theme, content fonts and colors
* Non-TLS mode for systems without TclTLS support
## Non-supported features ## 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. BFG ships with a `bfg.ini` file that holds your configuration values and bookmarks.
The main configuration sections are: 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) * `[widget]`: general UI widget appearance (ttkTheme, font (button font), entryfont, statusfont)
* `[style.general]`: general content area appearance (textfont, monofont\*, foreground color, background color) * `[style.general]`: general content area appearance (textfont, monofont\*, foreground color, background color)
* `[style.link.normal]`: normal link colors (foreground, background) * `[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. 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 ## Credits
Created by Luxferre in 2024, released into the public domain. Created by Luxferre in 2024, released into the public domain.
+1
View File
@@ -38,6 +38,7 @@ foreground=red
[net] [net]
timeout=5000 timeout=5000
tls=on
[style.highlight] [style.highlight]
background=yellow background=yellow
+26 -3
View File
@@ -6,7 +6,6 @@
# created by Luxferre in 2024, released into public domain # created by Luxferre in 2024, released into public domain
package require uri package require uri
package require tls
package require inifile package require inifile
package require Tk package require Tk
@@ -43,6 +42,7 @@ set bfg_highlight_fgcolor $bfg_main_fgcolor
set bfg_highlight_bgcolor yellow set bfg_highlight_bgcolor yellow
set bfg_error_fgcolor red set bfg_error_fgcolor red
set bfg_error_bgcolor $bfg_main_bgcolor set bfg_error_bgcolor $bfg_main_bgcolor
set bfg_tls_support 1
# read configuration from ini # read configuration from ini
set confini "" set confini ""
@@ -52,6 +52,8 @@ set bookmarks ""
if {$confini ne ""} { if {$confini ne ""} {
set val [::ini::value $confini net timeout $bfg_net_timeout] set val [::ini::value $confini net timeout $bfg_net_timeout]
if {$val ne ""} {set bfg_net_timeout $val} 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] set val [::ini::value $confini widget ttkTheme $bfg_theme]
if {$val ne ""} {set bfg_theme $val} if {$val ne ""} {set bfg_theme $val}
set val [::ini::value $confini widget font $bfg_widgetfont] set val [::ini::value $confini widget font $bfg_widgetfont]
@@ -106,6 +108,16 @@ if {$confini ne ""} {
::ini::close $confini ::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 # generate fonts
foreach fid {widget entry status text mono} { foreach fid {widget entry status text mono} {
set vname [string cat bfg_ $fid font] set vname [string cat bfg_ $fid font]
@@ -392,6 +404,7 @@ proc extOpen {url} {
# common URL downloader # common URL downloader
# return the contents in $bfg_response # return the contents in $bfg_response
proc urldl {inputurl isbinary} { proc urldl {inputurl isbinary} {
global bfg_tls_support bfg_response
set parts [url2dict $inputurl] set parts [url2dict $inputurl]
set host [dict get $parts host] set host [dict get $parts host]
set port [dict get $parts port] set port [dict get $parts port]
@@ -399,8 +412,18 @@ proc urldl {inputurl isbinary} {
set selector [dict get $parts selector] set selector [dict get $parts selector]
set scheme [dict get $parts scheme] set scheme [dict get $parts scheme]
set is_tls 0 set is_tls 0
if {$scheme eq "gemini"} {set is_tls 1} if {($scheme eq "gemini") || ($scheme eq "gophers")} {
if {$scheme eq "gophers"} {set is_tls 1} 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" set encoding "utf-8"
if {$isbinary eq 1} {set encoding "binary"} if {$isbinary eq 1} {set encoding "binary"}
reqresp $host $port $selector $is_tls $encoding reqresp $host $port $selector $is_tls $encoding