loading up the forgejo repo on tangled to test page performance
at forgejo 1.6 kB view raw
1// Copyright 2021 The Gitea Authors. All rights reserved. 2// SPDX-License-Identifier: MIT 3 4package setting 5 6import ( 7 "forgejo.org/modules/log" 8 9 "github.com/42wim/httpsig" 10) 11 12// Federation settings 13var ( 14 Federation = struct { 15 Enabled bool 16 ShareUserStatistics bool 17 MaxSize int64 18 SignatureAlgorithms []string 19 DigestAlgorithm string 20 GetHeaders []string 21 PostHeaders []string 22 SignatureEnforced bool 23 }{ 24 Enabled: false, 25 ShareUserStatistics: true, 26 MaxSize: 4, 27 SignatureAlgorithms: []string{"rsa-sha256", "rsa-sha512", "ed25519"}, 28 DigestAlgorithm: "SHA-256", 29 GetHeaders: []string{"(request-target)", "Date", "Host"}, 30 PostHeaders: []string{"(request-target)", "Date", "Host", "Digest"}, 31 SignatureEnforced: true, 32 } 33) 34 35// HttpsigAlgs is a constant slice of httpsig algorithm objects 36var HttpsigAlgs []httpsig.Algorithm 37 38func loadFederationFrom(rootCfg ConfigProvider) { 39 if err := rootCfg.Section("federation").MapTo(&Federation); err != nil { 40 log.Fatal("Failed to map Federation settings: %v", err) 41 } else if !httpsig.IsSupportedDigestAlgorithm(Federation.DigestAlgorithm) { 42 log.Fatal("unsupported digest algorithm: %s", Federation.DigestAlgorithm) 43 return 44 } 45 46 // Get MaxSize in bytes instead of MiB 47 Federation.MaxSize = 1 << 20 * Federation.MaxSize 48 49 HttpsigAlgs = make([]httpsig.Algorithm, len(Federation.SignatureAlgorithms)) 50 for i, alg := range Federation.SignatureAlgorithms { 51 HttpsigAlgs[i] = httpsig.Algorithm(alg) 52 } 53}