2021-05-22 05:37:16 +08:00
|
|
|
// Copyright 2021 The Gitea Authors. All rights reserved.
|
2022-11-27 13:20:29 -05:00
|
|
|
// SPDX-License-Identifier: MIT
|
2021-05-22 05:37:16 +08:00
|
|
|
|
|
|
|
package private
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
2025-03-27 19:40:14 +00:00
|
|
|
"forgejo.org/modules/log"
|
|
|
|
"forgejo.org/modules/private"
|
|
|
|
"forgejo.org/modules/web"
|
|
|
|
"forgejo.org/services/context"
|
2021-05-22 05:37:16 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
// SSHLog hook to response ssh log
|
|
|
|
func SSHLog(ctx *context.PrivateContext) {
|
2025-09-11 18:59:24 +02:00
|
|
|
logger := log.GetManager().GetLogger("ssh")
|
|
|
|
if !logger.IsEnabled() {
|
2021-05-22 05:37:16 +08:00
|
|
|
ctx.Status(http.StatusOK)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
opts := web.GetForm(ctx).(*private.SSHLogOption)
|
2025-09-11 18:59:24 +02:00
|
|
|
logger.Log(0, opts.Level, "ssh: %v", opts.Message)
|
2021-05-22 05:37:16 +08:00
|
|
|
ctx.Status(http.StatusOK)
|
|
|
|
}
|