You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ssh_log.go 684B

123456789101112131415161718192021222324252627282930313233
  1. // Copyright 2021 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package private
  4. import (
  5. "net/http"
  6. "code.gitea.io/gitea/modules/context"
  7. "code.gitea.io/gitea/modules/log"
  8. "code.gitea.io/gitea/modules/private"
  9. "code.gitea.io/gitea/modules/setting"
  10. "code.gitea.io/gitea/modules/web"
  11. )
  12. // SSHLog hook to response ssh log
  13. func SSHLog(ctx *context.PrivateContext) {
  14. if !setting.Log.EnableSSHLog {
  15. ctx.Status(http.StatusOK)
  16. return
  17. }
  18. opts := web.GetForm(ctx).(*private.SSHLogOption)
  19. if opts.IsError {
  20. log.Error("ssh: %v", opts.Message)
  21. ctx.Status(http.StatusOK)
  22. return
  23. }
  24. log.Debug("ssh: %v", opts.Message)
  25. ctx.Status(http.StatusOK)
  26. }