diff --git a/README.md b/README.md index 37d783e..6aa7782 100644 --- a/README.md +++ b/README.md @@ -97,6 +97,9 @@ Features in *italics* are in the master branch, but not in the latest release. - [x] Theming - [x] *Emoji favicons* - See `gemini://mozz.us/files/rfc_gemini_favicon.gmi` for details +- [x] *Proxying* + - All requests can optionally be sent through another server + - A gemini proxy server implementation currently does not exist, but Amfora will support it when it does! - [ ] Subscribe to RSS and Atom feeds and display them - Subscribing to page changes, similar to how Spacewalk works, will also be supported - *In progress on `feeds` branch* diff --git a/client/client.go b/client/client.go index e9a4fdf..eba7205 100644 --- a/client/client.go +++ b/client/client.go @@ -5,12 +5,20 @@ import ( "net/url" "github.com/makeworld-the-better-one/go-gemini" + "github.com/spf13/viper" ) // Fetch returns response data and an error. // The error text is human friendly and should be displayed. func Fetch(u string) (*gemini.Response, error) { - res, err := gemini.Fetch(u) + var res *gemini.Response + var err error + + if viper.GetString("a-general.proxy") == "" { + res, err = gemini.Fetch(u) + } else { + res, err = gemini.FetchWithHost(viper.GetString("a-general.proxy"), u) + } if err != nil { return nil, err } diff --git a/config/default.go b/config/default.go index 572716f..8f68590 100644 --- a/config/default.go +++ b/config/default.go @@ -55,6 +55,13 @@ page_max_time = 10 # Whether to replace tab numbers with emoji favicons, which are cached. emoji_favicons = false +# Proxy server, through which all requests would be sent. +# String should be a host: a domain/IP with an optional port. Port 1965 is assumed otherwise. +# The proxy server needs to be a Gemini server that supports proxying. +# By default it is empty, which disables the proxy. +proxy = "" + + [keybindings] # In the future there will be more settings here. @@ -154,4 +161,5 @@ max_pages = 30 # The maximum number of pages the cache will store # bkmk_modal_text # bkmk_modal_label # bkmk_modal_field_bg -# bkmk_modal_field_text`) +# bkmk_modal_field_text +`) diff --git a/default-config.toml b/default-config.toml index c304bf7..272f381 100644 --- a/default-config.toml +++ b/default-config.toml @@ -52,6 +52,13 @@ page_max_time = 10 # Whether to replace tab numbers with emoji favicons, which are cached. emoji_favicons = false +# Proxy server, through which all requests would be sent. +# String should be a host: a domain/IP with an optional port. Port 1965 is assumed otherwise. +# The proxy server needs to be a Gemini server that supports proxying. +# By default it is empty, which disables the proxy. +proxy = "" + + [keybindings] # In the future there will be more settings here. @@ -151,4 +158,4 @@ max_pages = 30 # The maximum number of pages the cache will store # bkmk_modal_text # bkmk_modal_label # bkmk_modal_field_bg -# bkmk_modal_field_text \ No newline at end of file +# bkmk_modal_field_text