diff --git a/.github/workflows/development.yml b/.github/workflows/development.yml index 796d4765..5d4d5022 100644 --- a/.github/workflows/development.yml +++ b/.github/workflows/development.yml @@ -57,11 +57,11 @@ jobs: - name: Run test cases using bolt provider run: | go test -v -p 1 -timeout 2m ./config -covermode=atomic - go test -v -p 1 -timeout 2m ./common -covermode=atomic - go test -v -p 1 -timeout 3m ./httpd -covermode=atomic + go test -v -p 1 -timeout 5m ./common -covermode=atomic + go test -v -p 1 -timeout 5m ./httpd -covermode=atomic go test -v -p 1 -timeout 8m ./sftpd -covermode=atomic - go test -v -p 1 -timeout 2m ./ftpd -covermode=atomic - go test -v -p 1 -timeout 2m ./webdavd -covermode=atomic + go test -v -p 1 -timeout 5m ./ftpd -covermode=atomic + go test -v -p 1 -timeout 5m ./webdavd -covermode=atomic go test -v -p 1 -timeout 2m ./telemetry -covermode=atomic env: SFTPGO_DATA_PROVIDER__DRIVER: bolt @@ -302,7 +302,7 @@ jobs: with: go-version: 1.16 - name: Run golangci-lint - uses: golangci/golangci-lint-action@v2.5.2 + uses: golangci/golangci-lint-action@v2 with: version: latest skip-go-installation: true \ No newline at end of file diff --git a/dataprovider/user.go b/dataprovider/user.go index e5155062..e6e3ee3c 100644 --- a/dataprovider/user.go +++ b/dataprovider/user.go @@ -853,9 +853,9 @@ func (u *User) isFilePatternAllowed(virtualPath string) bool { return true } -// CanManahePublicKeys return true if this user is allowed to manage public keys +// CanManagePublicKeys return true if this user is allowed to manage public keys // from the web client -func (u *User) CanManahePublicKeys() bool { +func (u *User) CanManagePublicKeys() bool { return !utils.IsStringInSlice(WebClientPubKeyChangeDisabled, u.Filters.WebClient) } diff --git a/httpd/httpd.go b/httpd/httpd.go index fad1b9ca..c9e1edbc 100644 --- a/httpd/httpd.go +++ b/httpd/httpd.go @@ -79,9 +79,10 @@ const ( webClientLogoutPathDefault = "/web/client/logout" webStaticFilesPathDefault = "/static" // MaxRestoreSize defines the max size for the loaddata input file - MaxRestoreSize = 10485760 // 10 MB - maxRequestSize = 1048576 // 1MB - osWindows = "windows" + MaxRestoreSize = 10485760 // 10 MB + maxRequestSize = 1048576 // 1MB + maxLoginPostSize = 262144 // 256 KB + osWindows = "windows" ) var ( diff --git a/httpd/server.go b/httpd/server.go index 53b7aac8..09348283 100644 --- a/httpd/server.go +++ b/httpd/server.go @@ -48,14 +48,12 @@ func (s *httpdServer) listenAndServe() error { httpServer := &http.Server{ Handler: s.router, ReadHeaderTimeout: 30 * time.Second, - IdleTimeout: 120 * time.Second, + ReadTimeout: 60 * time.Second, + WriteTimeout: 60 * time.Second, + IdleTimeout: 60 * time.Second, MaxHeaderBytes: 1 << 16, // 64KB ErrorLog: log.New(&logger.StdLoggerWrapper{Sender: logSender}, "", 0), } - if !s.binding.EnableWebClient { - httpServer.ReadTimeout = 60 * time.Second - httpServer.WriteTimeout = 90 * time.Second - } if certMgr != nil && s.binding.EnableHTTPS { config := &tls.Config{ GetCertificate: certMgr.GetCertificateFunc(), @@ -111,7 +109,7 @@ func (s *httpdServer) refreshCookie(next http.Handler) http.Handler { } func (s *httpdServer) handleWebClientLoginPost(w http.ResponseWriter, r *http.Request) { - r.Body = http.MaxBytesReader(w, r.Body, maxRequestSize) + r.Body = http.MaxBytesReader(w, r.Body, maxLoginPostSize) common.Connections.AddNetworkConnection() defer common.Connections.RemoveNetworkConnection() @@ -185,7 +183,7 @@ func (s *httpdServer) handleWebClientLoginPost(w http.ResponseWriter, r *http.Re } func (s *httpdServer) handleWebAdminLoginPost(w http.ResponseWriter, r *http.Request) { - r.Body = http.MaxBytesReader(w, r.Body, maxRequestSize) + r.Body = http.MaxBytesReader(w, r.Body, maxLoginPostSize) if err := r.ParseForm(); err != nil { renderLoginPage(w, err.Error()) return diff --git a/httpd/webclient.go b/httpd/webclient.go index 65e21297..97bfe669 100644 --- a/httpd/webclient.go +++ b/httpd/webclient.go @@ -582,10 +582,7 @@ func parseRangeRequest(bytesRange string, size int64) (int64, int64, error) { // we have something like -500 start = size - end size = end - // this can't happen, we did end = size -1 above - /*if start < 0 { - return 0, 0, fmt.Errorf("unacceptable range %#v", bytesRange) - }*/ + // start cannit be < 0 here, we did end = size -1 above } else { // we have something like 500-600 size = end - start + 1 @@ -595,9 +592,6 @@ func parseRangeRequest(bytesRange string, size int64) (int64, int64, error) { } return start, size, nil } - /*if start == -1 { - return 0, 0, fmt.Errorf("unacceptable range %#v", bytesRange) - }*/ // we have something like 500- size -= start if size < 0 { diff --git a/telemetry/telemetry.go b/telemetry/telemetry.go index cea2a497..f2e3d63b 100644 --- a/telemetry/telemetry.go +++ b/telemetry/telemetry.go @@ -89,12 +89,13 @@ func (c Conf) Initialize(configDir string) error { certificateKeyFile := getConfigPath(c.CertificateKeyFile, configDir) initializeRouter(c.EnableProfiler) httpServer := &http.Server{ - Handler: router, - ReadTimeout: 60 * time.Second, - WriteTimeout: 60 * time.Second, - IdleTimeout: 120 * time.Second, - MaxHeaderBytes: 1 << 14, // 16KB - ErrorLog: log.New(&logger.StdLoggerWrapper{Sender: logSender}, "", 0), + Handler: router, + ReadHeaderTimeout: 30 * time.Second, + ReadTimeout: 60 * time.Second, + WriteTimeout: 60 * time.Second, + IdleTimeout: 60 * time.Second, + MaxHeaderBytes: 1 << 14, // 16KB + ErrorLog: log.New(&logger.StdLoggerWrapper{Sender: logSender}, "", 0), } if certificateFile != "" && certificateKeyFile != "" { certMgr, err = common.NewCertManager(certificateFile, certificateKeyFile, configDir, logSender) diff --git a/templates/webclient/credentials.html b/templates/webclient/credentials.html index 34763549..db039211 100644 --- a/templates/webclient/credentials.html +++ b/templates/webclient/credentials.html @@ -41,7 +41,7 @@ -{{if .LoggedUser.CanManahePublicKeys}} +{{if .LoggedUser.CanManagePublicKeys}}