update to just pass instance account directly to nollamas middleware

This commit is contained in:
kim 2025-04-22 19:36:30 +01:00
commit b98ed0db3f
3 changed files with 5 additions and 13 deletions

View file

@ -499,7 +499,7 @@ var Start action.GTSAction = func(ctx context.Context) error {
s2sLimit := middleware.RateLimit(rlLimit, exceptions) // server-to-server (AP) s2sLimit := middleware.RateLimit(rlLimit, exceptions) // server-to-server (AP)
fsMainLimit := middleware.RateLimit(rlLimit, exceptions) // fileserver / web templates fsMainLimit := middleware.RateLimit(rlLimit, exceptions) // fileserver / web templates
fsEmojiLimit := middleware.RateLimit(rlLimit*2, exceptions) // fileserver (emojis only, use high limit) fsEmojiLimit := middleware.RateLimit(rlLimit*2, exceptions) // fileserver (emojis only, use high limit)
nollamas := middleware.NoLLaMas(state.DB) nollamas := middleware.NoLLaMas(instanceAccount)
// throttling // throttling
cpuMultiplier := config.GetAdvancedThrottlingMultiplier() cpuMultiplier := config.GetAdvancedThrottlingMultiplier()

View file

@ -257,8 +257,6 @@ var Start action.GTSAction = func(ctx context.Context) error {
nodeInfoModule = api.NewNodeInfo(processor) // nodeinfo endpoint nodeInfoModule = api.NewNodeInfo(processor) // nodeinfo endpoint
activityPubModule = api.NewActivityPub(state.DB, processor) // ActivityPub endpoints activityPubModule = api.NewActivityPub(state.DB, processor) // ActivityPub endpoints
webModule = web.New(state.DB, processor) // web pages + user profiles + settings panels etc webModule = web.New(state.DB, processor) // web pages + user profiles + settings panels etc
nollamas = middleware.NoLLaMas(state.DB)
) )
// these should be routed in order // these should be routed in order
@ -273,7 +271,7 @@ var Start action.GTSAction = func(ctx context.Context) error {
nodeInfoModule.Route(route) nodeInfoModule.Route(route)
activityPubModule.Route(route) activityPubModule.Route(route)
activityPubModule.RoutePublicKey(route) activityPubModule.RoutePublicKey(route)
webModule.Route(route, nollamas) webModule.Route(route)
// Create background cleaner. // Create background cleaner.
cleaner := cleaner.New(state) cleaner := cleaner.New(state)

View file

@ -18,7 +18,6 @@
package middleware package middleware
import ( import (
"context"
"crypto/sha256" "crypto/sha256"
"crypto/sha512" "crypto/sha512"
"crypto/subtle" "crypto/subtle"
@ -30,19 +29,14 @@ import (
"codeberg.org/gruf/go-byteutil" "codeberg.org/gruf/go-byteutil"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/superseriousbusiness/gotosocial/internal/db" "github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/superseriousbusiness/gotosocial/internal/oauth" "github.com/superseriousbusiness/gotosocial/internal/oauth"
) )
func NoLLaMas(db db.DB) gin.HandlerFunc { func NoLLaMas(instanceAcc *gtsmodel.Account) gin.HandlerFunc {
instance, err := db.GetInstanceAccount(context.Background(), "")
if err != nil {
panic(err)
}
// Generate seed hash from // Generate seed hash from
// this instance private key. // this instance private key.
priv := instance.PrivateKey priv := instanceAcc.PrivateKey
bpriv := x509.MarshalPKCS1PrivateKey(priv) bpriv := x509.MarshalPKCS1PrivateKey(priv)
seed := sha512.Sum512(bpriv) seed := sha512.Sum512(bpriv)