ProxyCheckEnabled detection draft

This commit is contained in:
perennial
2024-09-30 22:01:32 +10:00
parent c9649ff3fc
commit 74d60e549e
3 changed files with 28 additions and 3 deletions
+17
View File
@@ -81,6 +81,23 @@
proxy or one of the provided external proxy servers. If you prefer, you can
also specify a custom proxy server by entering its URL and clicking 'Save Changes'.
</p>
{{ if .ProxyCheckEnabled == false }}
<div class="alert alert-warning" role="alert">
<p>
<i class="bi bi-exclamation-triangle-fill"></i> This PixivFE instance has been configured to <span class="fw-bold">not</span> check the list of built-in image proxies (<a href="https://pixivfe-docs.pages.dev/hosting/environment-variables/#pixivfe_proxy_check_enabled" class="text-decoration-none"><code class="bg-dark-subtle rounded p-1">PIXIVFE_PROXY_CHECK_ENABLED=false</code></a> has been set).
</p>
<p class="mb-0">
All image proxies will be shown by default, regardless of their actual state.
</p>
</div>
{{- else -}}
<p>
This PixivFE instance has been configured to check the list of built-in image proxies every {{ .ProxyCheckInterval }}.
</p>
<p>
Image proxies that fail this check will not be shown unless "Show all proxy servers" is enabled.
</p>
{{- end -}}
<form action="/settings/imageServer" method="post">
<div class="mb-3 form-check form-switch">
<input class="form-check-input" type="checkbox" role="switch" id="show-all-proxies">
+6 -1
View File
@@ -169,7 +169,12 @@ func resetAll(w http.ResponseWriter, _ *http.Request) error {
}
func SettingsPage(w http.ResponseWriter, r *http.Request) error {
return RenderHTML(w, r, Data_settings{WorkingProxyList: proxy_checker.GetWorkingProxies(), ProxyList: config.BuiltinProxyList})
return RenderHTML(w, r, Data_settings{
WorkingProxyList: proxy_checker.GetWorkingProxies(),
ProxyList: config.BuiltinProxyList,
ProxyCheckEnabled: config.GlobalConfig.ProxyCheckEnabled, // Used to check whether proxy_checker is enabled on the instance
ProxyCheckInterval: config.GlobalConfig.ProxyCheckInterval, // Used to display the ProxyCheckInterval configured on the instance
})
}
func SettingsPost(w http.ResponseWriter, r *http.Request) error {
+5 -2
View File
@@ -6,6 +6,7 @@ import (
"codeberg.org/vnpower/pixivfe/v2/core"
"codeberg.org/vnpower/pixivfe/v2/server/request_context"
"codeberg.org/vnpower/pixivfe/v2/server/template"
"time"
)
func RenderHTML[T any](w http.ResponseWriter, r *http.Request, data T) error {
@@ -129,8 +130,10 @@ type Data_rankingCalendar struct {
ThisMonth DateWrap
}
type Data_settings struct {
ProxyList []string
WorkingProxyList []string
ProxyList []string
WorkingProxyList []string
ProxyCheckEnabled bool
ProxyCheckInterval time.Duration
}
type Data_tag struct {
Title string