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 {
Domain string `toml:"domain"`
CloneURL string `toml:"clone-url"`
IndexRepos []string `toml:"index-repos" default:"[]"`
FallbackProxyTo string `toml:"fallback-proxy-to"`
Domain string `toml:"domain"`
CloneURL string `toml:"clone-url"`
IndexRepos []string `toml:"index-repos" default:"[]"`
FallbackProxyTo string `toml:"fallback-proxy-to"`
FallbackInsecure bool `toml:"fallback-insecure"`
}
type CacheConfig struct {

View File

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