Add [[wildcard]].fallback-insecure option to disable TLS verification.

This is intended for local deployments only.
This commit is contained in:
Catherine
2025-11-04 19:03:35 +00:00
parent 28c1b42167
commit 3c07ebccbf
2 changed files with 13 additions and 4 deletions

View File

@@ -52,10 +52,11 @@ type ServerConfig struct {
} }
type WildcardConfig struct { type WildcardConfig struct {
Domain string `toml:"domain"` Domain string `toml:"domain"`
CloneURL string `toml:"clone-url"` CloneURL string `toml:"clone-url"`
IndexRepos []string `toml:"index-repos" default:"[]"` IndexRepos []string `toml:"index-repos" default:"[]"`
FallbackProxyTo string `toml:"fallback-proxy-to"` FallbackProxyTo string `toml:"fallback-proxy-to"`
FallbackInsecure bool `toml:"fallback-insecure"`
} }
type CacheConfig struct { type CacheConfig struct {

View File

@@ -1,6 +1,7 @@
package git_pages package git_pages
import ( import (
"crypto/tls"
"fmt" "fmt"
"log" "log"
"net/http" "net/http"
@@ -17,6 +18,7 @@ type WildcardPattern struct {
CloneURL *fasttemplate.Template CloneURL *fasttemplate.Template
IndexRepos []*fasttemplate.Template IndexRepos []*fasttemplate.Template
FallbackURL *url.URL FallbackURL *url.URL
Insecure bool
} }
var wildcardPatterns []*WildcardPattern var wildcardPatterns []*WildcardPattern
@@ -61,6 +63,11 @@ func HandleWildcardFallback(w http.ResponseWriter, r *http.Request) (bool, error
r.Out.Host = r.In.Host r.Out.Host = r.In.Host
r.Out.Header["X-Forwarded-For"] = r.In.Header["X-Forwarded-For"] r.Out.Header["X-Forwarded-For"] = r.In.Header["X-Forwarded-For"]
}, },
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: pattern.Insecure,
},
},
}).ServeHTTP(w, r) }).ServeHTTP(w, r)
return true, nil return true, nil
@@ -99,6 +106,7 @@ func ConfigureWildcards(configs []WildcardConfig) error {
CloneURL: cloneURLTemplate, CloneURL: cloneURLTemplate,
IndexRepos: indexRepoTemplates, IndexRepos: indexRepoTemplates,
FallbackURL: fallbackURL, FallbackURL: fallbackURL,
Insecure: config.FallbackInsecure,
}) })
} }
return nil return nil