chore: check sc-max-each-post-bytes greater than zero if set

This commit is contained in:
wwqgtxx
2026-04-08 15:53:00 +08:00
parent f109b8b095
commit 8c1b1a3ee2
3 changed files with 3 additions and 6 deletions
-3
View File
@@ -136,9 +136,6 @@ func NewClient(cfg *Config, makeTransport TransportMaker, makeDownloadTransport
if err != nil {
return nil, err
}
if scMaxEachPostBytes.Max == 0 { // default to 1MB
scMaxEachPostBytes.Max = 1000000
}
ctx, cancel := context.WithCancel(context.Background())
client := &Client{
+3
View File
@@ -114,6 +114,9 @@ func (c *Config) GetNormalizedScMaxEachPostBytes() (Range, error) {
if err != nil {
return Range{}, fmt.Errorf("invalid sc-max-each-post-bytes: %w", err)
}
if r.Max == 0 {
return Range{}, fmt.Errorf("invalid sc-max-each-post-bytes: must be greater than zero")
}
return r, nil
}
-3
View File
@@ -110,9 +110,6 @@ func NewServerHandler(opt ServerOption) (http.Handler, error) {
if err != nil {
return nil, err
}
if scMaxEachPostBytes.Max == 0 { // default to 1MB
scMaxEachPostBytes.Max = 1000000
}
scStreamUpServerSecs, err := opt.Config.GetNormalizedScStreamUpServerSecs()
if err != nil {
return nil, err