mirror of
https://github.com/makeworld-the-better-one/amfora.git
synced 2024-09-11 14:55:51 +03:00
🐛 Make TOFU warning accurate when proxy enabled
This commit is contained in:
parent
b37af27b80
commit
3dfbeb5bda
@ -4,6 +4,7 @@ package client
|
||||
import (
|
||||
"net/url"
|
||||
|
||||
"github.com/makeworld-the-better-one/amfora/config"
|
||||
"github.com/makeworld-the-better-one/go-gemini"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
@ -14,7 +15,7 @@ func Fetch(u string) (*gemini.Response, error) {
|
||||
var res *gemini.Response
|
||||
var err error
|
||||
|
||||
if viper.GetString("a-general.proxy") == "" {
|
||||
if config.Proxy == nil {
|
||||
res, err = gemini.Fetch(u)
|
||||
} else {
|
||||
res, err = gemini.FetchWithHost(viper.GetString("a-general.proxy"), u)
|
||||
|
@ -2,6 +2,7 @@ package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
@ -30,6 +31,8 @@ var bkmkPath string
|
||||
|
||||
var DownloadsDir string
|
||||
|
||||
var Proxy *url.URL
|
||||
|
||||
//nolint:golint,goerr113
|
||||
func Init() error {
|
||||
home, err := homedir.Dir()
|
||||
@ -156,6 +159,7 @@ func Init() error {
|
||||
viper.SetDefault("a-general.page_max_size", 2097152)
|
||||
viper.SetDefault("a-general.page_max_time", 10)
|
||||
viper.SetDefault("a-general.emoji_favicons", false)
|
||||
viper.SetDefault("a-general.proxy", "")
|
||||
viper.SetDefault("keybindings.shift_numbers", "!@#$%^&*()")
|
||||
viper.SetDefault("url-handlers.other", "off")
|
||||
viper.SetDefault("cache.max_size", 0)
|
||||
@ -168,6 +172,8 @@ func Init() error {
|
||||
return err
|
||||
}
|
||||
|
||||
Proxy, _ = url.Parse(viper.GetString("a-general.proxy"))
|
||||
|
||||
// Setup downloads dir
|
||||
if viper.GetString("a-general.downloads") == "" {
|
||||
// Find default Downloads dir
|
||||
|
@ -360,13 +360,25 @@ func handleURL(t *tab, u string, numRedirects int) (string, bool) {
|
||||
}
|
||||
|
||||
if errors.Is(err, client.ErrTofu) {
|
||||
if Tofu(parsed.Host, client.GetExpiry(parsed.Hostname(), parsed.Port())) {
|
||||
// They want to continue anyway
|
||||
client.ResetTofuEntry(parsed.Hostname(), parsed.Port(), res.Cert)
|
||||
// Response can be used further down, no need to reload
|
||||
if config.Proxy == nil {
|
||||
if Tofu(parsed.Host, client.GetExpiry(parsed.Hostname(), parsed.Port())) {
|
||||
// They want to continue anyway
|
||||
client.ResetTofuEntry(parsed.Hostname(), parsed.Port(), res.Cert)
|
||||
// Response can be used further down, no need to reload
|
||||
} else {
|
||||
// They don't want to continue
|
||||
return ret("", false)
|
||||
}
|
||||
} else {
|
||||
// They don't want to continue
|
||||
return ret("", false)
|
||||
// They are using a proxy
|
||||
if Tofu(config.Proxy.Host, client.GetExpiry(config.Proxy.Hostname(), config.Proxy.Port())) {
|
||||
// They want to continue anyway
|
||||
client.ResetTofuEntry(config.Proxy.Hostname(), config.Proxy.Port(), res.Cert)
|
||||
// Response can be used further down, no need to reload
|
||||
} else {
|
||||
// They don't want to continue
|
||||
return ret("", false)
|
||||
}
|
||||
}
|
||||
} else if err != nil {
|
||||
Error("URL Fetch Error", err.Error())
|
||||
|
Loading…
Reference in New Issue
Block a user