1
0
Fork 0

Proxy support

This commit is contained in:
makeworld 2020-08-27 22:40:40 -04:00
parent 11c3b1fec9
commit 164ed98588
4 changed files with 29 additions and 3 deletions

View File

@ -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*

View File

@ -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
}

View File

@ -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
`)

View File

@ -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
# bkmk_modal_field_text