From 87bfa79f71593975a1fa8318aaf519739f479f00 Mon Sep 17 00:00:00 2001 From: bom Date: Fri, 12 Jan 2024 12:29:00 +0100 Subject: [PATCH] Configure client against DOS --- modules/activitypub/client.go | 4 +++- routers/api/v1/activitypub/repository.go | 4 ---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/modules/activitypub/client.go b/modules/activitypub/client.go index 8f5f4617b8..25f56aff41 100644 --- a/modules/activitypub/client.go +++ b/modules/activitypub/client.go @@ -85,8 +85,10 @@ func NewClient(ctx context.Context, user *user_model.User, pubID string) (c *Cli c = &Client{ client: &http.Client{ Transport: &http.Transport{ - Proxy: proxy.Proxy(), + Proxy: proxy.Proxy(), + MaxConnsPerHost: 20, }, + Timeout: time.Duration(5 * time.Second), }, algs: setting.HttpsigAlgs, digestAlg: httpsig.DigestAlgorithm(setting.Federation.DigestAlgorithm), diff --git a/routers/api/v1/activitypub/repository.go b/routers/api/v1/activitypub/repository.go index e830dd8450..005f2c98a3 100644 --- a/routers/api/v1/activitypub/repository.go +++ b/routers/api/v1/activitypub/repository.go @@ -10,7 +10,6 @@ import ( "fmt" "net/http" "strings" - "time" "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/forgefed" @@ -160,9 +159,6 @@ func RepositoryInbox(ctx *context.APIContext) { } } - // wait 5 sec. - time.Sleep(5 * time.Second) - ctx.Status(http.StatusNoContent) }