try each default branch instead of 'pages' only

This commit is contained in:
Simon Vieille 2022-08-16 15:58:22 +02:00
parent dc634287aa
commit 9c412966fc
No known key found for this signature in database
GPG key ID: 579388D585F70417
2 changed files with 33 additions and 23 deletions

View file

@ -48,6 +48,7 @@ func Serve(ctx *cli.Context) error {
giteaAPIToken := ctx.String("gitea-api-token")
rawDomain := ctx.String("raw-domain")
mainDomainSuffix := []byte(ctx.String("pages-domain"))
defaultBranches := strings.Split(strings.ReplaceAll(ctx.String("pages-branches"), " ", ""), ",")
rawInfoPage := ctx.String("raw-info-page")
listeningAddress := fmt.Sprintf("%s:%s", ctx.String("host"), ctx.String("port"))
enableHTTPServer := ctx.Bool("enable-http-server")
@ -73,6 +74,10 @@ func Serve(ctx *cli.Context) error {
mainDomainSuffix = append([]byte{'.'}, mainDomainSuffix...)
}
if len(defaultBranches) == 0 {
defaultBranches = []string{"pages"}
}
keyCache := cache.NewKeyValueCache()
challengeCache := cache.NewKeyValueCache()
// canonicalDomainCache stores canonical domains
@ -95,7 +100,9 @@ func Serve(ctx *cli.Context) error {
giteaClient,
giteaRoot, rawInfoPage,
BlacklistedPaths, allowedCorsDomains,
dnsLookupCache, canonicalDomainCache, branchTimestampCache, fileResponseCache)
dnsLookupCache, canonicalDomainCache, branchTimestampCache, fileResponseCache,
defaultBranches,
)
fastServer := server.SetupServer(handler)
httpServer := server.SetupHTTPACMEChallengeServer(challengeCache)