Configure client against DOS

This commit is contained in:
bom 2024-01-12 12:29:00 +01:00 committed by Michael Jerger
parent ecf391dcbf
commit 87bfa79f71
2 changed files with 3 additions and 5 deletions

View file

@ -85,8 +85,10 @@ func NewClient(ctx context.Context, user *user_model.User, pubID string) (c *Cli
c = &Client{ c = &Client{
client: &http.Client{ client: &http.Client{
Transport: &http.Transport{ Transport: &http.Transport{
Proxy: proxy.Proxy(), Proxy: proxy.Proxy(),
MaxConnsPerHost: 20,
}, },
Timeout: time.Duration(5 * time.Second),
}, },
algs: setting.HttpsigAlgs, algs: setting.HttpsigAlgs,
digestAlg: httpsig.DigestAlgorithm(setting.Federation.DigestAlgorithm), digestAlg: httpsig.DigestAlgorithm(setting.Federation.DigestAlgorithm),

View file

@ -10,7 +10,6 @@ import (
"fmt" "fmt"
"net/http" "net/http"
"strings" "strings"
"time"
"code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/db"
"code.gitea.io/gitea/models/forgefed" "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) ctx.Status(http.StatusNoContent)
} }